Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Refactor of Zend\Db\Metadata for 3.0.0 #369

Open
wants to merge 14 commits into
base: 3.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions 3.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ Changed `setDriver(DriverInterface $driver)` for all the following platforms:
- Zend\Db\Adapter\Platform\Postgresql
- Zend\Db\Adapter\Platform\Sqlite
- Zend\Db\Adapter\Platform\SqlServer

- Zend\Db\Adapter\Adapter\OracleMetadata

Removed return statement of `loadColumnData()` and `loadTableNameData()` to
be compatible with return hint declaration of `Zend\Db\Metadata\Source\AbstractSource`

- Zend\Db\Metadata\Source\SqliteMetadata

`parseView()` and `parseTrigger()` now possibly return `array|null` instead of `array|void`
4 changes: 2 additions & 2 deletions src/Adapter/Driver/Pdo/Pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ public function setupDefaultFeatures(): DriverFeatureInterface
/**
* Get feature
*
* @param $name
* @param string $name
* @return AbstractFeature|false
*/
public function getFeature($name)
public function getFeature(string $name)
{
if (isset($this->features[$name])) {
return $this->features[$name];
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Driver/Pgsql/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function execute(string $sql): ResultInterface
/**
* {@inheritDoc}
*/
public function getLastGeneratedValue($name = null): string
public function getLastGeneratedValue(string $name = null): string
{
if ($name === null) {
return '';
Expand Down
108 changes: 29 additions & 79 deletions src/Metadata/Metadata.php
Original file line number Diff line number Diff line change
@@ -1,160 +1,110 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see https://github.com/zendframework/zend-db for the canonical source repository
* @copyright Copyright (c) 2005-2019 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace Zend\Db\Metadata;

use Zend\Db\Adapter\Adapter;
use Zend\Db\Metadata\Object\ColumnObject;
use Zend\Db\Metadata\Object\ConstraintObject;
use Zend\Db\Metadata\Object\TableObject;
use Zend\Db\Metadata\Object\TriggerObject;
use Zend\Db\Metadata\Object\ViewObject;

/**
* @deprecated Use Zend\Db\Metadata\Source\Factory::createSourceFromAdapter($adapter)
*/
class Metadata implements MetadataInterface
{
/**
* @var MetadataInterface
*/
protected $source = null;

/**
* Constructor
*
* @param Adapter $adapter
*/
/** @var MetadataInterface */
protected $source;

public function __construct(Adapter $adapter)
{
$this->source = Source\Factory::createSourceFromAdapter($adapter);
}

/**
* {@inheritdoc}
*/
public function getTables($schema = null, $includeViews = false)
public function getTables(?string $schema = null, bool $includeViews = false) : array
{
return $this->source->getTables($schema, $includeViews);
}

/**
* {@inheritdoc}
*/
public function getViews($schema = null)
public function getViews(?string $schema = null) : array
{
return $this->source->getViews($schema);
}

/**
* {@inheritdoc}
*/
public function getTriggers($schema = null)
public function getTriggers(?string $schema = null) : array
{
return $this->source->getTriggers($schema);
}

/**
* {@inheritdoc}
*/
public function getConstraints($table, $schema = null)
public function getConstraints(string $table, ?string $schema = null) : array
{
return $this->source->getConstraints($table, $schema);
}

/**
* {@inheritdoc}
*/
public function getColumns($table, $schema = null)
public function getColumns(string $table, ?string $schema = null) : array
{
return $this->source->getColumns($table, $schema);
}

/**
* {@inheritdoc}
*/
public function getConstraintKeys($constraint, $table, $schema = null)
public function getConstraintKeys($constraint, $table, ?string $schema = null) : array
{
return $this->source->getConstraintKeys($constraint, $table, $schema);
}

/**
* {@inheritdoc}
*/
public function getConstraint($constraintName, $table, $schema = null)
public function getConstraint($constraintName, $table, ?string $schema = null) : ConstraintObject
{
return $this->source->getConstraint($constraintName, $table, $schema);
}

/**
* {@inheritdoc}
*/
public function getSchemas()
public function getSchemas() : array
{
return $this->source->getSchemas();
}

/**
* {@inheritdoc}
*/
public function getTableNames($schema = null, $includeViews = false)
public function getTableNames(?string $schema = null, bool $includeViews = false) : array
{
return $this->source->getTableNames($schema, $includeViews);
}

/**
* {@inheritdoc}
*/
public function getTable($tableName, $schema = null)
public function getTable($tableName, ?string $schema = null) : TableObject
{
return $this->source->getTable($tableName, $schema);
}

/**
* {@inheritdoc}
*/
public function getViewNames($schema = null)
public function getViewNames(?string $schema = null) : array
{
return $this->source->getViewNames($schema);
}

/**
* {@inheritdoc}
*/
public function getView($viewName, $schema = null)
public function getView($viewName, ?string $schema = null) : ViewObject
{
return $this->source->getView($viewName, $schema);
}

/**
* {@inheritdoc}
*/
public function getTriggerNames($schema = null)
public function getTriggerNames(?string $schema = null) : array
{
return $this->source->getTriggerNames($schema);
}

/**
* {@inheritdoc}
*/
public function getTrigger($triggerName, $schema = null)
public function getTrigger($triggerName, ?string $schema = null) : TriggerObject
{
return $this->source->getTrigger($triggerName, $schema);
}

/**
* {@inheritdoc}
*/
public function getColumnNames($table, $schema = null)
public function getColumnNames(string $table, ?string $schema = null) : array
{
return $this->source->getColumnNames($table, $schema);
}

/**
* {@inheritdoc}
*/
public function getColumn($columnName, $table, $schema = null)
public function getColumn($columnName, $table, ?string $schema = null) : ColumnObject
{
return $this->source->getColumn($columnName, $table, $schema);
}
Expand Down
Loading