From 6f75f6b999871863f8521bd1f795dea11043253b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 09:26:45 +0100 Subject: [PATCH 01/14] Declared return types --- 3.0.0.md | 9 ++++ src/Metadata/Metadata.php | 39 ++++++++------ src/Metadata/MetadataInterface.php | 61 ++++++++++++---------- src/Metadata/Source/AbstractSource.php | 48 ++++++++--------- src/Metadata/Source/MysqlMetadata.php | 16 +++--- src/Metadata/Source/OracleMetadata.php | 18 +++---- src/Metadata/Source/PostgresqlMetadata.php | 10 ++-- src/Metadata/Source/SqlServerMetadata.php | 10 ++-- src/Metadata/Source/SqliteMetadata.php | 14 ++--- 9 files changed, 121 insertions(+), 104 deletions(-) diff --git a/3.0.0.md b/3.0.0.md index b1c3abfb90..37b3c6bcc0 100644 --- a/3.0.0.md +++ b/3.0.0.md @@ -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 + +`parseTrigger()` now possibly return `array|null` instead of `array|void` diff --git a/src/Metadata/Metadata.php b/src/Metadata/Metadata.php index c00cdfcf83..b2e422bd7c 100644 --- a/src/Metadata/Metadata.php +++ b/src/Metadata/Metadata.php @@ -3,13 +3,18 @@ * 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) + * @copyright Copyright (c) 2005-2019 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ 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) @@ -34,7 +39,7 @@ public function __construct(Adapter $adapter) /** * {@inheritdoc} */ - public function getTables($schema = null, $includeViews = false) + public function getTables($schema = null, $includeViews = false) : array { return $this->source->getTables($schema, $includeViews); } @@ -42,7 +47,7 @@ public function getTables($schema = null, $includeViews = false) /** * {@inheritdoc} */ - public function getViews($schema = null) + public function getViews($schema = null) : array { return $this->source->getViews($schema); } @@ -50,7 +55,7 @@ public function getViews($schema = null) /** * {@inheritdoc} */ - public function getTriggers($schema = null) + public function getTriggers($schema = null) : array { return $this->source->getTriggers($schema); } @@ -58,7 +63,7 @@ public function getTriggers($schema = null) /** * {@inheritdoc} */ - public function getConstraints($table, $schema = null) + public function getConstraints($table, $schema = null) : array { return $this->source->getConstraints($table, $schema); } @@ -66,7 +71,7 @@ public function getConstraints($table, $schema = null) /** * {@inheritdoc} */ - public function getColumns($table, $schema = null) + public function getColumns($table, $schema = null) : array { return $this->source->getColumns($table, $schema); } @@ -74,7 +79,7 @@ public function getColumns($table, $schema = null) /** * {@inheritdoc} */ - public function getConstraintKeys($constraint, $table, $schema = null) + public function getConstraintKeys($constraint, $table, $schema = null) : array { return $this->source->getConstraintKeys($constraint, $table, $schema); } @@ -82,7 +87,7 @@ public function getConstraintKeys($constraint, $table, $schema = null) /** * {@inheritdoc} */ - public function getConstraint($constraintName, $table, $schema = null) + public function getConstraint($constraintName, $table, $schema = null) : ConstraintObject { return $this->source->getConstraint($constraintName, $table, $schema); } @@ -90,7 +95,7 @@ public function getConstraint($constraintName, $table, $schema = null) /** * {@inheritdoc} */ - public function getSchemas() + public function getSchemas() : array { return $this->source->getSchemas(); } @@ -98,7 +103,7 @@ public function getSchemas() /** * {@inheritdoc} */ - public function getTableNames($schema = null, $includeViews = false) + public function getTableNames($schema = null, $includeViews = false) : array { return $this->source->getTableNames($schema, $includeViews); } @@ -106,7 +111,7 @@ public function getTableNames($schema = null, $includeViews = false) /** * {@inheritdoc} */ - public function getTable($tableName, $schema = null) + public function getTable($tableName, $schema = null) : TableObject { return $this->source->getTable($tableName, $schema); } @@ -114,7 +119,7 @@ public function getTable($tableName, $schema = null) /** * {@inheritdoc} */ - public function getViewNames($schema = null) + public function getViewNames($schema = null) : array { return $this->source->getViewNames($schema); } @@ -122,7 +127,7 @@ public function getViewNames($schema = null) /** * {@inheritdoc} */ - public function getView($viewName, $schema = null) + public function getView($viewName, $schema = null) : ViewObject { return $this->source->getView($viewName, $schema); } @@ -130,7 +135,7 @@ public function getView($viewName, $schema = null) /** * {@inheritdoc} */ - public function getTriggerNames($schema = null) + public function getTriggerNames($schema = null) : array { return $this->source->getTriggerNames($schema); } @@ -138,7 +143,7 @@ public function getTriggerNames($schema = null) /** * {@inheritdoc} */ - public function getTrigger($triggerName, $schema = null) + public function getTrigger($triggerName, $schema = null) : TriggerObject { return $this->source->getTrigger($triggerName, $schema); } @@ -146,7 +151,7 @@ public function getTrigger($triggerName, $schema = null) /** * {@inheritdoc} */ - public function getColumnNames($table, $schema = null) + public function getColumnNames($table, $schema = null) : array { return $this->source->getColumnNames($table, $schema); } @@ -154,7 +159,7 @@ public function getColumnNames($table, $schema = null) /** * {@inheritdoc} */ - public function getColumn($columnName, $table, $schema = null) + public function getColumn($columnName, $table, $schema = null) : ColumnObject { return $this->source->getColumn($columnName, $table, $schema); } diff --git a/src/Metadata/MetadataInterface.php b/src/Metadata/MetadataInterface.php index 5a395be2da..a19afda921 100644 --- a/src/Metadata/MetadataInterface.php +++ b/src/Metadata/MetadataInterface.php @@ -9,6 +9,13 @@ namespace Zend\Db\Metadata; +use Zend\Db\Metadata\Object\ColumnObject; +use Zend\Db\Metadata\Object\ConstraintKeyObject; +use Zend\Db\Metadata\Object\ConstraintObject; +use Zend\Db\Metadata\Object\TableObject; +use Zend\Db\Metadata\Object\TriggerObject; +use Zend\Db\Metadata\Object\ViewObject; + interface MetadataInterface { /** @@ -16,7 +23,7 @@ interface MetadataInterface * * @return string[] */ - public function getSchemas(); + public function getSchemas() : array; /** * Get table names. @@ -25,25 +32,25 @@ public function getSchemas(); * @param bool $includeViews * @return string[] */ - public function getTableNames($schema = null, $includeViews = false); + public function getTableNames($schema = null, $includeViews = false) : array; /** * Get tables. * * @param null|string $schema * @param bool $includeViews - * @return Object\TableObject[] + * @return TableObject[] */ - public function getTables($schema = null, $includeViews = false); + public function getTables($schema = null, $includeViews = false) : array; /** * Get table * * @param string $tableName * @param null|string $schema - * @return Object\TableObject + * @return TableObject */ - public function getTable($tableName, $schema = null); + public function getTable($tableName, $schema = null) : TableObject; /** * Get view names @@ -51,24 +58,24 @@ public function getTable($tableName, $schema = null); * @param null|string $schema * @return string[] */ - public function getViewNames($schema = null); + public function getViewNames($schema = null) : array; /** * Get views * * @param null|string $schema - * @return Object\ViewObject[] + * @return ViewObject[] */ - public function getViews($schema = null); + public function getViews($schema = null) : array; /** * Get view * * @param string $viewName * @param null|string $schema - * @return Object\ViewObject + * @return ViewObject */ - public function getView($viewName, $schema = null); + public function getView($viewName, $schema = null) : ViewObject; /** * Get column names @@ -77,16 +84,16 @@ public function getView($viewName, $schema = null); * @param null|string $schema * @return string[] */ - public function getColumnNames($table, $schema = null); + public function getColumnNames($table, $schema = null) : array; /** * Get columns * * @param string $table * @param null|string $schema - * @return Object\ColumnObject[] + * @return ColumnObject[] */ - public function getColumns($table, $schema = null); + public function getColumns($table, $schema = null) : array; /** * Get column @@ -94,18 +101,18 @@ public function getColumns($table, $schema = null); * @param string $columnName * @param string $table * @param null|string $schema - * @return Object\ColumnObject + * @return ColumnObject */ - public function getColumn($columnName, $table, $schema = null); + public function getColumn($columnName, $table, $schema = null) : ColumnObject; /** * Get constraints * * @param string $table * @param null|string $schema - * @return Object\ConstraintObject[] + * @return ConstraintObject[] */ - public function getConstraints($table, $schema = null); + public function getConstraints($table, $schema = null) : array; /** * Get constraint @@ -113,9 +120,9 @@ public function getConstraints($table, $schema = null); * @param string $constraintName * @param string $table * @param null|string $schema - * @return Object\ConstraintObject + * @return ConstraintObject */ - public function getConstraint($constraintName, $table, $schema = null); + public function getConstraint($constraintName, $table, $schema = null) : ConstraintObject; /** * Get constraint keys @@ -123,9 +130,9 @@ public function getConstraint($constraintName, $table, $schema = null); * @param string $constraint * @param string $table * @param null|string $schema - * @return Object\ConstraintKeyObject[] + * @return ConstraintKeyObject[] */ - public function getConstraintKeys($constraint, $table, $schema = null); + public function getConstraintKeys($constraint, $table, $schema = null) : array; /** * Get trigger names @@ -133,22 +140,22 @@ public function getConstraintKeys($constraint, $table, $schema = null); * @param null|string $schema * @return string[] */ - public function getTriggerNames($schema = null); + public function getTriggerNames($schema = null) : array; /** * Get triggers * * @param null|string $schema - * @return Object\TriggerObject[] + * @return TriggerObject[] */ - public function getTriggers($schema = null); + public function getTriggers($schema = null) : array; /** * Get trigger * * @param string $triggerName * @param null|string $schema - * @return Object\TriggerObject + * @return TriggerObject */ - public function getTrigger($triggerName, $schema = null); + public function getTrigger($triggerName, $schema = null) : TriggerObject; } diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index 0bd5c162e3..43dce2fef7 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -55,7 +55,7 @@ public function __construct(Adapter $adapter) * Get schemas * */ - public function getSchemas() + public function getSchemas() : array { $this->loadSchemaData(); @@ -65,7 +65,7 @@ public function getSchemas() /** * {@inheritdoc} */ - public function getTableNames($schema = null, $includeViews = false) + public function getTableNames($schema = null, $includeViews = false) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -89,7 +89,7 @@ public function getTableNames($schema = null, $includeViews = false) /** * {@inheritdoc} */ - public function getTables($schema = null, $includeViews = false) + public function getTables($schema = null, $includeViews = false) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -105,7 +105,7 @@ public function getTables($schema = null, $includeViews = false) /** * {@inheritdoc} */ - public function getTable($tableName, $schema = null) + public function getTable($tableName, $schema = null) : TableObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -141,7 +141,7 @@ public function getTable($tableName, $schema = null) /** * {@inheritdoc} */ - public function getViewNames($schema = null) + public function getViewNames($schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -161,7 +161,7 @@ public function getViewNames($schema = null) /** * {@inheritdoc} */ - public function getViews($schema = null) + public function getViews($schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -177,7 +177,7 @@ public function getViews($schema = null) /** * {@inheritdoc} */ - public function getView($viewName, $schema = null) + public function getView($viewName, $schema = null) : ViewObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -195,7 +195,7 @@ public function getView($viewName, $schema = null) /** * {@inheritdoc} */ - public function getColumnNames($table, $schema = null) + public function getColumnNames($table, $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -213,7 +213,7 @@ public function getColumnNames($table, $schema = null) /** * {@inheritdoc} */ - public function getColumns($table, $schema = null) + public function getColumns($table, $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -231,7 +231,7 @@ public function getColumns($table, $schema = null) /** * {@inheritdoc} */ - public function getColumn($columnName, $table, $schema = null) + public function getColumn($columnName, $table, $schema = null) : ColumnObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -275,7 +275,7 @@ public function getColumn($columnName, $table, $schema = null) /** * {@inheritdoc} */ - public function getConstraints($table, $schema = null) + public function getConstraints($table, $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -294,7 +294,7 @@ public function getConstraints($table, $schema = null) /** * {@inheritdoc} */ - public function getConstraint($constraintName, $table, $schema = null) + public function getConstraint($constraintName, $table, $schema = null) : ConstraintObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -331,7 +331,7 @@ public function getConstraint($constraintName, $table, $schema = null) /** * {@inheritdoc} */ - public function getConstraintKeys($constraint, $table, $schema = null) + public function getConstraintKeys($constraint, $table, $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -371,7 +371,7 @@ public function getConstraintKeys($constraint, $table, $schema = null) /** * {@inheritdoc} */ - public function getTriggerNames($schema = null) + public function getTriggerNames($schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -385,7 +385,7 @@ public function getTriggerNames($schema = null) /** * {@inheritdoc} */ - public function getTriggers($schema = null) + public function getTriggers($schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -401,7 +401,7 @@ public function getTriggers($schema = null) /** * {@inheritdoc} */ - public function getTrigger($triggerName, $schema = null) + public function getTrigger($triggerName, $schema = null) : TriggerObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -442,7 +442,7 @@ public function getTrigger($triggerName, $schema = null) * @param string $type * @param string $key ... */ - protected function prepareDataHierarchy($type) + protected function prepareDataHierarchy($type) : void { $data = &$this->data; foreach (func_get_args() as $key) { @@ -456,7 +456,7 @@ protected function prepareDataHierarchy($type) /** * Load schema data */ - protected function loadSchemaData() + protected function loadSchemaData() : void { } @@ -465,7 +465,7 @@ protected function loadSchemaData() * * @param string $schema */ - protected function loadTableNameData($schema) + protected function loadTableNameData($schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -480,7 +480,7 @@ protected function loadTableNameData($schema) * @param string $table * @param string $schema */ - protected function loadColumnData($table, $schema) + protected function loadColumnData($table, $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -495,7 +495,7 @@ protected function loadColumnData($table, $schema) * @param string $table * @param string $schema */ - protected function loadConstraintData($table, $schema) + protected function loadConstraintData($table, $schema) : void { if (isset($this->data['constraints'][$schema])) { return; @@ -509,7 +509,7 @@ protected function loadConstraintData($table, $schema) * * @param string $schema */ - protected function loadConstraintDataKeys($schema) + protected function loadConstraintDataKeys($schema) : void { if (isset($this->data['constraint_keys'][$schema])) { return; @@ -524,7 +524,7 @@ protected function loadConstraintDataKeys($schema) * @param string $table * @param string $schema */ - protected function loadConstraintReferences($table, $schema) + protected function loadConstraintReferences($table, $schema) : void { if (isset($this->data['constraint_references'][$schema])) { return; @@ -538,7 +538,7 @@ protected function loadConstraintReferences($table, $schema) * * @param string $schema */ - protected function loadTriggerData($schema) + protected function loadTriggerData($schema) : void { if (isset($this->data['triggers'][$schema])) { return; diff --git a/src/Metadata/Source/MysqlMetadata.php b/src/Metadata/Source/MysqlMetadata.php index c366fe9971..b0103c4c17 100644 --- a/src/Metadata/Source/MysqlMetadata.php +++ b/src/Metadata/Source/MysqlMetadata.php @@ -13,7 +13,7 @@ class MysqlMetadata extends AbstractSource { - protected function loadSchemaData() + protected function loadSchemaData() : void { if (isset($this->data['schemas'])) { return; @@ -37,7 +37,7 @@ protected function loadSchemaData() $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) + protected function loadTableNameData($schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -93,7 +93,7 @@ protected function loadTableNameData($schema) $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) + protected function loadColumnData($table, $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -175,7 +175,7 @@ protected function loadColumnData($table, $schema) $this->data['columns'][$schema][$table] = $columns; } - protected function loadConstraintData($table, $schema) + protected function loadConstraintData($table, $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -284,7 +284,7 @@ protected function loadConstraintData($table, $schema) $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadConstraintDataNames($schema) + protected function loadConstraintDataNames($schema) : void { if (isset($this->data['constraint_names'][$schema])) { return; @@ -332,7 +332,7 @@ protected function loadConstraintDataNames($schema) $this->data['constraint_names'][$schema] = $data; } - protected function loadConstraintDataKeys($schema) + protected function loadConstraintDataKeys($schema) : void { if (isset($this->data['constraint_keys'][$schema])) { return; @@ -383,7 +383,7 @@ protected function loadConstraintDataKeys($schema) $this->data['constraint_keys'][$schema] = $data; } - protected function loadConstraintReferences($table, $schema) + protected function loadConstraintReferences($table, $schema) : void { parent::loadConstraintReferences($table, $schema); @@ -441,7 +441,7 @@ protected function loadConstraintReferences($table, $schema) $this->data['constraint_references'][$schema] = $data; } - protected function loadTriggerData($schema) + protected function loadTriggerData($schema) : void { if (isset($this->data['triggers'][$schema])) { return; diff --git a/src/Metadata/Source/OracleMetadata.php b/src/Metadata/Source/OracleMetadata.php index 0ffa743d28..0a977aa706 100644 --- a/src/Metadata/Source/OracleMetadata.php +++ b/src/Metadata/Source/OracleMetadata.php @@ -29,7 +29,7 @@ class OracleMetadata extends AbstractSource * {@inheritdoc} * @see \Zend\Db\Metadata\Source\AbstractSource::loadColumnData() */ - protected function loadColumnData($table, $schema) + protected function loadColumnData($table, $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -75,7 +75,6 @@ protected function loadColumnData($table, $schema) } $this->data['columns'][$schema][$table] = $columns; - return $this; } /** @@ -84,7 +83,7 @@ protected function loadColumnData($table, $schema) * @param string $type * @return string */ - protected function getConstraintType($type) + protected function getConstraintType($type) : string { if (isset($this->constraintTypeMap[$type])) { return $this->constraintTypeMap[$type]; @@ -97,7 +96,7 @@ protected function getConstraintType($type) * {@inheritdoc} * @see \Zend\Db\Metadata\Source\AbstractSource::loadConstraintData() */ - protected function loadConstraintData($table, $schema) + protected function loadConstraintData($table, $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -171,15 +170,13 @@ protected function loadConstraintData($table, $schema) $constraints[$name]['referenced_columns'][] = $row['REF_COLUMN']; } } - - return $this; } /** * {@inheritdoc} * @see \Zend\Db\Metadata\Source\AbstractSource::loadSchemaData() */ - protected function loadSchemaData() + protected function loadSchemaData() : void { if (isset($this->data['schemas'])) { return; @@ -201,10 +198,10 @@ protected function loadSchemaData() * {@inheritdoc} * @see \Zend\Db\Metadata\Source\AbstractSource::loadTableNameData() */ - protected function loadTableNameData($schema) + protected function loadTableNameData($schema) : void { if (isset($this->data['table_names'][$schema])) { - return $this; + return; } $this->prepareDataHierarchy('table_names', $schema); @@ -235,7 +232,6 @@ protected function loadTableNameData($schema) } $this->data['table_names'][$schema] = $tables; - return $this; } /** @@ -245,7 +241,7 @@ protected function loadTableNameData($schema) * * @see \Zend\Db\Metadata\Source\AbstractSource::loadTriggerData() */ - protected function loadTriggerData($schema) + protected function loadTriggerData($schema) : void { if (isset($this->data['triggers'][$schema])) { return; diff --git a/src/Metadata/Source/PostgresqlMetadata.php b/src/Metadata/Source/PostgresqlMetadata.php index 8b43c7ef30..4a0e826a5b 100644 --- a/src/Metadata/Source/PostgresqlMetadata.php +++ b/src/Metadata/Source/PostgresqlMetadata.php @@ -13,7 +13,7 @@ class PostgresqlMetadata extends AbstractSource { - protected function loadSchemaData() + protected function loadSchemaData() : void { if (isset($this->data['schemas'])) { return; @@ -38,7 +38,7 @@ protected function loadSchemaData() $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) + protected function loadTableNameData($schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -94,7 +94,7 @@ protected function loadTableNameData($schema) $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) + protected function loadColumnData($table, $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -154,7 +154,7 @@ protected function loadColumnData($table, $schema) $this->data['columns'][$schema][$table] = $columns; } - protected function loadConstraintData($table, $schema) + protected function loadConstraintData($table, $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -281,7 +281,7 @@ protected function loadConstraintData($table, $schema) $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadTriggerData($schema) + protected function loadTriggerData($schema) : void { if (isset($this->data['triggers'][$schema])) { return; diff --git a/src/Metadata/Source/SqlServerMetadata.php b/src/Metadata/Source/SqlServerMetadata.php index 9cdad7f807..1a978d4028 100644 --- a/src/Metadata/Source/SqlServerMetadata.php +++ b/src/Metadata/Source/SqlServerMetadata.php @@ -13,7 +13,7 @@ class SqlServerMetadata extends AbstractSource { - protected function loadSchemaData() + protected function loadSchemaData() : void { if (isset($this->data['schemas'])) { return; @@ -37,7 +37,7 @@ protected function loadSchemaData() $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) + protected function loadTableNameData($schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -93,7 +93,7 @@ protected function loadTableNameData($schema) $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) + protected function loadColumnData($table, $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -157,7 +157,7 @@ protected function loadColumnData($table, $schema) $this->data['columns'][$schema][$table] = $columns; } - protected function loadConstraintData($table, $schema) + protected function loadConstraintData($table, $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -285,7 +285,7 @@ protected function loadConstraintData($table, $schema) $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadTriggerData($schema) + protected function loadTriggerData($schema) : void { if (isset($this->data['triggers'][$schema])) { return; diff --git a/src/Metadata/Source/SqliteMetadata.php b/src/Metadata/Source/SqliteMetadata.php index b189c3b271..f5176d0a94 100644 --- a/src/Metadata/Source/SqliteMetadata.php +++ b/src/Metadata/Source/SqliteMetadata.php @@ -14,7 +14,7 @@ class SqliteMetadata extends AbstractSource { - protected function loadSchemaData() + protected function loadSchemaData() : void { if (isset($this->data['schemas'])) { return; @@ -28,7 +28,7 @@ protected function loadSchemaData() $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) + protected function loadTableNameData($schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -70,7 +70,7 @@ protected function loadTableNameData($schema) $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) + protected function loadColumnData($table, $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -103,7 +103,7 @@ protected function loadColumnData($table, $schema) $this->data['sqlite_columns'][$schema][$table] = $results; } - protected function loadConstraintData($table, $schema) + protected function loadConstraintData($table, $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -186,7 +186,7 @@ protected function loadConstraintData($table, $schema) $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadTriggerData($schema) + protected function loadTriggerData($schema) : void { if (isset($this->data['triggers'][$schema])) { return; @@ -278,7 +278,7 @@ protected function parseView($sql) ]; } - protected function parseTrigger($sql) + protected function parseTrigger($sql) : ?array { static $re = null; if (null === $re) { @@ -306,7 +306,7 @@ protected function parseTrigger($sql) } if (! preg_match($re, $sql, $matches)) { - return; + return null; } $data = []; From b314200f38571a5c981931ffb3a0945830431639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 09:27:53 +0100 Subject: [PATCH 02/14] Fixed fatal errors due to incompatibility with super by declaring argument types --- src/Adapter/Driver/Pdo/Pdo.php | 4 ++-- src/Adapter/Driver/Pgsql/Connection.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Adapter/Driver/Pdo/Pdo.php b/src/Adapter/Driver/Pdo/Pdo.php index 71874d9c92..ccbcddb0e6 100644 --- a/src/Adapter/Driver/Pdo/Pdo.php +++ b/src/Adapter/Driver/Pdo/Pdo.php @@ -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]; diff --git a/src/Adapter/Driver/Pgsql/Connection.php b/src/Adapter/Driver/Pgsql/Connection.php index fa7707de98..555d9a3046 100644 --- a/src/Adapter/Driver/Pgsql/Connection.php +++ b/src/Adapter/Driver/Pgsql/Connection.php @@ -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 ''; From c13962461a61db1ca43933bdd6a75bfd7f56a1e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 09:34:24 +0100 Subject: [PATCH 03/14] Updated header comment and added stripct_types declaration --- src/Metadata/Metadata.php | 10 +++++----- src/Metadata/MetadataInterface.php | 10 +++++----- src/Metadata/Object/AbstractTableObject.php | 10 +++++----- src/Metadata/Object/ColumnObject.php | 10 +++++----- src/Metadata/Object/ConstraintKeyObject.php | 10 +++++----- src/Metadata/Object/ConstraintObject.php | 10 +++++----- src/Metadata/Object/TableObject.php | 10 +++++----- src/Metadata/Object/TriggerObject.php | 10 +++++----- src/Metadata/Object/ViewObject.php | 10 +++++----- src/Metadata/Source/AbstractSource.php | 10 +++++----- src/Metadata/Source/Factory.php | 10 +++++----- src/Metadata/Source/MysqlMetadata.php | 10 +++++----- src/Metadata/Source/OracleMetadata.php | 10 +++++----- src/Metadata/Source/PostgresqlMetadata.php | 10 +++++----- src/Metadata/Source/SqlServerMetadata.php | 10 +++++----- src/Metadata/Source/SqliteMetadata.php | 10 +++++----- 16 files changed, 80 insertions(+), 80 deletions(-) diff --git a/src/Metadata/Metadata.php b/src/Metadata/Metadata.php index b2e422bd7c..c304122cf6 100644 --- a/src/Metadata/Metadata.php +++ b/src/Metadata/Metadata.php @@ -1,12 +1,12 @@ Date: Wed, 13 Mar 2019 09:39:09 +0100 Subject: [PATCH 04/14] Removed comment --- src/Metadata/Object/AbstractTableObject.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Metadata/Object/AbstractTableObject.php b/src/Metadata/Object/AbstractTableObject.php index 70b4de8613..4929378483 100644 --- a/src/Metadata/Object/AbstractTableObject.php +++ b/src/Metadata/Object/AbstractTableObject.php @@ -11,11 +11,6 @@ abstract class AbstractTableObject { - /* - protected $catalogName = null; - protected $schemaName = null; - */ - /** * * @var string From e53b2e2292170771ab727d80eca914392682b353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 09:43:17 +0100 Subject: [PATCH 05/14] Declared argument type to be compatible with PlatformInterface --- src/Metadata/Source/SqliteMetadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Metadata/Source/SqliteMetadata.php b/src/Metadata/Source/SqliteMetadata.php index a32ebdf294..3c93606b28 100644 --- a/src/Metadata/Source/SqliteMetadata.php +++ b/src/Metadata/Source/SqliteMetadata.php @@ -231,7 +231,7 @@ protected function loadTriggerData($schema) : void $this->data['triggers'][$schema] = $triggers; } - protected function fetchPragma($name, $value = null, $schema = null) + protected function fetchPragma(string $name, string $value = null, string $schema = null) { $p = $this->adapter->getPlatform(); From 6795ab20a9918b2d61441e46cfea50f51bdb23cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 10:59:19 +0100 Subject: [PATCH 06/14] Updated default property values, added argument type and return type declarations --- src/Metadata/Metadata.php | 32 +++--- src/Metadata/MetadataInterface.php | 30 +++--- src/Metadata/Object/AbstractTableObject.php | 26 +++-- src/Metadata/Object/ColumnObject.php | 105 ++++++++++---------- src/Metadata/Object/ConstraintKeyObject.php | 56 +++++------ src/Metadata/Object/ConstraintObject.php | 82 +++++++-------- src/Metadata/Object/TriggerObject.php | 96 +++++++++--------- src/Metadata/Object/ViewObject.php | 20 ++-- src/Metadata/Source/AbstractSource.php | 51 +++++----- src/Metadata/Source/Factory.php | 2 +- src/Metadata/Source/MysqlMetadata.php | 14 +-- src/Metadata/Source/OracleMetadata.php | 10 +- src/Metadata/Source/PostgresqlMetadata.php | 8 +- src/Metadata/Source/SqlServerMetadata.php | 8 +- src/Metadata/Source/SqliteMetadata.php | 22 ++-- 15 files changed, 280 insertions(+), 282 deletions(-) diff --git a/src/Metadata/Metadata.php b/src/Metadata/Metadata.php index c304122cf6..f67f20fcd4 100644 --- a/src/Metadata/Metadata.php +++ b/src/Metadata/Metadata.php @@ -24,7 +24,7 @@ class Metadata implements MetadataInterface /** * @var MetadataInterface */ - protected $source = null; + protected $source; /** * Constructor @@ -39,7 +39,7 @@ public function __construct(Adapter $adapter) /** * {@inheritdoc} */ - public function getTables($schema = null, $includeViews = false) : array + public function getTables(?string $schema = null, bool $includeViews = false) : array { return $this->source->getTables($schema, $includeViews); } @@ -47,7 +47,7 @@ public function getTables($schema = null, $includeViews = false) : array /** * {@inheritdoc} */ - public function getViews($schema = null) : array + public function getViews(?string $schema = null) : array { return $this->source->getViews($schema); } @@ -55,7 +55,7 @@ public function getViews($schema = null) : array /** * {@inheritdoc} */ - public function getTriggers($schema = null) : array + public function getTriggers(?string $schema = null) : array { return $this->source->getTriggers($schema); } @@ -63,7 +63,7 @@ public function getTriggers($schema = null) : array /** * {@inheritdoc} */ - public function getConstraints($table, $schema = null) : array + public function getConstraints(string $table, ?string $schema = null) : array { return $this->source->getConstraints($table, $schema); } @@ -71,7 +71,7 @@ public function getConstraints($table, $schema = null) : array /** * {@inheritdoc} */ - public function getColumns($table, $schema = null) : array + public function getColumns(string $table, ?string $schema = null) : array { return $this->source->getColumns($table, $schema); } @@ -79,7 +79,7 @@ public function getColumns($table, $schema = null) : array /** * {@inheritdoc} */ - public function getConstraintKeys($constraint, $table, $schema = null) : array + public function getConstraintKeys($constraint, $table, ?string $schema = null) : array { return $this->source->getConstraintKeys($constraint, $table, $schema); } @@ -87,7 +87,7 @@ public function getConstraintKeys($constraint, $table, $schema = null) : array /** * {@inheritdoc} */ - public function getConstraint($constraintName, $table, $schema = null) : ConstraintObject + public function getConstraint($constraintName, $table, ?string $schema = null) : ConstraintObject { return $this->source->getConstraint($constraintName, $table, $schema); } @@ -103,7 +103,7 @@ public function getSchemas() : array /** * {@inheritdoc} */ - public function getTableNames($schema = null, $includeViews = false) : array + public function getTableNames(?string $schema = null, bool $includeViews = false) : array { return $this->source->getTableNames($schema, $includeViews); } @@ -111,7 +111,7 @@ public function getTableNames($schema = null, $includeViews = false) : array /** * {@inheritdoc} */ - public function getTable($tableName, $schema = null) : TableObject + public function getTable($tableName, ?string $schema = null) : TableObject { return $this->source->getTable($tableName, $schema); } @@ -119,7 +119,7 @@ public function getTable($tableName, $schema = null) : TableObject /** * {@inheritdoc} */ - public function getViewNames($schema = null) : array + public function getViewNames(?string $schema = null) : array { return $this->source->getViewNames($schema); } @@ -127,7 +127,7 @@ public function getViewNames($schema = null) : array /** * {@inheritdoc} */ - public function getView($viewName, $schema = null) : ViewObject + public function getView($viewName, ?string $schema = null) : ViewObject { return $this->source->getView($viewName, $schema); } @@ -135,7 +135,7 @@ public function getView($viewName, $schema = null) : ViewObject /** * {@inheritdoc} */ - public function getTriggerNames($schema = null) : array + public function getTriggerNames(?string $schema = null) : array { return $this->source->getTriggerNames($schema); } @@ -143,7 +143,7 @@ public function getTriggerNames($schema = null) : array /** * {@inheritdoc} */ - public function getTrigger($triggerName, $schema = null) : TriggerObject + public function getTrigger($triggerName, ?string $schema = null) : TriggerObject { return $this->source->getTrigger($triggerName, $schema); } @@ -151,7 +151,7 @@ public function getTrigger($triggerName, $schema = null) : TriggerObject /** * {@inheritdoc} */ - public function getColumnNames($table, $schema = null) : array + public function getColumnNames(string $table, ?string $schema = null) : array { return $this->source->getColumnNames($table, $schema); } @@ -159,7 +159,7 @@ public function getColumnNames($table, $schema = null) : array /** * {@inheritdoc} */ - public function getColumn($columnName, $table, $schema = null) : ColumnObject + public function getColumn($columnName, $table, ?string $schema = null) : ColumnObject { return $this->source->getColumn($columnName, $table, $schema); } diff --git a/src/Metadata/MetadataInterface.php b/src/Metadata/MetadataInterface.php index d4f79f45da..ddfdcecb09 100644 --- a/src/Metadata/MetadataInterface.php +++ b/src/Metadata/MetadataInterface.php @@ -32,7 +32,7 @@ public function getSchemas() : array; * @param bool $includeViews * @return string[] */ - public function getTableNames($schema = null, $includeViews = false) : array; + public function getTableNames(?string $schema = null, bool $includeViews = false) : array; /** * Get tables. @@ -41,7 +41,7 @@ public function getTableNames($schema = null, $includeViews = false) : array; * @param bool $includeViews * @return TableObject[] */ - public function getTables($schema = null, $includeViews = false) : array; + public function getTables(?string $schema = null, bool $includeViews = false) : array; /** * Get table @@ -50,7 +50,7 @@ public function getTables($schema = null, $includeViews = false) : array; * @param null|string $schema * @return TableObject */ - public function getTable($tableName, $schema = null) : TableObject; + public function getTable(string $tableName, ?string $schema = null) : TableObject; /** * Get view names @@ -58,7 +58,7 @@ public function getTable($tableName, $schema = null) : TableObject; * @param null|string $schema * @return string[] */ - public function getViewNames($schema = null) : array; + public function getViewNames(?string $schema = null) : array; /** * Get views @@ -66,7 +66,7 @@ public function getViewNames($schema = null) : array; * @param null|string $schema * @return ViewObject[] */ - public function getViews($schema = null) : array; + public function getViews(?string $schema = null) : array; /** * Get view @@ -75,7 +75,7 @@ public function getViews($schema = null) : array; * @param null|string $schema * @return ViewObject */ - public function getView($viewName, $schema = null) : ViewObject; + public function getView(string $viewName, ?string $schema = null) : ViewObject; /** * Get column names @@ -84,7 +84,7 @@ public function getView($viewName, $schema = null) : ViewObject; * @param null|string $schema * @return string[] */ - public function getColumnNames($table, $schema = null) : array; + public function getColumnNames(string $table, ?string $schema = null) : array; /** * Get columns @@ -93,7 +93,7 @@ public function getColumnNames($table, $schema = null) : array; * @param null|string $schema * @return ColumnObject[] */ - public function getColumns($table, $schema = null) : array; + public function getColumns(string $table, ?string $schema = null) : array; /** * Get column @@ -103,7 +103,7 @@ public function getColumns($table, $schema = null) : array; * @param null|string $schema * @return ColumnObject */ - public function getColumn($columnName, $table, $schema = null) : ColumnObject; + public function getColumn(string $columnName, string $table, ?string $schema = null) : ColumnObject; /** * Get constraints @@ -112,7 +112,7 @@ public function getColumn($columnName, $table, $schema = null) : ColumnObject; * @param null|string $schema * @return ConstraintObject[] */ - public function getConstraints($table, $schema = null) : array; + public function getConstraints(string $table, ?string $schema = null) : array; /** * Get constraint @@ -122,7 +122,7 @@ public function getConstraints($table, $schema = null) : array; * @param null|string $schema * @return ConstraintObject */ - public function getConstraint($constraintName, $table, $schema = null) : ConstraintObject; + public function getConstraint(string $constraintName, string $table, ?string $schema = null) : ConstraintObject; /** * Get constraint keys @@ -132,7 +132,7 @@ public function getConstraint($constraintName, $table, $schema = null) : Constra * @param null|string $schema * @return ConstraintKeyObject[] */ - public function getConstraintKeys($constraint, $table, $schema = null) : array; + public function getConstraintKeys(string $constraint, string $table, ?string $schema = null) : array; /** * Get trigger names @@ -140,7 +140,7 @@ public function getConstraintKeys($constraint, $table, $schema = null) : array; * @param null|string $schema * @return string[] */ - public function getTriggerNames($schema = null) : array; + public function getTriggerNames(?string $schema = null) : array; /** * Get triggers @@ -148,7 +148,7 @@ public function getTriggerNames($schema = null) : array; * @param null|string $schema * @return TriggerObject[] */ - public function getTriggers($schema = null) : array; + public function getTriggers(?string $schema = null) : array; /** * Get trigger @@ -157,5 +157,5 @@ public function getTriggers($schema = null) : array; * @param null|string $schema * @return TriggerObject */ - public function getTrigger($triggerName, $schema = null) : TriggerObject; + public function getTrigger(string $triggerName, ?string $schema = null) : TriggerObject; } diff --git a/src/Metadata/Object/AbstractTableObject.php b/src/Metadata/Object/AbstractTableObject.php index 4929378483..8c73e46413 100644 --- a/src/Metadata/Object/AbstractTableObject.php +++ b/src/Metadata/Object/AbstractTableObject.php @@ -15,36 +15,34 @@ abstract class AbstractTableObject * * @var string */ - protected $name = null; + protected $name = ''; /** * * @var string */ - protected $type = null; + protected $type = ''; /** * * @var array */ - protected $columns = null; + protected $columns = []; /** * * @var array */ - protected $constraints = null; + protected $constraints = []; /** * Constructor * * @param string $name */ - public function __construct($name) + public function __construct(string $name = '') { - if ($name) { - $this->setName($name); - } + $this->setName($name); } /** @@ -52,7 +50,7 @@ public function __construct($name) * * @param array $columns */ - public function setColumns(array $columns) + public function setColumns(array $columns) : void { $this->columns = $columns; } @@ -62,7 +60,7 @@ public function setColumns(array $columns) * * @return array */ - public function getColumns() + public function getColumns() : array { return $this->columns; } @@ -72,7 +70,7 @@ public function getColumns() * * @param array $constraints */ - public function setConstraints($constraints) + public function setConstraints(array $constraints) : void { $this->constraints = $constraints; } @@ -82,7 +80,7 @@ public function setConstraints($constraints) * * @return array */ - public function getConstraints() + public function getConstraints() : array { return $this->constraints; } @@ -92,7 +90,7 @@ public function getConstraints() * * @param string $name */ - public function setName($name) + public function setName(string $name) : void { $this->name = $name; } @@ -102,7 +100,7 @@ public function setName($name) * * @return string */ - public function getName() + public function getName() : string { return $this->name; } diff --git a/src/Metadata/Object/ColumnObject.php b/src/Metadata/Object/ColumnObject.php index 98ef5acffb..89f6c5e3b4 100644 --- a/src/Metadata/Object/ColumnObject.php +++ b/src/Metadata/Object/ColumnObject.php @@ -15,73 +15,73 @@ class ColumnObject * * @var string */ - protected $name = null; + protected $name = ''; /** * * @var string */ - protected $tableName = null; + protected $tableName = ''; /** * * @var string */ - protected $schemaName = null; + protected $schemaName = ''; /** * - * @var + * @var int|null */ - protected $ordinalPosition = null; + protected $ordinalPosition; /** * * @var string */ - protected $columnDefault = null; + protected $columnDefault = ''; /** * * @var bool */ - protected $isNullable = null; + protected $isNullable = false; /** * * @var string */ - protected $dataType = null; + protected $dataType = ''; /** * - * @var int + * @var int|null */ - protected $characterMaximumLength = null; + protected $characterMaximumLength; /** * - * @var int + * @var int|null */ - protected $characterOctetLength = null; + protected $characterOctetLength; /** * - * @var int + * @var int|null */ - protected $numericPrecision = null; + protected $numericPrecision; /** * - * @var int + * @var int|null */ - protected $numericScale = null; + protected $numericScale; /** * * @var bool */ - protected $numericUnsigned = null; + protected $numericUnsigned = false; /** * @@ -96,7 +96,7 @@ class ColumnObject * @param string $tableName * @param string $schemaName */ - public function __construct($name, $tableName, $schemaName = null) + public function __construct(string $name, string $tableName, string $schemaName = '') { $this->setName($name); $this->setTableName($tableName); @@ -108,7 +108,7 @@ public function __construct($name, $tableName, $schemaName = null) * * @param string $name */ - public function setName($name) + public function setName(string $name) : void { $this->name = $name; } @@ -118,7 +118,7 @@ public function setName($name) * * @return string */ - public function getName() + public function getName() : string { return $this->name; } @@ -128,7 +128,7 @@ public function getName() * * @return string */ - public function getTableName() + public function getTableName() : string { return $this->tableName; } @@ -139,7 +139,7 @@ public function getTableName() * @param string $tableName * @return self Provides a fluent interface */ - public function setTableName($tableName) + public function setTableName(string $tableName) : self { $this->tableName = $tableName; return $this; @@ -150,7 +150,7 @@ public function setTableName($tableName) * * @param string $schemaName */ - public function setSchemaName($schemaName) + public function setSchemaName(string $schemaName) : void { $this->schemaName = $schemaName; } @@ -160,7 +160,7 @@ public function setSchemaName($schemaName) * * @return string */ - public function getSchemaName() + public function getSchemaName() : string { return $this->schemaName; } @@ -168,7 +168,7 @@ public function getSchemaName() /** * @return int $ordinalPosition */ - public function getOrdinalPosition() + public function getOrdinalPosition() : ?int { return $this->ordinalPosition; } @@ -177,7 +177,7 @@ public function getOrdinalPosition() * @param int $ordinalPosition to set * @return self Provides a fluent interface */ - public function setOrdinalPosition($ordinalPosition) + public function setOrdinalPosition(?int $ordinalPosition) : self { $this->ordinalPosition = $ordinalPosition; return $this; @@ -186,16 +186,16 @@ public function setOrdinalPosition($ordinalPosition) /** * @return null|string the $columnDefault */ - public function getColumnDefault() + public function getColumnDefault() : ?string { return $this->columnDefault; } /** - * @param mixed $columnDefault to set + * @param string $columnDefault to set * @return self Provides a fluent interface */ - public function setColumnDefault($columnDefault) + public function setColumnDefault(string $columnDefault) : self { $this->columnDefault = $columnDefault; return $this; @@ -204,7 +204,7 @@ public function setColumnDefault($columnDefault) /** * @return bool $isNullable */ - public function getIsNullable() + public function getIsNullable() : bool { return $this->isNullable; } @@ -213,7 +213,7 @@ public function getIsNullable() * @param bool $isNullable to set * @return self Provides a fluent interface */ - public function setIsNullable($isNullable) + public function setIsNullable(bool $isNullable) : self { $this->isNullable = $isNullable; return $this; @@ -222,7 +222,7 @@ public function setIsNullable($isNullable) /** * @return bool $isNullable */ - public function isNullable() + public function isNullable() : bool { return $this->isNullable; } @@ -230,7 +230,7 @@ public function isNullable() /** * @return null|string the $dataType */ - public function getDataType() + public function getDataType() : ?string { return $this->dataType; } @@ -239,7 +239,7 @@ public function getDataType() * @param string $dataType the $dataType to set * @return self Provides a fluent interface */ - public function setDataType($dataType) + public function setDataType(string $dataType) : self { $this->dataType = $dataType; return $this; @@ -248,16 +248,16 @@ public function setDataType($dataType) /** * @return int|null the $characterMaximumLength */ - public function getCharacterMaximumLength() + public function getCharacterMaximumLength() : ?int { return $this->characterMaximumLength; } /** - * @param int $characterMaximumLength the $characterMaximumLength to set + * @param int|null $characterMaximumLength the $characterMaximumLength to set * @return self Provides a fluent interface */ - public function setCharacterMaximumLength($characterMaximumLength) + public function setCharacterMaximumLength(?int $characterMaximumLength) : self { $this->characterMaximumLength = $characterMaximumLength; return $this; @@ -266,16 +266,16 @@ public function setCharacterMaximumLength($characterMaximumLength) /** * @return int|null the $characterOctetLength */ - public function getCharacterOctetLength() + public function getCharacterOctetLength() : ?int { return $this->characterOctetLength; } /** - * @param int $characterOctetLength the $characterOctetLength to set + * @param int|null $characterOctetLength the $characterOctetLength to set * @return self Provides a fluent interface */ - public function setCharacterOctetLength($characterOctetLength) + public function setCharacterOctetLength(?int $characterOctetLength) : self { $this->characterOctetLength = $characterOctetLength; return $this; @@ -284,16 +284,16 @@ public function setCharacterOctetLength($characterOctetLength) /** * @return int the $numericPrecision */ - public function getNumericPrecision() + public function getNumericPrecision() : ?int { return $this->numericPrecision; } /** - * @param int $numericPrecision the $numericPrevision to set + * @param int|null $numericPrecision the $numericPrevision to set * @return self Provides a fluent interface */ - public function setNumericPrecision($numericPrecision) + public function setNumericPrecision(?int $numericPrecision) : self { $this->numericPrecision = $numericPrecision; return $this; @@ -302,7 +302,7 @@ public function setNumericPrecision($numericPrecision) /** * @return int the $numericScale */ - public function getNumericScale() + public function getNumericScale() : ?int { return $this->numericScale; } @@ -311,7 +311,7 @@ public function getNumericScale() * @param int $numericScale the $numericScale to set * @return self Provides a fluent interface */ - public function setNumericScale($numericScale) + public function setNumericScale(?int $numericScale) : self { $this->numericScale = $numericScale; return $this; @@ -320,7 +320,7 @@ public function setNumericScale($numericScale) /** * @return bool */ - public function getNumericUnsigned() + public function getNumericUnsigned() : bool { return $this->numericUnsigned; } @@ -329,7 +329,7 @@ public function getNumericUnsigned() * @param bool $numericUnsigned * @return self Provides a fluent interface */ - public function setNumericUnsigned($numericUnsigned) + public function setNumericUnsigned(bool $numericUnsigned) : self { $this->numericUnsigned = $numericUnsigned; return $this; @@ -338,7 +338,7 @@ public function setNumericUnsigned($numericUnsigned) /** * @return bool */ - public function isNumericUnsigned() + public function isNumericUnsigned() : bool { return $this->numericUnsigned; } @@ -346,7 +346,7 @@ public function isNumericUnsigned() /** * @return array the $errata */ - public function getErratas() + public function getErratas() : array { return $this->errata; } @@ -355,7 +355,7 @@ public function getErratas() * @param array $erratas * @return self Provides a fluent interface */ - public function setErratas(array $erratas) + public function setErratas(array $erratas) : self { foreach ($erratas as $name => $value) { $this->setErrata($name, $value); @@ -367,12 +367,11 @@ public function setErratas(array $erratas) * @param string $errataName * @return mixed */ - public function getErrata($errataName) + public function getErrata(string $errataName) { if (array_key_exists($errataName, $this->errata)) { return $this->errata[$errataName]; } - return; } /** @@ -380,7 +379,7 @@ public function getErrata($errataName) * @param mixed $errataValue * @return self Provides a fluent interface */ - public function setErrata($errataName, $errataValue) + public function setErrata(string $errataName, $errataValue) : self { $this->errata[$errataName] = $errataValue; return $this; diff --git a/src/Metadata/Object/ConstraintKeyObject.php b/src/Metadata/Object/ConstraintKeyObject.php index 1d43280243..49d6e746f5 100644 --- a/src/Metadata/Object/ConstraintKeyObject.php +++ b/src/Metadata/Object/ConstraintKeyObject.php @@ -21,56 +21,56 @@ class ConstraintKeyObject * * @var string */ - protected $columnName = null; + protected $columnName = ''; /** * - * @var int + * @var int|null */ - protected $ordinalPosition = null; + protected $ordinalPosition; /** * * @var bool */ - protected $positionInUniqueConstraint = null; + protected $positionInUniqueConstraint = false; /** * * @var string */ - protected $referencedTableSchema = null; + protected $referencedTableSchema = ''; /** * * @var string */ - protected $referencedTableName = null; + protected $referencedTableName = ''; /** * * @var string */ - protected $referencedColumnName = null; + protected $referencedColumnName = ''; /** * * @var string */ - protected $foreignKeyUpdateRule = null; + protected $foreignKeyUpdateRule = ''; /** * * @var string */ - protected $foreignKeyDeleteRule = null; + protected $foreignKeyDeleteRule = ''; /** * Constructor * * @param string $column */ - public function __construct($column) + public function __construct(string $column) { $this->setColumnName($column); } @@ -80,7 +80,7 @@ public function __construct($column) * * @return string */ - public function getColumnName() + public function getColumnName() : string { return $this->columnName; } @@ -91,7 +91,7 @@ public function getColumnName() * @param string $columnName * @return self Provides a fluent interface */ - public function setColumnName($columnName) + public function setColumnName(string $columnName) : self { $this->columnName = $columnName; return $this; @@ -100,9 +100,9 @@ public function setColumnName($columnName) /** * Get ordinal position * - * @return int + * @return int|null */ - public function getOrdinalPosition() + public function getOrdinalPosition() : ?int { return $this->ordinalPosition; } @@ -113,7 +113,7 @@ public function getOrdinalPosition() * @param int $ordinalPosition * @return self Provides a fluent interface */ - public function setOrdinalPosition($ordinalPosition) + public function setOrdinalPosition($ordinalPosition) : self { $this->ordinalPosition = $ordinalPosition; return $this; @@ -124,7 +124,7 @@ public function setOrdinalPosition($ordinalPosition) * * @return bool */ - public function getPositionInUniqueConstraint() + public function getPositionInUniqueConstraint() : bool { return $this->positionInUniqueConstraint; } @@ -135,18 +135,18 @@ public function getPositionInUniqueConstraint() * @param bool $positionInUniqueConstraint * @return self Provides a fluent interface */ - public function setPositionInUniqueConstraint($positionInUniqueConstraint) + public function setPositionInUniqueConstraint(bool $positionInUniqueConstraint) : self { $this->positionInUniqueConstraint = $positionInUniqueConstraint; return $this; } /** - * Get referencred table schema + * Get referenced table schema * * @return string */ - public function getReferencedTableSchema() + public function getReferencedTableSchema() : string { return $this->referencedTableSchema; } @@ -157,7 +157,7 @@ public function getReferencedTableSchema() * @param string $referencedTableSchema * @return self Provides a fluent interface */ - public function setReferencedTableSchema($referencedTableSchema) + public function setReferencedTableSchema($referencedTableSchema) : self { $this->referencedTableSchema = $referencedTableSchema; return $this; @@ -168,7 +168,7 @@ public function setReferencedTableSchema($referencedTableSchema) * * @return string */ - public function getReferencedTableName() + public function getReferencedTableName() : string { return $this->referencedTableName; } @@ -179,7 +179,7 @@ public function getReferencedTableName() * @param string $referencedTableName * @return self Provides a fluent interface */ - public function setReferencedTableName($referencedTableName) + public function setReferencedTableName(string $referencedTableName) : self { $this->referencedTableName = $referencedTableName; return $this; @@ -190,7 +190,7 @@ public function setReferencedTableName($referencedTableName) * * @return string */ - public function getReferencedColumnName() + public function getReferencedColumnName() : string { return $this->referencedColumnName; } @@ -201,7 +201,7 @@ public function getReferencedColumnName() * @param string $referencedColumnName * @return self Provides a fluent interface */ - public function setReferencedColumnName($referencedColumnName) + public function setReferencedColumnName(string $referencedColumnName) : self { $this->referencedColumnName = $referencedColumnName; return $this; @@ -212,7 +212,7 @@ public function setReferencedColumnName($referencedColumnName) * * @param string $foreignKeyUpdateRule */ - public function setForeignKeyUpdateRule($foreignKeyUpdateRule) + public function setForeignKeyUpdateRule($foreignKeyUpdateRule) : void { $this->foreignKeyUpdateRule = $foreignKeyUpdateRule; } @@ -222,7 +222,7 @@ public function setForeignKeyUpdateRule($foreignKeyUpdateRule) * * @return string */ - public function getForeignKeyUpdateRule() + public function getForeignKeyUpdateRule() : string { return $this->foreignKeyUpdateRule; } @@ -232,7 +232,7 @@ public function getForeignKeyUpdateRule() * * @param string $foreignKeyDeleteRule */ - public function setForeignKeyDeleteRule($foreignKeyDeleteRule) + public function setForeignKeyDeleteRule($foreignKeyDeleteRule) : void { $this->foreignKeyDeleteRule = $foreignKeyDeleteRule; } @@ -242,7 +242,7 @@ public function setForeignKeyDeleteRule($foreignKeyDeleteRule) * * @return string */ - public function getForeignKeyDeleteRule() + public function getForeignKeyDeleteRule() : string { return $this->foreignKeyDeleteRule; } diff --git a/src/Metadata/Object/ConstraintObject.php b/src/Metadata/Object/ConstraintObject.php index e71acf36cd..7336268ce9 100644 --- a/src/Metadata/Object/ConstraintObject.php +++ b/src/Metadata/Object/ConstraintObject.php @@ -15,26 +15,26 @@ class ConstraintObject * * @var string */ - protected $name = null; + protected $name = ''; /** * * @var string */ - protected $tableName = null; + protected $tableName = ''; /** * * @var string */ - protected $schemaName = null; + protected $schemaName = ''; /** * One of "PRIMARY KEY", "UNIQUE", "FOREIGN KEY", or "CHECK" * * @var string */ - protected $type = null; + protected $type = ''; /** * @@ -48,49 +48,49 @@ class ConstraintObject * * @var string */ - protected $referencedTableSchema; + protected $referencedTableSchema = ''; /** * * * @var string */ - protected $referencedTableName; + protected $referencedTableName = ''; /** * * * @var string[] */ - protected $referencedColumns; + protected $referencedColumns = []; /** * * * @var string */ - protected $matchOption; + protected $matchOption = ''; /** * * * @var string */ - protected $updateRule; + protected $updateRule = ''; /** * * * @var string */ - protected $deleteRule; + protected $deleteRule = ''; /** * * * @var string */ - protected $checkClause; + protected $checkClause = ''; /** * Constructor @@ -99,7 +99,7 @@ class ConstraintObject * @param string $tableName * @param string $schemaName */ - public function __construct($name, $tableName, $schemaName = null) + public function __construct(string $name, string $tableName, string $schemaName = '') { $this->setName($name); $this->setTableName($tableName); @@ -111,7 +111,7 @@ public function __construct($name, $tableName, $schemaName = null) * * @param string $name */ - public function setName($name) + public function setName(string $name) : void { $this->name = $name; } @@ -121,7 +121,7 @@ public function setName($name) * * @return string */ - public function getName() + public function getName() : string { return $this->name; } @@ -131,7 +131,7 @@ public function getName() * * @param string $schemaName */ - public function setSchemaName($schemaName) + public function setSchemaName($schemaName) : void { $this->schemaName = $schemaName; } @@ -141,7 +141,7 @@ public function setSchemaName($schemaName) * * @return string */ - public function getSchemaName() + public function getSchemaName() : string { return $this->schemaName; } @@ -151,7 +151,7 @@ public function getSchemaName() * * @return string */ - public function getTableName() + public function getTableName() : string { return $this->tableName; } @@ -162,7 +162,7 @@ public function getTableName() * @param string $tableName * @return self Provides a fluent interface */ - public function setTableName($tableName) + public function setTableName($tableName) : self { $this->tableName = $tableName; return $this; @@ -173,7 +173,7 @@ public function setTableName($tableName) * * @param string $type */ - public function setType($type) + public function setType($type) : void { $this->type = $type; } @@ -183,12 +183,12 @@ public function setType($type) * * @return string */ - public function getType() + public function getType() : string { return $this->type; } - public function hasColumns() + public function hasColumns() : bool { return (! empty($this->columns)); } @@ -198,7 +198,7 @@ public function hasColumns() * * @return string[] */ - public function getColumns() + public function getColumns() : array { return $this->columns; } @@ -209,7 +209,7 @@ public function getColumns() * @param string[] $columns * @return self Provides a fluent interface */ - public function setColumns(array $columns) + public function setColumns(array $columns) : self { $this->columns = $columns; return $this; @@ -220,7 +220,7 @@ public function setColumns(array $columns) * * @return string */ - public function getReferencedTableSchema() + public function getReferencedTableSchema() : string { return $this->referencedTableSchema; } @@ -231,7 +231,7 @@ public function getReferencedTableSchema() * @param string $referencedTableSchema * @return self Provides a fluent interface */ - public function setReferencedTableSchema($referencedTableSchema) + public function setReferencedTableSchema($referencedTableSchema) : self { $this->referencedTableSchema = $referencedTableSchema; return $this; @@ -242,7 +242,7 @@ public function setReferencedTableSchema($referencedTableSchema) * * @return string */ - public function getReferencedTableName() + public function getReferencedTableName() : string { return $this->referencedTableName; } @@ -253,7 +253,7 @@ public function getReferencedTableName() * @param string $referencedTableName * @return self Provides a fluent interface */ - public function setReferencedTableName($referencedTableName) + public function setReferencedTableName($referencedTableName) : self { $this->referencedTableName = $referencedTableName; return $this; @@ -264,7 +264,7 @@ public function setReferencedTableName($referencedTableName) * * @return string[] */ - public function getReferencedColumns() + public function getReferencedColumns() : array { return $this->referencedColumns; } @@ -275,7 +275,7 @@ public function getReferencedColumns() * @param string[] $referencedColumns * @return self Provides a fluent interface */ - public function setReferencedColumns(array $referencedColumns) + public function setReferencedColumns(array $referencedColumns) : self { $this->referencedColumns = $referencedColumns; return $this; @@ -286,7 +286,7 @@ public function setReferencedColumns(array $referencedColumns) * * @return string */ - public function getMatchOption() + public function getMatchOption() : string { return $this->matchOption; } @@ -297,7 +297,7 @@ public function getMatchOption() * @param string $matchOption * @return self Provides a fluent interface */ - public function setMatchOption($matchOption) + public function setMatchOption($matchOption) : self { $this->matchOption = $matchOption; return $this; @@ -308,7 +308,7 @@ public function setMatchOption($matchOption) * * @return string */ - public function getUpdateRule() + public function getUpdateRule() : string { return $this->updateRule; } @@ -319,7 +319,7 @@ public function getUpdateRule() * @param string $updateRule * @return self Provides a fluent interface */ - public function setUpdateRule($updateRule) + public function setUpdateRule($updateRule) : self { $this->updateRule = $updateRule; return $this; @@ -330,7 +330,7 @@ public function setUpdateRule($updateRule) * * @return string */ - public function getDeleteRule() + public function getDeleteRule() : string { return $this->deleteRule; } @@ -341,7 +341,7 @@ public function getDeleteRule() * @param string $deleteRule * @return self Provides a fluent interface */ - public function setDeleteRule($deleteRule) + public function setDeleteRule($deleteRule) : self { $this->deleteRule = $deleteRule; return $this; @@ -352,7 +352,7 @@ public function setDeleteRule($deleteRule) * * @return string */ - public function getCheckClause() + public function getCheckClause() : string { return $this->checkClause; } @@ -363,7 +363,7 @@ public function getCheckClause() * @param string $checkClause * @return self Provides a fluent interface */ - public function setCheckClause($checkClause) + public function setCheckClause($checkClause) : self { $this->checkClause = $checkClause; return $this; @@ -374,7 +374,7 @@ public function setCheckClause($checkClause) * * @return bool */ - public function isPrimaryKey() + public function isPrimaryKey() : bool { return ('PRIMARY KEY' == $this->type); } @@ -384,7 +384,7 @@ public function isPrimaryKey() * * @return bool */ - public function isUnique() + public function isUnique() : bool { return ('UNIQUE' == $this->type); } @@ -394,7 +394,7 @@ public function isUnique() * * @return bool */ - public function isForeignKey() + public function isForeignKey() : bool { return ('FOREIGN KEY' == $this->type); } @@ -404,7 +404,7 @@ public function isForeignKey() * * @return bool */ - public function isCheck() + public function isCheck() : bool { return ('CHECK' == $this->type); } diff --git a/src/Metadata/Object/TriggerObject.php b/src/Metadata/Object/TriggerObject.php index ba92e45b7a..8353df85d6 100644 --- a/src/Metadata/Object/TriggerObject.php +++ b/src/Metadata/Object/TriggerObject.php @@ -9,6 +9,8 @@ namespace Zend\Db\Metadata\Object; +use DateTime; + class TriggerObject { /** @@ -16,103 +18,103 @@ class TriggerObject * * @var string */ - protected $name; + protected $name = ''; /** * * * @var string */ - protected $eventManipulation; + protected $eventManipulation = ''; /** * * * @var string */ - protected $eventObjectCatalog; + protected $eventObjectCatalog = ''; /** * * * @var string */ - protected $eventObjectSchema; + protected $eventObjectSchema = ''; /** * * * @var string */ - protected $eventObjectTable; + protected $eventObjectTable = ''; /** * * * @var string */ - protected $actionOrder; + protected $actionOrder = ''; /** * * * @var string */ - protected $actionCondition; + protected $actionCondition = ''; /** * * * @var string */ - protected $actionStatement; + protected $actionStatement = ''; /** * * * @var string */ - protected $actionOrientation; + protected $actionOrientation = ''; /** * * * @var string */ - protected $actionTiming; + protected $actionTiming = ''; /** * * * @var string */ - protected $actionReferenceOldTable; + protected $actionReferenceOldTable = ''; /** * * * @var string */ - protected $actionReferenceNewTable; + protected $actionReferenceNewTable = ''; /** * * * @var string */ - protected $actionReferenceOldRow; + protected $actionReferenceOldRow = ''; /** * * * @var string */ - protected $actionReferenceNewRow; + protected $actionReferenceNewRow = ''; /** * * - * @var \DateTime + * @var DateTime|null */ protected $created; @@ -121,7 +123,7 @@ class TriggerObject * * @return string */ - public function getName() + public function getName() : string { return $this->name; } @@ -132,7 +134,7 @@ public function getName() * @param string $name * @return self Provides a fluent interface */ - public function setName($name) + public function setName(string $name) : self { $this->name = $name; return $this; @@ -143,7 +145,7 @@ public function setName($name) * * @return string */ - public function getEventManipulation() + public function getEventManipulation() : string { return $this->eventManipulation; } @@ -154,7 +156,7 @@ public function getEventManipulation() * @param string $eventManipulation * @return self Provides a fluent interface */ - public function setEventManipulation($eventManipulation) + public function setEventManipulation(string $eventManipulation) : self { $this->eventManipulation = $eventManipulation; return $this; @@ -165,7 +167,7 @@ public function setEventManipulation($eventManipulation) * * @return string */ - public function getEventObjectCatalog() + public function getEventObjectCatalog() : string { return $this->eventObjectCatalog; } @@ -176,7 +178,7 @@ public function getEventObjectCatalog() * @param string $eventObjectCatalog * @return self Provides a fluent interface */ - public function setEventObjectCatalog($eventObjectCatalog) + public function setEventObjectCatalog(string $eventObjectCatalog) : self { $this->eventObjectCatalog = $eventObjectCatalog; return $this; @@ -187,7 +189,7 @@ public function setEventObjectCatalog($eventObjectCatalog) * * @return string */ - public function getEventObjectSchema() + public function getEventObjectSchema() : string { return $this->eventObjectSchema; } @@ -198,7 +200,7 @@ public function getEventObjectSchema() * @param string $eventObjectSchema * @return self Provides a fluent interface */ - public function setEventObjectSchema($eventObjectSchema) + public function setEventObjectSchema(string $eventObjectSchema) : self { $this->eventObjectSchema = $eventObjectSchema; return $this; @@ -209,7 +211,7 @@ public function setEventObjectSchema($eventObjectSchema) * * @return string */ - public function getEventObjectTable() + public function getEventObjectTable() : string { return $this->eventObjectTable; } @@ -220,7 +222,7 @@ public function getEventObjectTable() * @param string $eventObjectTable * @return self Provides a fluent interface */ - public function setEventObjectTable($eventObjectTable) + public function setEventObjectTable(string $eventObjectTable) : self { $this->eventObjectTable = $eventObjectTable; return $this; @@ -231,7 +233,7 @@ public function setEventObjectTable($eventObjectTable) * * @return string */ - public function getActionOrder() + public function getActionOrder() : string { return $this->actionOrder; } @@ -242,7 +244,7 @@ public function getActionOrder() * @param string $actionOrder * @return self Provides a fluent interface */ - public function setActionOrder($actionOrder) + public function setActionOrder(string $actionOrder) : self { $this->actionOrder = $actionOrder; return $this; @@ -253,7 +255,7 @@ public function setActionOrder($actionOrder) * * @return string */ - public function getActionCondition() + public function getActionCondition() : string { return $this->actionCondition; } @@ -264,7 +266,7 @@ public function getActionCondition() * @param string $actionCondition * @return self Provides a fluent interface */ - public function setActionCondition($actionCondition) + public function setActionCondition(string $actionCondition) : self { $this->actionCondition = $actionCondition; return $this; @@ -275,7 +277,7 @@ public function setActionCondition($actionCondition) * * @return string */ - public function getActionStatement() + public function getActionStatement() : string { return $this->actionStatement; } @@ -286,7 +288,7 @@ public function getActionStatement() * @param string $actionStatement * @return self Provides a fluent interface */ - public function setActionStatement($actionStatement) + public function setActionStatement(string $actionStatement) : self { $this->actionStatement = $actionStatement; return $this; @@ -297,7 +299,7 @@ public function setActionStatement($actionStatement) * * @return string */ - public function getActionOrientation() + public function getActionOrientation() : string { return $this->actionOrientation; } @@ -308,7 +310,7 @@ public function getActionOrientation() * @param string $actionOrientation * @return self Provides a fluent interface */ - public function setActionOrientation($actionOrientation) + public function setActionOrientation(string $actionOrientation) : self { $this->actionOrientation = $actionOrientation; return $this; @@ -319,7 +321,7 @@ public function setActionOrientation($actionOrientation) * * @return string */ - public function getActionTiming() + public function getActionTiming() : string { return $this->actionTiming; } @@ -330,7 +332,7 @@ public function getActionTiming() * @param string $actionTiming * @return self Provides a fluent interface */ - public function setActionTiming($actionTiming) + public function setActionTiming(string $actionTiming) : self { $this->actionTiming = $actionTiming; return $this; @@ -341,7 +343,7 @@ public function setActionTiming($actionTiming) * * @return string */ - public function getActionReferenceOldTable() + public function getActionReferenceOldTable() : string { return $this->actionReferenceOldTable; } @@ -352,7 +354,7 @@ public function getActionReferenceOldTable() * @param string $actionReferenceOldTable * @return self Provides a fluent interface */ - public function setActionReferenceOldTable($actionReferenceOldTable) + public function setActionReferenceOldTable(string $actionReferenceOldTable) : self { $this->actionReferenceOldTable = $actionReferenceOldTable; return $this; @@ -363,7 +365,7 @@ public function setActionReferenceOldTable($actionReferenceOldTable) * * @return string */ - public function getActionReferenceNewTable() + public function getActionReferenceNewTable() : string { return $this->actionReferenceNewTable; } @@ -374,7 +376,7 @@ public function getActionReferenceNewTable() * @param string $actionReferenceNewTable * @return self Provides a fluent interface */ - public function setActionReferenceNewTable($actionReferenceNewTable) + public function setActionReferenceNewTable(string $actionReferenceNewTable) : self { $this->actionReferenceNewTable = $actionReferenceNewTable; return $this; @@ -385,7 +387,7 @@ public function setActionReferenceNewTable($actionReferenceNewTable) * * @return string */ - public function getActionReferenceOldRow() + public function getActionReferenceOldRow() : string { return $this->actionReferenceOldRow; } @@ -396,7 +398,7 @@ public function getActionReferenceOldRow() * @param string $actionReferenceOldRow * @return self Provides a fluent interface */ - public function setActionReferenceOldRow($actionReferenceOldRow) + public function setActionReferenceOldRow(string $actionReferenceOldRow) : self { $this->actionReferenceOldRow = $actionReferenceOldRow; return $this; @@ -407,7 +409,7 @@ public function setActionReferenceOldRow($actionReferenceOldRow) * * @return string */ - public function getActionReferenceNewRow() + public function getActionReferenceNewRow() : string { return $this->actionReferenceNewRow; } @@ -418,7 +420,7 @@ public function getActionReferenceNewRow() * @param string $actionReferenceNewRow * @return self Provides a fluent interface */ - public function setActionReferenceNewRow($actionReferenceNewRow) + public function setActionReferenceNewRow(string $actionReferenceNewRow) : self { $this->actionReferenceNewRow = $actionReferenceNewRow; return $this; @@ -427,9 +429,9 @@ public function setActionReferenceNewRow($actionReferenceNewRow) /** * Get Created. * - * @return \DateTime + * @return DateTime */ - public function getCreated() + public function getCreated(): ?DateTime { return $this->created; } @@ -437,10 +439,10 @@ public function getCreated() /** * Set Created. * - * @param \DateTime $created + * @param DateTime $created * @return self Provides a fluent interface */ - public function setCreated($created) + public function setCreated(?DateTime $created) : self { $this->created = $created; return $this; diff --git a/src/Metadata/Object/ViewObject.php b/src/Metadata/Object/ViewObject.php index e828f0f270..af51ad0a95 100644 --- a/src/Metadata/Object/ViewObject.php +++ b/src/Metadata/Object/ViewObject.php @@ -11,14 +11,14 @@ class ViewObject extends AbstractTableObject { - protected $viewDefinition; - protected $checkOption; - protected $isUpdatable; + protected $viewDefinition = ''; + protected $checkOption = ''; + protected $isUpdatable = false; /** * @return string $viewDefinition */ - public function getViewDefinition() + public function getViewDefinition() : string { return $this->viewDefinition; } @@ -27,7 +27,7 @@ public function getViewDefinition() * @param string $viewDefinition to set * @return self Provides a fluent interface */ - public function setViewDefinition($viewDefinition) + public function setViewDefinition(string $viewDefinition) : self { $this->viewDefinition = $viewDefinition; return $this; @@ -36,7 +36,7 @@ public function setViewDefinition($viewDefinition) /** * @return string $checkOption */ - public function getCheckOption() + public function getCheckOption() : string { return $this->checkOption; } @@ -45,7 +45,7 @@ public function getCheckOption() * @param string $checkOption to set * @return self Provides a fluent interface */ - public function setCheckOption($checkOption) + public function setCheckOption(string $checkOption) : self { $this->checkOption = $checkOption; return $this; @@ -54,7 +54,7 @@ public function setCheckOption($checkOption) /** * @return bool $isUpdatable */ - public function getIsUpdatable() + public function getIsUpdatable() : bool { return $this->isUpdatable; } @@ -63,13 +63,13 @@ public function getIsUpdatable() * @param bool $isUpdatable to set * @return self Provides a fluent interface */ - public function setIsUpdatable($isUpdatable) + public function setIsUpdatable(bool $isUpdatable) : self { $this->isUpdatable = $isUpdatable; return $this; } - public function isUpdatable() + public function isUpdatable() : bool { return $this->isUpdatable; } diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index 04136d2243..580480efac 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -26,13 +26,13 @@ abstract class AbstractSource implements MetadataInterface * * @var Adapter */ - protected $adapter = null; + protected $adapter; /** * * @var string */ - protected $defaultSchema = null; + protected $defaultSchema = ''; /** * @@ -52,8 +52,7 @@ public function __construct(Adapter $adapter) } /** - * Get schemas - * + * @inheritdoc */ public function getSchemas() : array { @@ -65,7 +64,7 @@ public function getSchemas() : array /** * {@inheritdoc} */ - public function getTableNames($schema = null, $includeViews = false) : array + public function getTableNames(?string $schema = null, bool $includeViews = false) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -89,7 +88,7 @@ public function getTableNames($schema = null, $includeViews = false) : array /** * {@inheritdoc} */ - public function getTables($schema = null, $includeViews = false) : array + public function getTables(?string $schema = null, bool $includeViews = false) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -105,7 +104,7 @@ public function getTables($schema = null, $includeViews = false) : array /** * {@inheritdoc} */ - public function getTable($tableName, $schema = null) : TableObject + public function getTable(string $tableName, ?string $schema = null) : TableObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -141,7 +140,7 @@ public function getTable($tableName, $schema = null) : TableObject /** * {@inheritdoc} */ - public function getViewNames($schema = null) : array + public function getViewNames(?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -161,7 +160,7 @@ public function getViewNames($schema = null) : array /** * {@inheritdoc} */ - public function getViews($schema = null) : array + public function getViews(?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -177,7 +176,7 @@ public function getViews($schema = null) : array /** * {@inheritdoc} */ - public function getView($viewName, $schema = null) : ViewObject + public function getView(string $viewName, ?string $schema = null) : ViewObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -195,7 +194,7 @@ public function getView($viewName, $schema = null) : ViewObject /** * {@inheritdoc} */ - public function getColumnNames($table, $schema = null) : array + public function getColumnNames(string $table, ?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -213,7 +212,7 @@ public function getColumnNames($table, $schema = null) : array /** * {@inheritdoc} */ - public function getColumns($table, $schema = null) : array + public function getColumns(string $table, ?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -231,7 +230,7 @@ public function getColumns($table, $schema = null) : array /** * {@inheritdoc} */ - public function getColumn($columnName, $table, $schema = null) : ColumnObject + public function getColumn(string $columnName, string $table, ?string $schema = null) : ColumnObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -275,7 +274,7 @@ public function getColumn($columnName, $table, $schema = null) : ColumnObject /** * {@inheritdoc} */ - public function getConstraints($table, $schema = null) : array + public function getConstraints(string $table, ?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -294,7 +293,7 @@ public function getConstraints($table, $schema = null) : array /** * {@inheritdoc} */ - public function getConstraint($constraintName, $table, $schema = null) : ConstraintObject + public function getConstraint(string $constraintName, string $table, ?string $schema = null) : ConstraintObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -331,7 +330,7 @@ public function getConstraint($constraintName, $table, $schema = null) : Constra /** * {@inheritdoc} */ - public function getConstraintKeys($constraint, $table, $schema = null) : array + public function getConstraintKeys(string $constraint, string $table, ?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -371,7 +370,7 @@ public function getConstraintKeys($constraint, $table, $schema = null) : array /** * {@inheritdoc} */ - public function getTriggerNames($schema = null) : array + public function getTriggerNames(?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -385,7 +384,7 @@ public function getTriggerNames($schema = null) : array /** * {@inheritdoc} */ - public function getTriggers($schema = null) : array + public function getTriggers(?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -401,7 +400,7 @@ public function getTriggers($schema = null) : array /** * {@inheritdoc} */ - public function getTrigger($triggerName, $schema = null) : TriggerObject + public function getTrigger(string $triggerName, ?string $schema = null) : TriggerObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -442,7 +441,7 @@ public function getTrigger($triggerName, $schema = null) : TriggerObject * @param string $type * @param string $key ... */ - protected function prepareDataHierarchy($type) : void + protected function prepareDataHierarchy(string $type) : void { $data = &$this->data; foreach (func_get_args() as $key) { @@ -465,7 +464,7 @@ protected function loadSchemaData() : void * * @param string $schema */ - protected function loadTableNameData($schema) : void + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -480,7 +479,7 @@ protected function loadTableNameData($schema) : void * @param string $table * @param string $schema */ - protected function loadColumnData($table, $schema) : void + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -495,7 +494,7 @@ protected function loadColumnData($table, $schema) : void * @param string $table * @param string $schema */ - protected function loadConstraintData($table, $schema) : void + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema])) { return; @@ -509,7 +508,7 @@ protected function loadConstraintData($table, $schema) : void * * @param string $schema */ - protected function loadConstraintDataKeys($schema) : void + protected function loadConstraintDataKeys(string $schema) : void { if (isset($this->data['constraint_keys'][$schema])) { return; @@ -524,7 +523,7 @@ protected function loadConstraintDataKeys($schema) : void * @param string $table * @param string $schema */ - protected function loadConstraintReferences($table, $schema) : void + protected function loadConstraintReferences(string $table, string $schema) : void { if (isset($this->data['constraint_references'][$schema])) { return; @@ -538,7 +537,7 @@ protected function loadConstraintReferences($table, $schema) : void * * @param string $schema */ - protected function loadTriggerData($schema) : void + protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { return; diff --git a/src/Metadata/Source/Factory.php b/src/Metadata/Source/Factory.php index babf270f70..3104255094 100644 --- a/src/Metadata/Source/Factory.php +++ b/src/Metadata/Source/Factory.php @@ -25,7 +25,7 @@ class Factory * @return MetadataInterface * @throws InvalidArgumentException If adapter platform name not recognized. */ - public static function createSourceFromAdapter(Adapter $adapter) + public static function createSourceFromAdapter(Adapter $adapter) : MetadataInterface { $platformName = $adapter->getPlatform()->getName(); diff --git a/src/Metadata/Source/MysqlMetadata.php b/src/Metadata/Source/MysqlMetadata.php index 6e44d7021d..fb1f6ea5e9 100644 --- a/src/Metadata/Source/MysqlMetadata.php +++ b/src/Metadata/Source/MysqlMetadata.php @@ -37,7 +37,7 @@ protected function loadSchemaData() : void $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) : void + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -93,7 +93,7 @@ protected function loadTableNameData($schema) : void $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) : void + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -175,7 +175,7 @@ protected function loadColumnData($table, $schema) : void $this->data['columns'][$schema][$table] = $columns; } - protected function loadConstraintData($table, $schema) : void + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -284,7 +284,7 @@ protected function loadConstraintData($table, $schema) : void $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadConstraintDataNames($schema) : void + protected function loadConstraintDataNames(string $schema) : void { if (isset($this->data['constraint_names'][$schema])) { return; @@ -332,7 +332,7 @@ protected function loadConstraintDataNames($schema) : void $this->data['constraint_names'][$schema] = $data; } - protected function loadConstraintDataKeys($schema) : void + protected function loadConstraintDataKeys(string $schema) : void { if (isset($this->data['constraint_keys'][$schema])) { return; @@ -383,7 +383,7 @@ protected function loadConstraintDataKeys($schema) : void $this->data['constraint_keys'][$schema] = $data; } - protected function loadConstraintReferences($table, $schema) : void + protected function loadConstraintReferences(string $table, string $schema) : void { parent::loadConstraintReferences($table, $schema); @@ -441,7 +441,7 @@ protected function loadConstraintReferences($table, $schema) : void $this->data['constraint_references'][$schema] = $data; } - protected function loadTriggerData($schema) : void + protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { return; diff --git a/src/Metadata/Source/OracleMetadata.php b/src/Metadata/Source/OracleMetadata.php index 3ba2871370..f9509d9948 100644 --- a/src/Metadata/Source/OracleMetadata.php +++ b/src/Metadata/Source/OracleMetadata.php @@ -29,7 +29,7 @@ class OracleMetadata extends AbstractSource * {@inheritdoc} * @see \Zend\Db\Metadata\Source\AbstractSource::loadColumnData() */ - protected function loadColumnData($table, $schema) : void + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -83,7 +83,7 @@ protected function loadColumnData($table, $schema) : void * @param string $type * @return string */ - protected function getConstraintType($type) : string + protected function getConstraintType(string $type) : string { if (isset($this->constraintTypeMap[$type])) { return $this->constraintTypeMap[$type]; @@ -96,7 +96,7 @@ protected function getConstraintType($type) : string * {@inheritdoc} * @see \Zend\Db\Metadata\Source\AbstractSource::loadConstraintData() */ - protected function loadConstraintData($table, $schema) : void + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -198,7 +198,7 @@ protected function loadSchemaData() : void * {@inheritdoc} * @see \Zend\Db\Metadata\Source\AbstractSource::loadTableNameData() */ - protected function loadTableNameData($schema) : void + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -241,7 +241,7 @@ protected function loadTableNameData($schema) : void * * @see \Zend\Db\Metadata\Source\AbstractSource::loadTriggerData() */ - protected function loadTriggerData($schema) : void + protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { return; diff --git a/src/Metadata/Source/PostgresqlMetadata.php b/src/Metadata/Source/PostgresqlMetadata.php index a10bf0dfad..7006f0d456 100644 --- a/src/Metadata/Source/PostgresqlMetadata.php +++ b/src/Metadata/Source/PostgresqlMetadata.php @@ -38,7 +38,7 @@ protected function loadSchemaData() : void $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) : void + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -94,7 +94,7 @@ protected function loadTableNameData($schema) : void $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) : void + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -154,7 +154,7 @@ protected function loadColumnData($table, $schema) : void $this->data['columns'][$schema][$table] = $columns; } - protected function loadConstraintData($table, $schema) : void + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -281,7 +281,7 @@ protected function loadConstraintData($table, $schema) : void $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadTriggerData($schema) : void + protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { return; diff --git a/src/Metadata/Source/SqlServerMetadata.php b/src/Metadata/Source/SqlServerMetadata.php index da8c8cf608..f95e2cafd5 100644 --- a/src/Metadata/Source/SqlServerMetadata.php +++ b/src/Metadata/Source/SqlServerMetadata.php @@ -37,7 +37,7 @@ protected function loadSchemaData() : void $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) : void + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -93,7 +93,7 @@ protected function loadTableNameData($schema) : void $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) : void + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -157,7 +157,7 @@ protected function loadColumnData($table, $schema) : void $this->data['columns'][$schema][$table] = $columns; } - protected function loadConstraintData($table, $schema) : void + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -285,7 +285,7 @@ protected function loadConstraintData($table, $schema) : void $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadTriggerData($schema) : void + protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { return; diff --git a/src/Metadata/Source/SqliteMetadata.php b/src/Metadata/Source/SqliteMetadata.php index 3c93606b28..407045318b 100644 --- a/src/Metadata/Source/SqliteMetadata.php +++ b/src/Metadata/Source/SqliteMetadata.php @@ -28,7 +28,7 @@ protected function loadSchemaData() : void $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) : void + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -70,7 +70,7 @@ protected function loadTableNameData($schema) : void $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) : void + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -103,7 +103,7 @@ protected function loadColumnData($table, $schema) : void $this->data['sqlite_columns'][$schema][$table] = $results; } - protected function loadConstraintData($table, $schema) : void + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -186,7 +186,7 @@ protected function loadConstraintData($table, $schema) : void $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadTriggerData($schema) : void + protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { return; @@ -231,7 +231,7 @@ protected function loadTriggerData($schema) : void $this->data['triggers'][$schema] = $triggers; } - protected function fetchPragma(string $name, string $value = null, string $schema = null) + protected function fetchPragma(string $name, ?string $value = null, ?string $schema = null) { $p = $this->adapter->getPlatform(); @@ -253,7 +253,7 @@ protected function fetchPragma(string $name, string $value = null, string $schem return []; } - protected function parseView($sql) + protected function parseView(string $sql) { static $re = null; if (null === $re) { @@ -278,7 +278,7 @@ protected function parseView($sql) ]; } - protected function parseTrigger($sql) : ?array + protected function parseTrigger(string $sql) : ?array { static $re = null; if (null === $re) { @@ -336,7 +336,7 @@ protected function parseTrigger($sql) : ?array return $data; } - protected function buildRegularExpression(array $re) + protected function buildRegularExpression(array $re) : ?string { foreach ($re as &$value) { if (is_array($value)) { @@ -350,7 +350,7 @@ protected function buildRegularExpression(array $re) return $re; } - protected function getIdentifierRegularExpression() + protected function getIdentifierRegularExpression() : ?string { static $re = null; if (null === $re) { @@ -365,7 +365,7 @@ protected function getIdentifierRegularExpression() return $re; } - protected function getIdentifierChainRegularExpression() + protected function getIdentifierChainRegularExpression() : ?string { static $re = null; if (null === $re) { @@ -375,7 +375,7 @@ protected function getIdentifierChainRegularExpression() return $re; } - protected function getIdentifierListRegularExpression() + protected function getIdentifierListRegularExpression() : ?string { static $re = null; if (null === $re) { From 83afa374214157d7533505139470187b145bb7ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 11:04:41 +0100 Subject: [PATCH 07/14] Removed PHPDoc for non-existing argument --- src/Metadata/Source/AbstractSource.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index 580480efac..39c1ae0afa 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -439,7 +439,6 @@ public function getTrigger(string $triggerName, ?string $schema = null) : Trigge * Prepare data hierarchy * * @param string $type - * @param string $key ... */ protected function prepareDataHierarchy(string $type) : void { From 36bd061a5ff650d03c592703d5513834caa4cc8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 11:05:21 +0100 Subject: [PATCH 08/14] Declared as static, since it seems to be quite 'heavy' --- src/Metadata/Source/OracleMetadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Metadata/Source/OracleMetadata.php b/src/Metadata/Source/OracleMetadata.php index f9509d9948..a1fb438546 100644 --- a/src/Metadata/Source/OracleMetadata.php +++ b/src/Metadata/Source/OracleMetadata.php @@ -19,7 +19,7 @@ class OracleMetadata extends AbstractSource /** * @var array */ - protected $constraintTypeMap = [ + protected static $constraintTypeMap = [ 'C' => 'CHECK', 'P' => 'PRIMARY KEY', 'R' => 'FOREIGN_KEY' From 817ccfcd0124fcb3b1955b622dd26cde7f669e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 11:06:29 +0100 Subject: [PATCH 09/14] Defined visibility for class constants --- src/Metadata/Object/ConstraintKeyObject.php | 10 +++++----- src/Metadata/Source/AbstractSource.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Metadata/Object/ConstraintKeyObject.php b/src/Metadata/Object/ConstraintKeyObject.php index 49d6e746f5..13a0a71247 100644 --- a/src/Metadata/Object/ConstraintKeyObject.php +++ b/src/Metadata/Object/ConstraintKeyObject.php @@ -11,11 +11,11 @@ class ConstraintKeyObject { - const FK_CASCADE = 'CASCADE'; - const FK_SET_NULL = 'SET NULL'; - const FK_NO_ACTION = 'NO ACTION'; - const FK_RESTRICT = 'RESTRICT'; - const FK_SET_DEFAULT = 'SET DEFAULT'; + public const FK_CASCADE = 'CASCADE'; + public const FK_SET_NULL = 'SET NULL'; + public const FK_NO_ACTION = 'NO ACTION'; + public const FK_RESTRICT = 'RESTRICT'; + public const FK_SET_DEFAULT = 'SET DEFAULT'; /** * diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index 39c1ae0afa..94b5e64b3a 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -20,7 +20,7 @@ abstract class AbstractSource implements MetadataInterface { - const DEFAULT_SCHEMA = '__DEFAULT_SCHEMA__'; + public const DEFAULT_SCHEMA = '__DEFAULT_SCHEMA__'; /** * From 308177815027f79a7ad501f53033e730c56a7fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 11:07:13 +0100 Subject: [PATCH 10/14] Removed unnecessary parentheses --- src/Metadata/Object/ConstraintObject.php | 2 +- src/Metadata/Source/AbstractSource.php | 2 +- src/Metadata/Source/MysqlMetadata.php | 6 +++--- src/Metadata/Source/OracleMetadata.php | 2 +- src/Metadata/Source/PostgresqlMetadata.php | 4 ++-- src/Metadata/Source/SqlServerMetadata.php | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Metadata/Object/ConstraintObject.php b/src/Metadata/Object/ConstraintObject.php index 7336268ce9..f9f0b40328 100644 --- a/src/Metadata/Object/ConstraintObject.php +++ b/src/Metadata/Object/ConstraintObject.php @@ -190,7 +190,7 @@ public function getType() : string public function hasColumns() : bool { - return (! empty($this->columns)); + return ! empty($this->columns); } /** diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index 94b5e64b3a..501aa489c0 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -48,7 +48,7 @@ abstract class AbstractSource implements MetadataInterface public function __construct(Adapter $adapter) { $this->adapter = $adapter; - $this->defaultSchema = ($adapter->getCurrentSchema()) ?: self::DEFAULT_SCHEMA; + $this->defaultSchema = $adapter->getCurrentSchema() ?: self::DEFAULT_SCHEMA; } /** diff --git a/src/Metadata/Source/MysqlMetadata.php b/src/Metadata/Source/MysqlMetadata.php index fb1f6ea5e9..a91ac1cb47 100644 --- a/src/Metadata/Source/MysqlMetadata.php +++ b/src/Metadata/Source/MysqlMetadata.php @@ -86,7 +86,7 @@ protected function loadTableNameData(string $schema) : void 'table_type' => $row['TABLE_TYPE'], 'view_definition' => $row['VIEW_DEFINITION'], 'check_option' => $row['CHECK_OPTION'], - 'is_updatable' => ('YES' == $row['IS_UPDATABLE']), + 'is_updatable' => 'YES' == $row['IS_UPDATABLE'], ]; } @@ -161,13 +161,13 @@ protected function loadColumnData(string $table, string $schema) : void $columns[$row['COLUMN_NAME']] = [ 'ordinal_position' => $row['ORDINAL_POSITION'], 'column_default' => $row['COLUMN_DEFAULT'], - 'is_nullable' => ('YES' == $row['IS_NULLABLE']), + 'is_nullable' => 'YES' == $row['IS_NULLABLE'], 'data_type' => $row['DATA_TYPE'], 'character_maximum_length' => $row['CHARACTER_MAXIMUM_LENGTH'], 'character_octet_length' => $row['CHARACTER_OCTET_LENGTH'], 'numeric_precision' => $row['NUMERIC_PRECISION'], 'numeric_scale' => $row['NUMERIC_SCALE'], - 'numeric_unsigned' => (false !== strpos($row['COLUMN_TYPE'], 'unsigned')), + 'numeric_unsigned' => false !== strpos($row['COLUMN_TYPE'], 'unsigned'), 'erratas' => $erratas, ]; } diff --git a/src/Metadata/Source/OracleMetadata.php b/src/Metadata/Source/OracleMetadata.php index a1fb438546..bf116e09c3 100644 --- a/src/Metadata/Source/OracleMetadata.php +++ b/src/Metadata/Source/OracleMetadata.php @@ -63,7 +63,7 @@ protected function loadColumnData(string $table, string $schema) : void $columns[$row['COLUMN_NAME']] = [ 'ordinal_position' => $row['COLUMN_ID'], 'column_default' => $row['DATA_DEFAULT'], - 'is_nullable' => ('Y' == $row['NULLABLE']), + 'is_nullable' => 'Y' == $row['NULLABLE'], 'data_type' => $row['DATA_TYPE'], 'character_maximum_length' => $row['DATA_LENGTH'], 'character_octet_length' => null, diff --git a/src/Metadata/Source/PostgresqlMetadata.php b/src/Metadata/Source/PostgresqlMetadata.php index 7006f0d456..27508f538b 100644 --- a/src/Metadata/Source/PostgresqlMetadata.php +++ b/src/Metadata/Source/PostgresqlMetadata.php @@ -87,7 +87,7 @@ protected function loadTableNameData(string $schema) : void 'table_type' => $row['table_type'], 'view_definition' => $row['view_definition'], 'check_option' => $row['check_option'], - 'is_updatable' => ('YES' == $row['is_updatable']), + 'is_updatable' => 'YES' == $row['is_updatable'], ]; } @@ -140,7 +140,7 @@ protected function loadColumnData(string $table, string $schema) : void $columns[$row['column_name']] = [ 'ordinal_position' => $row['ordinal_position'], 'column_default' => $row['column_default'], - 'is_nullable' => ('YES' == $row['is_nullable']), + 'is_nullable' => 'YES' == $row['is_nullable'], 'data_type' => $row['data_type'], 'character_maximum_length' => $row['character_maximum_length'], 'character_octet_length' => $row['character_octet_length'], diff --git a/src/Metadata/Source/SqlServerMetadata.php b/src/Metadata/Source/SqlServerMetadata.php index f95e2cafd5..15f9d79bb9 100644 --- a/src/Metadata/Source/SqlServerMetadata.php +++ b/src/Metadata/Source/SqlServerMetadata.php @@ -86,7 +86,7 @@ protected function loadTableNameData(string $schema) : void 'table_type' => $row['TABLE_TYPE'], 'view_definition' => $row['VIEW_DEFINITION'], 'check_option' => $row['CHECK_OPTION'], - 'is_updatable' => ('YES' == $row['IS_UPDATABLE']), + 'is_updatable' => 'YES' == $row['IS_UPDATABLE'], ]; } @@ -143,7 +143,7 @@ protected function loadColumnData(string $table, string $schema) : void $columns[$row['COLUMN_NAME']] = [ 'ordinal_position' => $row['ORDINAL_POSITION'], 'column_default' => $row['COLUMN_DEFAULT'], - 'is_nullable' => ('YES' == $row['IS_NULLABLE']), + 'is_nullable' => 'YES' == $row['IS_NULLABLE'], 'data_type' => $row['DATA_TYPE'], 'character_maximum_length' => $row['CHARACTER_MAXIMUM_LENGTH'], 'character_octet_length' => $row['CHARACTER_OCTET_LENGTH'], From 625bb91981152914b2855952cac94c4ad93ed347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 11:14:42 +0100 Subject: [PATCH 11/14] Apply strict comparison --- src/Metadata/Object/ConstraintObject.php | 8 ++++---- src/Metadata/Source/AbstractSource.php | 10 +++++----- src/Metadata/Source/MysqlMetadata.php | 20 ++++++++++---------- src/Metadata/Source/OracleMetadata.php | 6 +++--- src/Metadata/Source/PostgresqlMetadata.php | 16 ++++++++-------- src/Metadata/Source/SqlServerMetadata.php | 16 ++++++++-------- src/Metadata/Source/SqliteMetadata.php | 4 ++-- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/Metadata/Object/ConstraintObject.php b/src/Metadata/Object/ConstraintObject.php index f9f0b40328..c33cc7a65f 100644 --- a/src/Metadata/Object/ConstraintObject.php +++ b/src/Metadata/Object/ConstraintObject.php @@ -376,7 +376,7 @@ public function setCheckClause($checkClause) : self */ public function isPrimaryKey() : bool { - return ('PRIMARY KEY' == $this->type); + return ('PRIMARY KEY' === $this->type); } /** @@ -386,7 +386,7 @@ public function isPrimaryKey() : bool */ public function isUnique() : bool { - return ('UNIQUE' == $this->type); + return ('UNIQUE' === $this->type); } /** @@ -396,7 +396,7 @@ public function isUnique() : bool */ public function isForeignKey() : bool { - return ('FOREIGN KEY' == $this->type); + return ('FOREIGN KEY' === $this->type); } /** @@ -406,6 +406,6 @@ public function isForeignKey() : bool */ public function isCheck() : bool { - return ('CHECK' == $this->type); + return ('CHECK' === $this->type); } } diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index 501aa489c0..fafcfe9f63 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -78,7 +78,7 @@ public function getTableNames(?string $schema = null, bool $includeViews = false $tableNames = []; foreach ($this->data['table_names'][$schema] as $tableName => $data) { - if ('BASE TABLE' == $data['table_type']) { + if ('BASE TABLE' === $data['table_type']) { $tableNames[] = $tableName; } } @@ -150,7 +150,7 @@ public function getViewNames(?string $schema = null) : array $viewNames = []; foreach ($this->data['table_names'][$schema] as $tableName => $data) { - if ('VIEW' == $data['table_type']) { + if ('VIEW' === $data['table_type']) { $viewNames[] = $tableName; } } @@ -185,7 +185,7 @@ public function getView(string $viewName, ?string $schema = null) : ViewObject $this->loadTableNameData($schema); $tableNames = $this->data['table_names'][$schema]; - if (isset($tableNames[$viewName]) && 'VIEW' == $tableNames[$viewName]['table_type']) { + if (isset($tableNames[$viewName]) && 'VIEW' === $tableNames[$viewName]['table_type']) { return $this->getTable($viewName, $schema); } throw new \Exception('View "' . $viewName . '" does not exist'); @@ -341,7 +341,7 @@ public function getConstraintKeys(string $constraint, string $table, ?string $sc // organize references first $references = []; foreach ($this->data['constraint_references'][$schema] as $refKeyInfo) { - if ($refKeyInfo['constraint_name'] == $constraint) { + if ($refKeyInfo['constraint_name'] === $constraint) { $references[$refKeyInfo['constraint_name']] = $refKeyInfo; } } @@ -350,7 +350,7 @@ public function getConstraintKeys(string $constraint, string $table, ?string $sc $keys = []; foreach ($this->data['constraint_keys'][$schema] as $constraintKeyInfo) { - if ($constraintKeyInfo['table_name'] == $table && $constraintKeyInfo['constraint_name'] === $constraint) { + if ($constraintKeyInfo['table_name'] === $table && $constraintKeyInfo['constraint_name'] === $constraint) { $keys[] = $key = new ConstraintKeyObject($constraintKeyInfo['column_name']); $key->setOrdinalPosition($constraintKeyInfo['ordinal_position']); if (isset($references[$constraint])) { diff --git a/src/Metadata/Source/MysqlMetadata.php b/src/Metadata/Source/MysqlMetadata.php index a91ac1cb47..4ce45923c7 100644 --- a/src/Metadata/Source/MysqlMetadata.php +++ b/src/Metadata/Source/MysqlMetadata.php @@ -70,7 +70,7 @@ protected function loadTableNameData(string $schema) : void . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { @@ -86,7 +86,7 @@ protected function loadTableNameData(string $schema) : void 'table_type' => $row['TABLE_TYPE'], 'view_definition' => $row['VIEW_DEFINITION'], 'check_option' => $row['CHECK_OPTION'], - 'is_updatable' => 'YES' == $row['IS_UPDATABLE'], + 'is_updatable' => 'YES' === $row['IS_UPDATABLE'], ]; } @@ -130,7 +130,7 @@ protected function loadColumnData(string $table, string $schema) : void . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) . ' = ' . $p->quoteTrustedValue($table); - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { @@ -161,7 +161,7 @@ protected function loadColumnData(string $table, string $schema) : void $columns[$row['COLUMN_NAME']] = [ 'ordinal_position' => $row['ORDINAL_POSITION'], 'column_default' => $row['COLUMN_DEFAULT'], - 'is_nullable' => 'YES' == $row['IS_NULLABLE'], + 'is_nullable' => 'YES' === $row['IS_NULLABLE'], 'data_type' => $row['DATA_TYPE'], 'character_maximum_length' => $row['CHARACTER_MAXIMUM_LENGTH'], 'character_octet_length' => $row['CHARACTER_OCTET_LENGTH'], @@ -230,7 +230,7 @@ protected function loadConstraintData(string $table, string $schema) : void . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { @@ -254,7 +254,7 @@ protected function loadConstraintData(string $table, string $schema) : void foreach ($results->toArray() as $row) { if ($row['CONSTRAINT_NAME'] !== $realName) { $realName = $row['CONSTRAINT_NAME']; - $isFK = ('FOREIGN KEY' == $row['CONSTRAINT_TYPE']); + $isFK = ('FOREIGN KEY' === $row['CONSTRAINT_TYPE']); if ($isFK) { $name = $realName; } else { @@ -314,7 +314,7 @@ protected function loadConstraintDataNames(string $schema) : void . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { @@ -365,7 +365,7 @@ protected function loadConstraintDataKeys(string $schema) : void . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { @@ -423,7 +423,7 @@ protected function loadConstraintReferences(string $table, string $schema) : voi . 'WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { @@ -479,7 +479,7 @@ protected function loadTriggerData(string $schema) : void . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TRIGGERS']) . ' WHERE '; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= $p->quoteIdentifier('TRIGGER_SCHEMA') . ' = ' . $p->quoteTrustedValue($schema); } else { diff --git a/src/Metadata/Source/OracleMetadata.php b/src/Metadata/Source/OracleMetadata.php index bf116e09c3..db0cc4c061 100644 --- a/src/Metadata/Source/OracleMetadata.php +++ b/src/Metadata/Source/OracleMetadata.php @@ -63,7 +63,7 @@ protected function loadColumnData(string $table, string $schema) : void $columns[$row['COLUMN_NAME']] = [ 'ordinal_position' => $row['COLUMN_ID'], 'column_default' => $row['DATA_DEFAULT'], - 'is_nullable' => 'Y' == $row['NULLABLE'], + 'is_nullable' => 'Y' === $row['NULLABLE'], 'data_type' => $row['DATA_TYPE'], 'character_maximum_length' => $row['DATA_LENGTH'], 'character_octet_length' => null, @@ -147,14 +147,14 @@ protected function loadConstraintData(string $table, string $schema) : void 'table_name' => $row['TABLE_NAME'], ]; - if ('C' == $row['CONSTRAINT_TYPE']) { + if ('C' === $row['CONSTRAINT_TYPE']) { $constraints[$name]['CHECK_CLAUSE'] = $row['CHECK_CLAUSE']; continue; } $constraints[$name]['columns'] = []; - $isFK = ('R' == $row['CONSTRAINT_TYPE']); + $isFK = ('R' === $row['CONSTRAINT_TYPE']); if ($isFK) { $constraints[$name]['referenced_table_schema'] = $row['REF_OWNER']; $constraints[$name]['referenced_table_name'] = $row['REF_TABLE']; diff --git a/src/Metadata/Source/PostgresqlMetadata.php b/src/Metadata/Source/PostgresqlMetadata.php index 27508f538b..aa98608439 100644 --- a/src/Metadata/Source/PostgresqlMetadata.php +++ b/src/Metadata/Source/PostgresqlMetadata.php @@ -71,7 +71,7 @@ protected function loadTableNameData(string $schema) : void . ' WHERE ' . $p->quoteIdentifierChain(['t', 'table_type']) . ' IN (\'BASE TABLE\', \'VIEW\')'; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= ' AND ' . $p->quoteIdentifierChain(['t', 'table_schema']) . ' = ' . $p->quoteTrustedValue($schema); } else { @@ -87,7 +87,7 @@ protected function loadTableNameData(string $schema) : void 'table_type' => $row['table_type'], 'view_definition' => $row['view_definition'], 'check_option' => $row['check_option'], - 'is_updatable' => 'YES' == $row['is_updatable'], + 'is_updatable' => 'YES' === $row['is_updatable'], ]; } @@ -129,7 +129,7 @@ protected function loadColumnData(string $table, string $schema) : void . ' AND ' . $platform->quoteIdentifier('table_name') . ' = ' . $platform->quoteTrustedValue($table); - if ($schema != '__DEFAULT_SCHEMA__') { + if ($schema !== '__DEFAULT_SCHEMA__') { $sql .= ' AND ' . $platform->quoteIdentifier('table_schema') . ' = ' . $platform->quoteTrustedValue($schema); } @@ -140,7 +140,7 @@ protected function loadColumnData(string $table, string $schema) : void $columns[$row['column_name']] = [ 'ordinal_position' => $row['ordinal_position'], 'column_default' => $row['column_default'], - 'is_nullable' => 'YES' == $row['is_nullable'], + 'is_nullable' => 'YES' === $row['is_nullable'], 'data_type' => $row['data_type'], 'character_maximum_length' => $row['character_maximum_length'], 'character_octet_length' => $row['character_octet_length'], @@ -228,7 +228,7 @@ protected function loadConstraintData(string $table, string $schema) : void . ' AND ' . $p->quoteIdentifierChain(['t', 'table_type']) . ' IN (\'BASE TABLE\', \'VIEW\')'; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= ' AND ' . $p->quoteIdentifierChain(['t', 'table_schema']) . ' = ' . $p->quoteTrustedValue($schema); } else { @@ -257,12 +257,12 @@ protected function loadConstraintData(string $table, string $schema) : void 'constraint_type' => $row['constraint_type'], 'table_name' => $row['table_name'], ]; - if ('CHECK' == $row['constraint_type']) { + if ('CHECK' === $row['constraint_type']) { $constraints[$name]['check_clause'] = $row['check_clause']; continue; } $constraints[$name]['columns'] = []; - $isFK = ('FOREIGN KEY' == $row['constraint_type']); + $isFK = ('FOREIGN KEY' === $row['constraint_type']); if ($isFK) { $constraints[$name]['referenced_table_schema'] = $row['referenced_table_schema']; $constraints[$name]['referenced_table_name'] = $row['referenced_table_name']; @@ -323,7 +323,7 @@ protected function loadTriggerData(string $schema) : void . ' FROM ' . $p->quoteIdentifierChain(['information_schema', 'triggers']) . ' WHERE '; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= $p->quoteIdentifier('trigger_schema') . ' = ' . $p->quoteTrustedValue($schema); } else { diff --git a/src/Metadata/Source/SqlServerMetadata.php b/src/Metadata/Source/SqlServerMetadata.php index 15f9d79bb9..4804580d23 100644 --- a/src/Metadata/Source/SqlServerMetadata.php +++ b/src/Metadata/Source/SqlServerMetadata.php @@ -70,7 +70,7 @@ protected function loadTableNameData(string $schema) : void . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { @@ -86,7 +86,7 @@ protected function loadTableNameData(string $schema) : void 'table_type' => $row['TABLE_TYPE'], 'view_definition' => $row['VIEW_DEFINITION'], 'check_option' => $row['CHECK_OPTION'], - 'is_updatable' => 'YES' == $row['IS_UPDATABLE'], + 'is_updatable' => 'YES' === $row['IS_UPDATABLE'], ]; } @@ -129,7 +129,7 @@ protected function loadColumnData(string $table, string $schema) : void . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) . ' = ' . $p->quoteTrustedValue($table); - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { @@ -143,7 +143,7 @@ protected function loadColumnData(string $table, string $schema) : void $columns[$row['COLUMN_NAME']] = [ 'ordinal_position' => $row['ORDINAL_POSITION'], 'column_default' => $row['COLUMN_DEFAULT'], - 'is_nullable' => 'YES' == $row['IS_NULLABLE'], + 'is_nullable' => 'YES' === $row['IS_NULLABLE'], 'data_type' => $row['DATA_TYPE'], 'character_maximum_length' => $row['CHARACTER_MAXIMUM_LENGTH'], 'character_octet_length' => $row['CHARACTER_OCTET_LENGTH'], @@ -231,7 +231,7 @@ protected function loadConstraintData(string $table, string $schema) : void . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { @@ -261,12 +261,12 @@ protected function loadConstraintData(string $table, string $schema) : void 'constraint_type' => $row['CONSTRAINT_TYPE'], 'table_name' => $row['TABLE_NAME'], ]; - if ('CHECK' == $row['CONSTRAINT_TYPE']) { + if ('CHECK' === $row['CONSTRAINT_TYPE']) { $constraints[$name]['check_clause'] = $row['CHECK_CLAUSE']; continue; } $constraints[$name]['columns'] = []; - $isFK = ('FOREIGN KEY' == $row['CONSTRAINT_TYPE']); + $isFK = ('FOREIGN KEY' === $row['CONSTRAINT_TYPE']); if ($isFK) { $constraints[$name]['referenced_table_schema'] = $row['REFERENCED_TABLE_SCHEMA']; $constraints[$name]['referenced_table_name'] = $row['REFERENCED_TABLE_NAME']; @@ -321,7 +321,7 @@ protected function loadTriggerData(string $schema) : void . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TRIGGERS']) . ' WHERE '; - if ($schema != self::DEFAULT_SCHEMA) { + if ($schema !== self::DEFAULT_SCHEMA) { $sql .= $p->quoteIdentifier('TRIGGER_SCHEMA') . ' = ' . $p->quoteTrustedValue($schema); } else { diff --git a/src/Metadata/Source/SqliteMetadata.php b/src/Metadata/Source/SqliteMetadata.php index 407045318b..3cd7638e8d 100644 --- a/src/Metadata/Source/SqliteMetadata.php +++ b/src/Metadata/Source/SqliteMetadata.php @@ -45,7 +45,7 @@ protected function loadTableNameData(string $schema) : void $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); $tables = []; foreach ($results->toArray() as $row) { - if ('table' == $row['type']) { + if ('table' === $row['type']) { $table = [ 'table_type' => 'BASE TABLE', 'view_definition' => null, // VIEW only @@ -324,7 +324,7 @@ protected function parseTrigger(string $sql) : ?array } if (! empty($data['action_timing'])) { $data['action_timing'] = strtoupper($data['action_timing']); - if ('I' == $data['action_timing'][0]) { + if ('I' === $data['action_timing'][0]) { // normalize the white-space between the two words $data['action_timing'] = 'INSTEAD OF'; } From e28f7c8f816ef09e0471184bfa6869bb7810fda4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 11:26:05 +0100 Subject: [PATCH 12/14] Added missing, updated and formatted DocBlocks --- 3.0.0.md | 2 +- src/Metadata/Object/AbstractTableObject.php | 4 -- src/Metadata/Object/ColumnObject.php | 13 ----- src/Metadata/Object/ConstraintKeyObject.php | 8 --- src/Metadata/Object/ConstraintObject.php | 19 -------- src/Metadata/Object/TriggerObject.php | 30 ------------ src/Metadata/Object/ViewObject.php | 14 ++++++ src/Metadata/Source/AbstractSource.php | 3 -- src/Metadata/Source/MysqlMetadata.php | 26 ++++++++++ src/Metadata/Source/PostgresqlMetadata.php | 15 ++++++ src/Metadata/Source/SqlServerMetadata.php | 15 ++++++ src/Metadata/Source/SqliteMetadata.php | 54 +++++++++++++++++++-- 12 files changed, 122 insertions(+), 81 deletions(-) diff --git a/3.0.0.md b/3.0.0.md index 37b3c6bcc0..4f7af77cec 100644 --- a/3.0.0.md +++ b/3.0.0.md @@ -36,4 +36,4 @@ be compatible with return hint declaration of `Zend\Db\Metadata\Source\AbstractS - Zend\Db\Metadata\Source\SqliteMetadata -`parseTrigger()` now possibly return `array|null` instead of `array|void` +`parseView()` and `parseTrigger()` now possibly return `array|null` instead of `array|void` diff --git a/src/Metadata/Object/AbstractTableObject.php b/src/Metadata/Object/AbstractTableObject.php index 8c73e46413..5a419947ce 100644 --- a/src/Metadata/Object/AbstractTableObject.php +++ b/src/Metadata/Object/AbstractTableObject.php @@ -12,25 +12,21 @@ abstract class AbstractTableObject { /** - * * @var string */ protected $name = ''; /** - * * @var string */ protected $type = ''; /** - * * @var array */ protected $columns = []; /** - * * @var array */ protected $constraints = []; diff --git a/src/Metadata/Object/ColumnObject.php b/src/Metadata/Object/ColumnObject.php index 89f6c5e3b4..ceea079a27 100644 --- a/src/Metadata/Object/ColumnObject.php +++ b/src/Metadata/Object/ColumnObject.php @@ -12,79 +12,66 @@ class ColumnObject { /** - * * @var string */ protected $name = ''; /** - * * @var string */ protected $tableName = ''; /** - * * @var string */ protected $schemaName = ''; /** - * * @var int|null */ protected $ordinalPosition; /** - * * @var string */ protected $columnDefault = ''; /** - * * @var bool */ protected $isNullable = false; /** - * * @var string */ protected $dataType = ''; /** - * * @var int|null */ protected $characterMaximumLength; /** - * * @var int|null */ protected $characterOctetLength; /** - * * @var int|null */ protected $numericPrecision; /** - * * @var int|null */ protected $numericScale; /** - * * @var bool */ protected $numericUnsigned = false; /** - * * @var array */ protected $errata = []; diff --git a/src/Metadata/Object/ConstraintKeyObject.php b/src/Metadata/Object/ConstraintKeyObject.php index 13a0a71247..4f170976bc 100644 --- a/src/Metadata/Object/ConstraintKeyObject.php +++ b/src/Metadata/Object/ConstraintKeyObject.php @@ -18,49 +18,41 @@ class ConstraintKeyObject public const FK_SET_DEFAULT = 'SET DEFAULT'; /** - * * @var string */ protected $columnName = ''; /** - * * @var int|null */ protected $ordinalPosition; /** - * * @var bool */ protected $positionInUniqueConstraint = false; /** - * * @var string */ protected $referencedTableSchema = ''; /** - * * @var string */ protected $referencedTableName = ''; /** - * * @var string */ protected $referencedColumnName = ''; /** - * * @var string */ protected $foreignKeyUpdateRule = ''; /** - * * @var string */ protected $foreignKeyDeleteRule = ''; diff --git a/src/Metadata/Object/ConstraintObject.php b/src/Metadata/Object/ConstraintObject.php index c33cc7a65f..41932abeab 100644 --- a/src/Metadata/Object/ConstraintObject.php +++ b/src/Metadata/Object/ConstraintObject.php @@ -12,19 +12,16 @@ class ConstraintObject { /** - * * @var string */ protected $name = ''; /** - * * @var string */ protected $tableName = ''; /** - * * @var string */ protected $schemaName = ''; @@ -37,57 +34,41 @@ class ConstraintObject protected $type = ''; /** - * - * * @var string[] */ protected $columns = []; /** - * - * * @var string */ protected $referencedTableSchema = ''; /** - * - * * @var string */ protected $referencedTableName = ''; /** - * - * * @var string[] */ protected $referencedColumns = []; /** - * - * * @var string */ protected $matchOption = ''; /** - * - * * @var string */ protected $updateRule = ''; /** - * - * * @var string */ protected $deleteRule = ''; /** - * - * * @var string */ protected $checkClause = ''; diff --git a/src/Metadata/Object/TriggerObject.php b/src/Metadata/Object/TriggerObject.php index 8353df85d6..dc50e8e00d 100644 --- a/src/Metadata/Object/TriggerObject.php +++ b/src/Metadata/Object/TriggerObject.php @@ -14,106 +14,76 @@ class TriggerObject { /** - * - * * @var string */ protected $name = ''; /** - * - * * @var string */ protected $eventManipulation = ''; /** - * - * * @var string */ protected $eventObjectCatalog = ''; /** - * - * * @var string */ protected $eventObjectSchema = ''; /** - * - * * @var string */ protected $eventObjectTable = ''; /** - * - * * @var string */ protected $actionOrder = ''; /** - * - * * @var string */ protected $actionCondition = ''; /** - * - * * @var string */ protected $actionStatement = ''; /** - * - * * @var string */ protected $actionOrientation = ''; /** - * - * * @var string */ protected $actionTiming = ''; /** - * - * * @var string */ protected $actionReferenceOldTable = ''; /** - * - * * @var string */ protected $actionReferenceNewTable = ''; /** - * - * * @var string */ protected $actionReferenceOldRow = ''; /** - * - * * @var string */ protected $actionReferenceNewRow = ''; /** - * - * * @var DateTime|null */ protected $created; diff --git a/src/Metadata/Object/ViewObject.php b/src/Metadata/Object/ViewObject.php index af51ad0a95..c3750c4e84 100644 --- a/src/Metadata/Object/ViewObject.php +++ b/src/Metadata/Object/ViewObject.php @@ -11,8 +11,19 @@ class ViewObject extends AbstractTableObject { + /** + * @var string + */ protected $viewDefinition = ''; + + /** + * @var string + */ protected $checkOption = ''; + + /** + * @var bool + */ protected $isUpdatable = false; /** @@ -69,6 +80,9 @@ public function setIsUpdatable(bool $isUpdatable) : self return $this; } + /** + * @return bool + */ public function isUpdatable() : bool { return $this->isUpdatable; diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index fafcfe9f63..753ffe0540 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -23,19 +23,16 @@ abstract class AbstractSource implements MetadataInterface public const DEFAULT_SCHEMA = '__DEFAULT_SCHEMA__'; /** - * * @var Adapter */ protected $adapter; /** - * * @var string */ protected $defaultSchema = ''; /** - * * @var array */ protected $data = []; diff --git a/src/Metadata/Source/MysqlMetadata.php b/src/Metadata/Source/MysqlMetadata.php index 4ce45923c7..f9f7184806 100644 --- a/src/Metadata/Source/MysqlMetadata.php +++ b/src/Metadata/Source/MysqlMetadata.php @@ -13,6 +13,9 @@ class MysqlMetadata extends AbstractSource { + /** + * @inheritdoc + */ protected function loadSchemaData() : void { if (isset($this->data['schemas'])) { @@ -37,6 +40,9 @@ protected function loadSchemaData() : void $this->data['schemas'] = $schemas; } + /** + * @inheritdoc + */ protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { @@ -93,6 +99,9 @@ protected function loadTableNameData(string $schema) : void $this->data['table_names'][$schema] = $tables; } + /** + * @inheritdoc + */ protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { @@ -175,6 +184,9 @@ protected function loadColumnData(string $table, string $schema) : void $this->data['columns'][$schema][$table] = $columns; } + /** + * @inheritdoc + */ protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { @@ -284,6 +296,11 @@ protected function loadConstraintData(string $table, string $schema) : void $this->data['constraints'][$schema][$table] = $constraints; } + /** + * Load constraint data names + * + * @param string $schema + */ protected function loadConstraintDataNames(string $schema) : void { if (isset($this->data['constraint_names'][$schema])) { @@ -332,6 +349,9 @@ protected function loadConstraintDataNames(string $schema) : void $this->data['constraint_names'][$schema] = $data; } + /** + * @inheritdoc + */ protected function loadConstraintDataKeys(string $schema) : void { if (isset($this->data['constraint_keys'][$schema])) { @@ -383,6 +403,9 @@ protected function loadConstraintDataKeys(string $schema) : void $this->data['constraint_keys'][$schema] = $data; } + /** + * @inheritdoc + */ protected function loadConstraintReferences(string $table, string $schema) : void { parent::loadConstraintReferences($table, $schema); @@ -441,6 +464,9 @@ protected function loadConstraintReferences(string $table, string $schema) : voi $this->data['constraint_references'][$schema] = $data; } + /** + * @inheritdoc + */ protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { diff --git a/src/Metadata/Source/PostgresqlMetadata.php b/src/Metadata/Source/PostgresqlMetadata.php index aa98608439..316abe5f21 100644 --- a/src/Metadata/Source/PostgresqlMetadata.php +++ b/src/Metadata/Source/PostgresqlMetadata.php @@ -13,6 +13,9 @@ class PostgresqlMetadata extends AbstractSource { + /** + * @inheritdoc + */ protected function loadSchemaData() : void { if (isset($this->data['schemas'])) { @@ -38,6 +41,9 @@ protected function loadSchemaData() : void $this->data['schemas'] = $schemas; } + /** + * @inheritdoc + */ protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { @@ -94,6 +100,9 @@ protected function loadTableNameData(string $schema) : void $this->data['table_names'][$schema] = $tables; } + /** + * @inheritdoc + */ protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { @@ -154,6 +163,9 @@ protected function loadColumnData(string $table, string $schema) : void $this->data['columns'][$schema][$table] = $columns; } + /** + * @inheritdoc + */ protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { @@ -281,6 +293,9 @@ protected function loadConstraintData(string $table, string $schema) : void $this->data['constraints'][$schema][$table] = $constraints; } + /** + * @inheritdoc + */ protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { diff --git a/src/Metadata/Source/SqlServerMetadata.php b/src/Metadata/Source/SqlServerMetadata.php index 4804580d23..4d4820ffc2 100644 --- a/src/Metadata/Source/SqlServerMetadata.php +++ b/src/Metadata/Source/SqlServerMetadata.php @@ -13,6 +13,9 @@ class SqlServerMetadata extends AbstractSource { + /** + * @inheritdoc + */ protected function loadSchemaData() : void { if (isset($this->data['schemas'])) { @@ -37,6 +40,9 @@ protected function loadSchemaData() : void $this->data['schemas'] = $schemas; } + /** + * @inheritdoc + */ protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { @@ -93,6 +99,9 @@ protected function loadTableNameData(string $schema) : void $this->data['table_names'][$schema] = $tables; } + /** + * @inheritdoc + */ protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { @@ -157,6 +166,9 @@ protected function loadColumnData(string $table, string $schema) : void $this->data['columns'][$schema][$table] = $columns; } + /** + * @inheritdoc + */ protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { @@ -285,6 +297,9 @@ protected function loadConstraintData(string $table, string $schema) : void $this->data['constraints'][$schema][$table] = $constraints; } + /** + * @inheritdoc + */ protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { diff --git a/src/Metadata/Source/SqliteMetadata.php b/src/Metadata/Source/SqliteMetadata.php index 3cd7638e8d..a66a91b431 100644 --- a/src/Metadata/Source/SqliteMetadata.php +++ b/src/Metadata/Source/SqliteMetadata.php @@ -14,6 +14,9 @@ class SqliteMetadata extends AbstractSource { + /** + * @inheritdoc + */ protected function loadSchemaData() : void { if (isset($this->data['schemas'])) { @@ -28,6 +31,9 @@ protected function loadSchemaData() : void $this->data['schemas'] = $schemas; } + /** + * @inheritdoc + */ protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { @@ -70,6 +76,9 @@ protected function loadTableNameData(string $schema) : void $this->data['table_names'][$schema] = $tables; } + /** + * @inheritdoc + */ protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { @@ -103,6 +112,9 @@ protected function loadColumnData(string $table, string $schema) : void $this->data['sqlite_columns'][$schema][$table] = $results; } + /** + * @inheritdoc + */ protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { @@ -186,6 +198,9 @@ protected function loadConstraintData(string $table, string $schema) : void $this->data['constraints'][$schema][$table] = $constraints; } + /** + * @inheritdoc + */ protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { @@ -231,7 +246,15 @@ protected function loadTriggerData(string $schema) : void $this->data['triggers'][$schema] = $triggers; } - protected function fetchPragma(string $name, ?string $value = null, ?string $schema = null) + /** + * Fetch pragma + * + * @param string $name + * @param string|null $value + * @param string|null $schema + * @return array + */ + protected function fetchPragma(string $name, ?string $value = null, ?string $schema = null) : array { $p = $this->adapter->getPlatform(); @@ -253,7 +276,13 @@ protected function fetchPragma(string $name, ?string $value = null, ?string $sch return []; } - protected function parseView(string $sql) + /** + * Parse view + * + * @param string $sql + * @return array|void + */ + protected function parseView(string $sql) : ?array { static $re = null; if (null === $re) { @@ -271,13 +300,19 @@ protected function parseView(string $sql) } if (! preg_match($re, $sql, $matches)) { - return; + return null; } return [ 'view_definition' => $matches['view_definition'], ]; } + /** + * Parse trigger + * + * @param string $sql + * @return array|null + */ protected function parseTrigger(string $sql) : ?array { static $re = null; @@ -336,6 +371,10 @@ protected function parseTrigger(string $sql) : ?array return $data; } + /** + * @param array $re + * @return string|null + */ protected function buildRegularExpression(array $re) : ?string { foreach ($re as &$value) { @@ -350,6 +389,9 @@ protected function buildRegularExpression(array $re) : ?string return $re; } + /** + * @return string|null + */ protected function getIdentifierRegularExpression() : ?string { static $re = null; @@ -365,6 +407,9 @@ protected function getIdentifierRegularExpression() : ?string return $re; } + /** + * @return string|null + */ protected function getIdentifierChainRegularExpression() : ?string { static $re = null; @@ -375,6 +420,9 @@ protected function getIdentifierChainRegularExpression() : ?string return $re; } + /** + * @return string|null + */ protected function getIdentifierListRegularExpression() : ?string { static $re = null; From fc4edbfecc0e773e3b5af383545e474e9b3d3ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 11:56:53 +0100 Subject: [PATCH 13/14] Changed single-line comments with @var to one-liners --- src/Metadata/Metadata.php | 4 +- src/Metadata/Object/AbstractTableObject.php | 16 ++---- src/Metadata/Object/ColumnObject.php | 52 +++++------------- src/Metadata/Object/ConstraintKeyObject.php | 32 +++-------- src/Metadata/Object/ConstraintObject.php | 44 ++++----------- src/Metadata/Object/TriggerObject.php | 60 ++++++--------------- src/Metadata/Object/ViewObject.php | 12 ++--- src/Metadata/Source/AbstractSource.php | 12 ++--- src/Metadata/Source/OracleMetadata.php | 4 +- 9 files changed, 59 insertions(+), 177 deletions(-) diff --git a/src/Metadata/Metadata.php b/src/Metadata/Metadata.php index f67f20fcd4..a5463603b2 100644 --- a/src/Metadata/Metadata.php +++ b/src/Metadata/Metadata.php @@ -21,9 +21,7 @@ */ class Metadata implements MetadataInterface { - /** - * @var MetadataInterface - */ + /** @var MetadataInterface */ protected $source; /** diff --git a/src/Metadata/Object/AbstractTableObject.php b/src/Metadata/Object/AbstractTableObject.php index 5a419947ce..76596344f7 100644 --- a/src/Metadata/Object/AbstractTableObject.php +++ b/src/Metadata/Object/AbstractTableObject.php @@ -11,24 +11,16 @@ abstract class AbstractTableObject { - /** - * @var string - */ + /** @var string */ protected $name = ''; - /** - * @var string - */ + /** @var string */ protected $type = ''; - /** - * @var array - */ + /** @var array */ protected $columns = []; - /** - * @var array - */ + /** @var array */ protected $constraints = []; /** diff --git a/src/Metadata/Object/ColumnObject.php b/src/Metadata/Object/ColumnObject.php index ceea079a27..50bec0bfc3 100644 --- a/src/Metadata/Object/ColumnObject.php +++ b/src/Metadata/Object/ColumnObject.php @@ -11,69 +11,43 @@ class ColumnObject { - /** - * @var string - */ + /** @var string */ protected $name = ''; - /** - * @var string - */ + /** @var string */ protected $tableName = ''; - /** - * @var string - */ + /** @var string */ protected $schemaName = ''; - /** - * @var int|null - */ + /** @var int|null */ protected $ordinalPosition; - /** - * @var string - */ + /** @var string */ protected $columnDefault = ''; - /** - * @var bool - */ + /** @var bool */ protected $isNullable = false; - /** - * @var string - */ + /** @var string */ protected $dataType = ''; - /** - * @var int|null - */ + /** @var int|null */ protected $characterMaximumLength; - /** - * @var int|null - */ + /** @var int|null */ protected $characterOctetLength; - /** - * @var int|null - */ + /** @var int|null */ protected $numericPrecision; - /** - * @var int|null - */ + /** @var int|null */ protected $numericScale; - /** - * @var bool - */ + /** @var bool */ protected $numericUnsigned = false; - /** - * @var array - */ + /** @var array */ protected $errata = []; /** diff --git a/src/Metadata/Object/ConstraintKeyObject.php b/src/Metadata/Object/ConstraintKeyObject.php index 4f170976bc..59330a0708 100644 --- a/src/Metadata/Object/ConstraintKeyObject.php +++ b/src/Metadata/Object/ConstraintKeyObject.php @@ -17,44 +17,28 @@ class ConstraintKeyObject public const FK_RESTRICT = 'RESTRICT'; public const FK_SET_DEFAULT = 'SET DEFAULT'; - /** - * @var string - */ + /** @var string */ protected $columnName = ''; - /** - * @var int|null - */ + /** @var int|null */ protected $ordinalPosition; - /** - * @var bool - */ + /** @var bool */ protected $positionInUniqueConstraint = false; - /** - * @var string - */ + /** @var string */ protected $referencedTableSchema = ''; - /** - * @var string - */ + /** @var string */ protected $referencedTableName = ''; - /** - * @var string - */ + /** @var string */ protected $referencedColumnName = ''; - /** - * @var string - */ + /** @var string */ protected $foreignKeyUpdateRule = ''; - /** - * @var string - */ + /** @var string */ protected $foreignKeyDeleteRule = ''; /** diff --git a/src/Metadata/Object/ConstraintObject.php b/src/Metadata/Object/ConstraintObject.php index 41932abeab..f63f4961e2 100644 --- a/src/Metadata/Object/ConstraintObject.php +++ b/src/Metadata/Object/ConstraintObject.php @@ -11,19 +11,13 @@ class ConstraintObject { - /** - * @var string - */ + /** @var string */ protected $name = ''; - /** - * @var string - */ + /** @var string */ protected $tableName = ''; - /** - * @var string - */ + /** @var string */ protected $schemaName = ''; /** @@ -33,44 +27,28 @@ class ConstraintObject */ protected $type = ''; - /** - * @var string[] - */ + /** @var string[] */ protected $columns = []; - /** - * @var string - */ + /** @var string */ protected $referencedTableSchema = ''; - /** - * @var string - */ + /** @var string */ protected $referencedTableName = ''; - /** - * @var string[] - */ + /** @var string[] */ protected $referencedColumns = []; - /** - * @var string - */ + /** @var string */ protected $matchOption = ''; - /** - * @var string - */ + /** @var string */ protected $updateRule = ''; - /** - * @var string - */ + /** @var string */ protected $deleteRule = ''; - /** - * @var string - */ + /** @var string */ protected $checkClause = ''; /** diff --git a/src/Metadata/Object/TriggerObject.php b/src/Metadata/Object/TriggerObject.php index dc50e8e00d..5c88d8d06b 100644 --- a/src/Metadata/Object/TriggerObject.php +++ b/src/Metadata/Object/TriggerObject.php @@ -13,79 +13,49 @@ class TriggerObject { - /** - * @var string - */ + /** @var string */ protected $name = ''; - /** - * @var string - */ + /** @var string */ protected $eventManipulation = ''; - /** - * @var string - */ + /** @var string */ protected $eventObjectCatalog = ''; - /** - * @var string - */ + /** @var string */ protected $eventObjectSchema = ''; - /** - * @var string - */ + /** @var string */ protected $eventObjectTable = ''; - /** - * @var string - */ + /** @var string */ protected $actionOrder = ''; - /** - * @var string - */ + /** @var string */ protected $actionCondition = ''; - /** - * @var string - */ + /** @var string */ protected $actionStatement = ''; - /** - * @var string - */ + /** @var string */ protected $actionOrientation = ''; - /** - * @var string - */ + /** @var string */ protected $actionTiming = ''; - /** - * @var string - */ + /** @var string */ protected $actionReferenceOldTable = ''; - /** - * @var string - */ + /** @var string */ protected $actionReferenceNewTable = ''; - /** - * @var string - */ + /** @var string */ protected $actionReferenceOldRow = ''; - /** - * @var string - */ + /** @var string */ protected $actionReferenceNewRow = ''; - /** - * @var DateTime|null - */ + /** @var DateTime|null */ protected $created; /** diff --git a/src/Metadata/Object/ViewObject.php b/src/Metadata/Object/ViewObject.php index c3750c4e84..07bb324e2d 100644 --- a/src/Metadata/Object/ViewObject.php +++ b/src/Metadata/Object/ViewObject.php @@ -11,19 +11,13 @@ class ViewObject extends AbstractTableObject { - /** - * @var string - */ + /** @var string */ protected $viewDefinition = ''; - /** - * @var string - */ + /** @var string */ protected $checkOption = ''; - /** - * @var bool - */ + /** @var bool */ protected $isUpdatable = false; /** diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index 753ffe0540..2e7a1a5ac0 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -22,19 +22,13 @@ abstract class AbstractSource implements MetadataInterface { public const DEFAULT_SCHEMA = '__DEFAULT_SCHEMA__'; - /** - * @var Adapter - */ + /** @var Adapter */ protected $adapter; - /** - * @var string - */ + /** @var string */ protected $defaultSchema = ''; - /** - * @var array - */ + /** @var array */ protected $data = []; /** diff --git a/src/Metadata/Source/OracleMetadata.php b/src/Metadata/Source/OracleMetadata.php index db0cc4c061..c14532165d 100644 --- a/src/Metadata/Source/OracleMetadata.php +++ b/src/Metadata/Source/OracleMetadata.php @@ -16,9 +16,7 @@ */ class OracleMetadata extends AbstractSource { - /** - * @var array - */ + /** @var array */ protected static $constraintTypeMap = [ 'C' => 'CHECK', 'P' => 'PRIMARY KEY', From f072bec9643db56c24b261b3d81fa2c131e3c894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Wed, 13 Mar 2019 12:11:30 +0100 Subject: [PATCH 14/14] Removed method comments which do not add valuable information --- src/Metadata/Metadata.php | 53 ------- src/Metadata/MetadataInterface.php | 37 ----- src/Metadata/Object/AbstractTableObject.php | 35 ----- src/Metadata/Object/ColumnObject.php | 123 --------------- src/Metadata/Object/ConstraintKeyObject.php | 91 ----------- src/Metadata/Object/ConstraintObject.php | 156 ------------------ src/Metadata/Object/TriggerObject.php | 165 -------------------- src/Metadata/Object/ViewObject.php | 24 --- src/Metadata/Source/AbstractSource.php | 91 ----------- src/Metadata/Source/Factory.php | 7 - src/Metadata/Source/MysqlMetadata.php | 5 - src/Metadata/Source/OracleMetadata.php | 26 --- src/Metadata/Source/SqliteMetadata.php | 33 ---- 13 files changed, 846 deletions(-) diff --git a/src/Metadata/Metadata.php b/src/Metadata/Metadata.php index a5463603b2..386b73cf0f 100644 --- a/src/Metadata/Metadata.php +++ b/src/Metadata/Metadata.php @@ -24,139 +24,86 @@ class Metadata implements MetadataInterface /** @var MetadataInterface */ protected $source; - /** - * Constructor - * - * @param Adapter $adapter - */ public function __construct(Adapter $adapter) { $this->source = Source\Factory::createSourceFromAdapter($adapter); } - /** - * {@inheritdoc} - */ public function getTables(?string $schema = null, bool $includeViews = false) : array { return $this->source->getTables($schema, $includeViews); } - /** - * {@inheritdoc} - */ public function getViews(?string $schema = null) : array { return $this->source->getViews($schema); } - /** - * {@inheritdoc} - */ public function getTriggers(?string $schema = null) : array { return $this->source->getTriggers($schema); } - /** - * {@inheritdoc} - */ public function getConstraints(string $table, ?string $schema = null) : array { return $this->source->getConstraints($table, $schema); } - /** - * {@inheritdoc} - */ public function getColumns(string $table, ?string $schema = null) : array { return $this->source->getColumns($table, $schema); } - /** - * {@inheritdoc} - */ public function getConstraintKeys($constraint, $table, ?string $schema = null) : array { return $this->source->getConstraintKeys($constraint, $table, $schema); } - /** - * {@inheritdoc} - */ public function getConstraint($constraintName, $table, ?string $schema = null) : ConstraintObject { return $this->source->getConstraint($constraintName, $table, $schema); } - /** - * {@inheritdoc} - */ public function getSchemas() : array { return $this->source->getSchemas(); } - /** - * {@inheritdoc} - */ public function getTableNames(?string $schema = null, bool $includeViews = false) : array { return $this->source->getTableNames($schema, $includeViews); } - /** - * {@inheritdoc} - */ public function getTable($tableName, ?string $schema = null) : TableObject { return $this->source->getTable($tableName, $schema); } - /** - * {@inheritdoc} - */ public function getViewNames(?string $schema = null) : array { return $this->source->getViewNames($schema); } - /** - * {@inheritdoc} - */ public function getView($viewName, ?string $schema = null) : ViewObject { return $this->source->getView($viewName, $schema); } - /** - * {@inheritdoc} - */ public function getTriggerNames(?string $schema = null) : array { return $this->source->getTriggerNames($schema); } - /** - * {@inheritdoc} - */ public function getTrigger($triggerName, ?string $schema = null) : TriggerObject { return $this->source->getTrigger($triggerName, $schema); } - /** - * {@inheritdoc} - */ public function getColumnNames(string $table, ?string $schema = null) : array { return $this->source->getColumnNames($table, $schema); } - /** - * {@inheritdoc} - */ public function getColumn($columnName, $table, ?string $schema = null) : ColumnObject { return $this->source->getColumn($columnName, $table, $schema); diff --git a/src/Metadata/MetadataInterface.php b/src/Metadata/MetadataInterface.php index ddfdcecb09..0a0c536566 100644 --- a/src/Metadata/MetadataInterface.php +++ b/src/Metadata/MetadataInterface.php @@ -43,13 +43,6 @@ public function getTableNames(?string $schema = null, bool $includeViews = false */ public function getTables(?string $schema = null, bool $includeViews = false) : array; - /** - * Get table - * - * @param string $tableName - * @param null|string $schema - * @return TableObject - */ public function getTable(string $tableName, ?string $schema = null) : TableObject; /** @@ -68,13 +61,6 @@ public function getViewNames(?string $schema = null) : array; */ public function getViews(?string $schema = null) : array; - /** - * Get view - * - * @param string $viewName - * @param null|string $schema - * @return ViewObject - */ public function getView(string $viewName, ?string $schema = null) : ViewObject; /** @@ -95,14 +81,6 @@ public function getColumnNames(string $table, ?string $schema = null) : array; */ public function getColumns(string $table, ?string $schema = null) : array; - /** - * Get column - * - * @param string $columnName - * @param string $table - * @param null|string $schema - * @return ColumnObject - */ public function getColumn(string $columnName, string $table, ?string $schema = null) : ColumnObject; /** @@ -114,14 +92,6 @@ public function getColumn(string $columnName, string $table, ?string $schema = n */ public function getConstraints(string $table, ?string $schema = null) : array; - /** - * Get constraint - * - * @param string $constraintName - * @param string $table - * @param null|string $schema - * @return ConstraintObject - */ public function getConstraint(string $constraintName, string $table, ?string $schema = null) : ConstraintObject; /** @@ -150,12 +120,5 @@ public function getTriggerNames(?string $schema = null) : array; */ public function getTriggers(?string $schema = null) : array; - /** - * Get trigger - * - * @param string $triggerName - * @param null|string $schema - * @return TriggerObject - */ public function getTrigger(string $triggerName, ?string $schema = null) : TriggerObject; } diff --git a/src/Metadata/Object/AbstractTableObject.php b/src/Metadata/Object/AbstractTableObject.php index 76596344f7..259f78363b 100644 --- a/src/Metadata/Object/AbstractTableObject.php +++ b/src/Metadata/Object/AbstractTableObject.php @@ -23,71 +23,36 @@ abstract class AbstractTableObject /** @var array */ protected $constraints = []; - /** - * Constructor - * - * @param string $name - */ public function __construct(string $name = '') { $this->setName($name); } - /** - * Set columns - * - * @param array $columns - */ public function setColumns(array $columns) : void { $this->columns = $columns; } - /** - * Get columns - * - * @return array - */ public function getColumns() : array { return $this->columns; } - /** - * Set constraints - * - * @param array $constraints - */ public function setConstraints(array $constraints) : void { $this->constraints = $constraints; } - /** - * Get constraints - * - * @return array - */ public function getConstraints() : array { return $this->constraints; } - /** - * Set name - * - * @param string $name - */ public function setName(string $name) : void { $this->name = $name; } - /** - * Get name - * - * @return string - */ public function getName() : string { return $this->name; diff --git a/src/Metadata/Object/ColumnObject.php b/src/Metadata/Object/ColumnObject.php index 50bec0bfc3..729a45e926 100644 --- a/src/Metadata/Object/ColumnObject.php +++ b/src/Metadata/Object/ColumnObject.php @@ -50,13 +50,6 @@ class ColumnObject /** @var array */ protected $errata = []; - /** - * Constructor - * - * @param string $name - * @param string $tableName - * @param string $schemaName - */ public function __construct(string $name, string $tableName, string $schemaName = '') { $this->setName($name); @@ -64,258 +57,151 @@ public function __construct(string $name, string $tableName, string $schemaName $this->setSchemaName($schemaName); } - /** - * Set name - * - * @param string $name - */ public function setName(string $name) : void { $this->name = $name; } - /** - * Get name - * - * @return string - */ public function getName() : string { return $this->name; } - /** - * Get table name - * - * @return string - */ public function getTableName() : string { return $this->tableName; } - /** - * Set table name - * - * @param string $tableName - * @return self Provides a fluent interface - */ public function setTableName(string $tableName) : self { $this->tableName = $tableName; return $this; } - /** - * Set schema name - * - * @param string $schemaName - */ public function setSchemaName(string $schemaName) : void { $this->schemaName = $schemaName; } - /** - * Get schema name - * - * @return string - */ public function getSchemaName() : string { return $this->schemaName; } - /** - * @return int $ordinalPosition - */ public function getOrdinalPosition() : ?int { return $this->ordinalPosition; } - /** - * @param int $ordinalPosition to set - * @return self Provides a fluent interface - */ public function setOrdinalPosition(?int $ordinalPosition) : self { $this->ordinalPosition = $ordinalPosition; return $this; } - /** - * @return null|string the $columnDefault - */ public function getColumnDefault() : ?string { return $this->columnDefault; } - /** - * @param string $columnDefault to set - * @return self Provides a fluent interface - */ public function setColumnDefault(string $columnDefault) : self { $this->columnDefault = $columnDefault; return $this; } - /** - * @return bool $isNullable - */ public function getIsNullable() : bool { return $this->isNullable; } - /** - * @param bool $isNullable to set - * @return self Provides a fluent interface - */ public function setIsNullable(bool $isNullable) : self { $this->isNullable = $isNullable; return $this; } - /** - * @return bool $isNullable - */ public function isNullable() : bool { return $this->isNullable; } - /** - * @return null|string the $dataType - */ public function getDataType() : ?string { return $this->dataType; } - /** - * @param string $dataType the $dataType to set - * @return self Provides a fluent interface - */ public function setDataType(string $dataType) : self { $this->dataType = $dataType; return $this; } - /** - * @return int|null the $characterMaximumLength - */ public function getCharacterMaximumLength() : ?int { return $this->characterMaximumLength; } - /** - * @param int|null $characterMaximumLength the $characterMaximumLength to set - * @return self Provides a fluent interface - */ public function setCharacterMaximumLength(?int $characterMaximumLength) : self { $this->characterMaximumLength = $characterMaximumLength; return $this; } - /** - * @return int|null the $characterOctetLength - */ public function getCharacterOctetLength() : ?int { return $this->characterOctetLength; } - /** - * @param int|null $characterOctetLength the $characterOctetLength to set - * @return self Provides a fluent interface - */ public function setCharacterOctetLength(?int $characterOctetLength) : self { $this->characterOctetLength = $characterOctetLength; return $this; } - /** - * @return int the $numericPrecision - */ public function getNumericPrecision() : ?int { return $this->numericPrecision; } - /** - * @param int|null $numericPrecision the $numericPrevision to set - * @return self Provides a fluent interface - */ public function setNumericPrecision(?int $numericPrecision) : self { $this->numericPrecision = $numericPrecision; return $this; } - /** - * @return int the $numericScale - */ public function getNumericScale() : ?int { return $this->numericScale; } - /** - * @param int $numericScale the $numericScale to set - * @return self Provides a fluent interface - */ public function setNumericScale(?int $numericScale) : self { $this->numericScale = $numericScale; return $this; } - /** - * @return bool - */ public function getNumericUnsigned() : bool { return $this->numericUnsigned; } - /** - * @param bool $numericUnsigned - * @return self Provides a fluent interface - */ public function setNumericUnsigned(bool $numericUnsigned) : self { $this->numericUnsigned = $numericUnsigned; return $this; } - /** - * @return bool - */ public function isNumericUnsigned() : bool { return $this->numericUnsigned; } - /** - * @return array the $errata - */ public function getErratas() : array { return $this->errata; } - /** - * @param array $erratas - * @return self Provides a fluent interface - */ public function setErratas(array $erratas) : self { foreach ($erratas as $name => $value) { @@ -324,10 +210,6 @@ public function setErratas(array $erratas) : self return $this; } - /** - * @param string $errataName - * @return mixed - */ public function getErrata(string $errataName) { if (array_key_exists($errataName, $this->errata)) { @@ -335,11 +217,6 @@ public function getErrata(string $errataName) } } - /** - * @param string $errataName - * @param mixed $errataValue - * @return self Provides a fluent interface - */ public function setErrata(string $errataName, $errataValue) : self { $this->errata[$errataName] = $errataValue; diff --git a/src/Metadata/Object/ConstraintKeyObject.php b/src/Metadata/Object/ConstraintKeyObject.php index 59330a0708..1e3f819b85 100644 --- a/src/Metadata/Object/ConstraintKeyObject.php +++ b/src/Metadata/Object/ConstraintKeyObject.php @@ -41,183 +41,92 @@ class ConstraintKeyObject /** @var string */ protected $foreignKeyDeleteRule = ''; - /** - * Constructor - * - * @param string $column - */ public function __construct(string $column) { $this->setColumnName($column); } - /** - * Get column name - * - * @return string - */ public function getColumnName() : string { return $this->columnName; } - /** - * Set column name - * - * @param string $columnName - * @return self Provides a fluent interface - */ public function setColumnName(string $columnName) : self { $this->columnName = $columnName; return $this; } - /** - * Get ordinal position - * - * @return int|null - */ public function getOrdinalPosition() : ?int { return $this->ordinalPosition; } - /** - * Set ordinal position - * - * @param int $ordinalPosition - * @return self Provides a fluent interface - */ public function setOrdinalPosition($ordinalPosition) : self { $this->ordinalPosition = $ordinalPosition; return $this; } - /** - * Get position in unique constraint - * - * @return bool - */ public function getPositionInUniqueConstraint() : bool { return $this->positionInUniqueConstraint; } - /** - * Set position in unique constraint - * - * @param bool $positionInUniqueConstraint - * @return self Provides a fluent interface - */ public function setPositionInUniqueConstraint(bool $positionInUniqueConstraint) : self { $this->positionInUniqueConstraint = $positionInUniqueConstraint; return $this; } - /** - * Get referenced table schema - * - * @return string - */ public function getReferencedTableSchema() : string { return $this->referencedTableSchema; } - /** - * Set referenced table schema - * - * @param string $referencedTableSchema - * @return self Provides a fluent interface - */ public function setReferencedTableSchema($referencedTableSchema) : self { $this->referencedTableSchema = $referencedTableSchema; return $this; } - /** - * Get referenced table name - * - * @return string - */ public function getReferencedTableName() : string { return $this->referencedTableName; } - /** - * Set Referenced table name - * - * @param string $referencedTableName - * @return self Provides a fluent interface - */ public function setReferencedTableName(string $referencedTableName) : self { $this->referencedTableName = $referencedTableName; return $this; } - /** - * Get referenced column name - * - * @return string - */ public function getReferencedColumnName() : string { return $this->referencedColumnName; } - /** - * Set referenced column name - * - * @param string $referencedColumnName - * @return self Provides a fluent interface - */ public function setReferencedColumnName(string $referencedColumnName) : self { $this->referencedColumnName = $referencedColumnName; return $this; } - /** - * set foreign key update rule - * - * @param string $foreignKeyUpdateRule - */ public function setForeignKeyUpdateRule($foreignKeyUpdateRule) : void { $this->foreignKeyUpdateRule = $foreignKeyUpdateRule; } - /** - * Get foreign key update rule - * - * @return string - */ public function getForeignKeyUpdateRule() : string { return $this->foreignKeyUpdateRule; } - /** - * Set foreign key delete rule - * - * @param string $foreignKeyDeleteRule - */ public function setForeignKeyDeleteRule($foreignKeyDeleteRule) : void { $this->foreignKeyDeleteRule = $foreignKeyDeleteRule; } - /** - * get foreign key delete rule - * - * @return string - */ public function getForeignKeyDeleteRule() : string { return $this->foreignKeyDeleteRule; diff --git a/src/Metadata/Object/ConstraintObject.php b/src/Metadata/Object/ConstraintObject.php index f63f4961e2..32c41b7778 100644 --- a/src/Metadata/Object/ConstraintObject.php +++ b/src/Metadata/Object/ConstraintObject.php @@ -51,13 +51,6 @@ class ConstraintObject /** @var string */ protected $checkClause = ''; - /** - * Constructor - * - * @param string $name - * @param string $tableName - * @param string $schemaName - */ public function __construct(string $name, string $tableName, string $schemaName = '') { $this->setName($name); @@ -65,83 +58,42 @@ public function __construct(string $name, string $tableName, string $schemaName $this->setSchemaName($schemaName); } - /** - * Set name - * - * @param string $name - */ public function setName(string $name) : void { $this->name = $name; } - /** - * Get name - * - * @return string - */ public function getName() : string { return $this->name; } - /** - * Set schema name - * - * @param string $schemaName - */ public function setSchemaName($schemaName) : void { $this->schemaName = $schemaName; } - /** - * Get schema name - * - * @return string - */ public function getSchemaName() : string { return $this->schemaName; } - /** - * Get table name - * - * @return string - */ public function getTableName() : string { return $this->tableName; } - /** - * Set table name - * - * @param string $tableName - * @return self Provides a fluent interface - */ public function setTableName($tableName) : self { $this->tableName = $tableName; return $this; } - /** - * Set type - * - * @param string $type - */ public function setType($type) : void { $this->type = $type; } - /** - * Get type - * - * @return string - */ public function getType() : string { return $this->type; @@ -152,217 +104,109 @@ public function hasColumns() : bool return ! empty($this->columns); } - /** - * Get Columns. - * - * @return string[] - */ public function getColumns() : array { return $this->columns; } - /** - * Set Columns. - * - * @param string[] $columns - * @return self Provides a fluent interface - */ public function setColumns(array $columns) : self { $this->columns = $columns; return $this; } - /** - * Get Referenced Table Schema. - * - * @return string - */ public function getReferencedTableSchema() : string { return $this->referencedTableSchema; } - /** - * Set Referenced Table Schema. - * - * @param string $referencedTableSchema - * @return self Provides a fluent interface - */ public function setReferencedTableSchema($referencedTableSchema) : self { $this->referencedTableSchema = $referencedTableSchema; return $this; } - /** - * Get Referenced Table Name. - * - * @return string - */ public function getReferencedTableName() : string { return $this->referencedTableName; } - /** - * Set Referenced Table Name. - * - * @param string $referencedTableName - * @return self Provides a fluent interface - */ public function setReferencedTableName($referencedTableName) : self { $this->referencedTableName = $referencedTableName; return $this; } - /** - * Get Referenced Columns. - * - * @return string[] - */ public function getReferencedColumns() : array { return $this->referencedColumns; } - /** - * Set Referenced Columns. - * - * @param string[] $referencedColumns - * @return self Provides a fluent interface - */ public function setReferencedColumns(array $referencedColumns) : self { $this->referencedColumns = $referencedColumns; return $this; } - /** - * Get Match Option. - * - * @return string - */ public function getMatchOption() : string { return $this->matchOption; } - /** - * Set Match Option. - * - * @param string $matchOption - * @return self Provides a fluent interface - */ public function setMatchOption($matchOption) : self { $this->matchOption = $matchOption; return $this; } - /** - * Get Update Rule. - * - * @return string - */ public function getUpdateRule() : string { return $this->updateRule; } - /** - * Set Update Rule. - * - * @param string $updateRule - * @return self Provides a fluent interface - */ public function setUpdateRule($updateRule) : self { $this->updateRule = $updateRule; return $this; } - /** - * Get Delete Rule. - * - * @return string - */ public function getDeleteRule() : string { return $this->deleteRule; } - /** - * Set Delete Rule. - * - * @param string $deleteRule - * @return self Provides a fluent interface - */ public function setDeleteRule($deleteRule) : self { $this->deleteRule = $deleteRule; return $this; } - /** - * Get Check Clause. - * - * @return string - */ public function getCheckClause() : string { return $this->checkClause; } - /** - * Set Check Clause. - * - * @param string $checkClause - * @return self Provides a fluent interface - */ public function setCheckClause($checkClause) : self { $this->checkClause = $checkClause; return $this; } - /** - * Is primary key - * - * @return bool - */ public function isPrimaryKey() : bool { return ('PRIMARY KEY' === $this->type); } - /** - * Is unique key - * - * @return bool - */ public function isUnique() : bool { return ('UNIQUE' === $this->type); } - /** - * Is foreign key - * - * @return bool - */ public function isForeignKey() : bool { return ('FOREIGN KEY' === $this->type); } - /** - * Is foreign key - * - * @return bool - */ public function isCheck() : bool { return ('CHECK' === $this->type); diff --git a/src/Metadata/Object/TriggerObject.php b/src/Metadata/Object/TriggerObject.php index 5c88d8d06b..d01c4bd8b5 100644 --- a/src/Metadata/Object/TriggerObject.php +++ b/src/Metadata/Object/TriggerObject.php @@ -58,330 +58,165 @@ class TriggerObject /** @var DateTime|null */ protected $created; - /** - * Get Name. - * - * @return string - */ public function getName() : string { return $this->name; } - /** - * Set Name. - * - * @param string $name - * @return self Provides a fluent interface - */ public function setName(string $name) : self { $this->name = $name; return $this; } - /** - * Get Event Manipulation. - * - * @return string - */ public function getEventManipulation() : string { return $this->eventManipulation; } - /** - * Set Event Manipulation. - * - * @param string $eventManipulation - * @return self Provides a fluent interface - */ public function setEventManipulation(string $eventManipulation) : self { $this->eventManipulation = $eventManipulation; return $this; } - /** - * Get Event Object Catalog. - * - * @return string - */ public function getEventObjectCatalog() : string { return $this->eventObjectCatalog; } - /** - * Set Event Object Catalog. - * - * @param string $eventObjectCatalog - * @return self Provides a fluent interface - */ public function setEventObjectCatalog(string $eventObjectCatalog) : self { $this->eventObjectCatalog = $eventObjectCatalog; return $this; } - /** - * Get Event Object Schema. - * - * @return string - */ public function getEventObjectSchema() : string { return $this->eventObjectSchema; } - /** - * Set Event Object Schema. - * - * @param string $eventObjectSchema - * @return self Provides a fluent interface - */ public function setEventObjectSchema(string $eventObjectSchema) : self { $this->eventObjectSchema = $eventObjectSchema; return $this; } - /** - * Get Event Object Table. - * - * @return string - */ public function getEventObjectTable() : string { return $this->eventObjectTable; } - /** - * Set Event Object Table. - * - * @param string $eventObjectTable - * @return self Provides a fluent interface - */ public function setEventObjectTable(string $eventObjectTable) : self { $this->eventObjectTable = $eventObjectTable; return $this; } - /** - * Get Action Order. - * - * @return string - */ public function getActionOrder() : string { return $this->actionOrder; } - /** - * Set Action Order. - * - * @param string $actionOrder - * @return self Provides a fluent interface - */ public function setActionOrder(string $actionOrder) : self { $this->actionOrder = $actionOrder; return $this; } - /** - * Get Action Condition. - * - * @return string - */ public function getActionCondition() : string { return $this->actionCondition; } - /** - * Set Action Condition. - * - * @param string $actionCondition - * @return self Provides a fluent interface - */ public function setActionCondition(string $actionCondition) : self { $this->actionCondition = $actionCondition; return $this; } - /** - * Get Action Statement. - * - * @return string - */ public function getActionStatement() : string { return $this->actionStatement; } - /** - * Set Action Statement. - * - * @param string $actionStatement - * @return self Provides a fluent interface - */ public function setActionStatement(string $actionStatement) : self { $this->actionStatement = $actionStatement; return $this; } - /** - * Get Action Orientation. - * - * @return string - */ public function getActionOrientation() : string { return $this->actionOrientation; } - /** - * Set Action Orientation. - * - * @param string $actionOrientation - * @return self Provides a fluent interface - */ public function setActionOrientation(string $actionOrientation) : self { $this->actionOrientation = $actionOrientation; return $this; } - /** - * Get Action Timing. - * - * @return string - */ public function getActionTiming() : string { return $this->actionTiming; } - /** - * Set Action Timing. - * - * @param string $actionTiming - * @return self Provides a fluent interface - */ public function setActionTiming(string $actionTiming) : self { $this->actionTiming = $actionTiming; return $this; } - /** - * Get Action Reference Old Table. - * - * @return string - */ public function getActionReferenceOldTable() : string { return $this->actionReferenceOldTable; } - /** - * Set Action Reference Old Table. - * - * @param string $actionReferenceOldTable - * @return self Provides a fluent interface - */ public function setActionReferenceOldTable(string $actionReferenceOldTable) : self { $this->actionReferenceOldTable = $actionReferenceOldTable; return $this; } - /** - * Get Action Reference New Table. - * - * @return string - */ public function getActionReferenceNewTable() : string { return $this->actionReferenceNewTable; } - /** - * Set Action Reference New Table. - * - * @param string $actionReferenceNewTable - * @return self Provides a fluent interface - */ public function setActionReferenceNewTable(string $actionReferenceNewTable) : self { $this->actionReferenceNewTable = $actionReferenceNewTable; return $this; } - /** - * Get Action Reference Old Row. - * - * @return string - */ public function getActionReferenceOldRow() : string { return $this->actionReferenceOldRow; } - /** - * Set Action Reference Old Row. - * - * @param string $actionReferenceOldRow - * @return self Provides a fluent interface - */ public function setActionReferenceOldRow(string $actionReferenceOldRow) : self { $this->actionReferenceOldRow = $actionReferenceOldRow; return $this; } - /** - * Get Action Reference New Row. - * - * @return string - */ public function getActionReferenceNewRow() : string { return $this->actionReferenceNewRow; } - /** - * Set Action Reference New Row. - * - * @param string $actionReferenceNewRow - * @return self Provides a fluent interface - */ public function setActionReferenceNewRow(string $actionReferenceNewRow) : self { $this->actionReferenceNewRow = $actionReferenceNewRow; return $this; } - /** - * Get Created. - * - * @return DateTime - */ public function getCreated(): ?DateTime { return $this->created; } - /** - * Set Created. - * - * @param DateTime $created - * @return self Provides a fluent interface - */ public function setCreated(?DateTime $created) : self { $this->created = $created; diff --git a/src/Metadata/Object/ViewObject.php b/src/Metadata/Object/ViewObject.php index 07bb324e2d..db2bea1226 100644 --- a/src/Metadata/Object/ViewObject.php +++ b/src/Metadata/Object/ViewObject.php @@ -20,63 +20,39 @@ class ViewObject extends AbstractTableObject /** @var bool */ protected $isUpdatable = false; - /** - * @return string $viewDefinition - */ public function getViewDefinition() : string { return $this->viewDefinition; } - /** - * @param string $viewDefinition to set - * @return self Provides a fluent interface - */ public function setViewDefinition(string $viewDefinition) : self { $this->viewDefinition = $viewDefinition; return $this; } - /** - * @return string $checkOption - */ public function getCheckOption() : string { return $this->checkOption; } - /** - * @param string $checkOption to set - * @return self Provides a fluent interface - */ public function setCheckOption(string $checkOption) : self { $this->checkOption = $checkOption; return $this; } - /** - * @return bool $isUpdatable - */ public function getIsUpdatable() : bool { return $this->isUpdatable; } - /** - * @param bool $isUpdatable to set - * @return self Provides a fluent interface - */ public function setIsUpdatable(bool $isUpdatable) : self { $this->isUpdatable = $isUpdatable; return $this; } - /** - * @return bool - */ public function isUpdatable() : bool { return $this->isUpdatable; diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index 2e7a1a5ac0..d334bd7670 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -31,11 +31,6 @@ abstract class AbstractSource implements MetadataInterface /** @var array */ protected $data = []; - /** - * Constructor - * - * @param Adapter $adapter - */ public function __construct(Adapter $adapter) { $this->adapter = $adapter; @@ -52,9 +47,6 @@ public function getSchemas() : array return $this->data['schemas']; } - /** - * {@inheritdoc} - */ public function getTableNames(?string $schema = null, bool $includeViews = false) : array { if ($schema === null) { @@ -76,9 +68,6 @@ public function getTableNames(?string $schema = null, bool $includeViews = false return $tableNames; } - /** - * {@inheritdoc} - */ public function getTables(?string $schema = null, bool $includeViews = false) : array { if ($schema === null) { @@ -92,9 +81,6 @@ public function getTables(?string $schema = null, bool $includeViews = false) : return $tables; } - /** - * {@inheritdoc} - */ public function getTable(string $tableName, ?string $schema = null) : TableObject { if ($schema === null) { @@ -128,9 +114,6 @@ public function getTable(string $tableName, ?string $schema = null) : TableObjec return $table; } - /** - * {@inheritdoc} - */ public function getViewNames(?string $schema = null) : array { if ($schema === null) { @@ -148,9 +131,6 @@ public function getViewNames(?string $schema = null) : array return $viewNames; } - /** - * {@inheritdoc} - */ public function getViews(?string $schema = null) : array { if ($schema === null) { @@ -164,9 +144,6 @@ public function getViews(?string $schema = null) : array return $views; } - /** - * {@inheritdoc} - */ public function getView(string $viewName, ?string $schema = null) : ViewObject { if ($schema === null) { @@ -182,9 +159,6 @@ public function getView(string $viewName, ?string $schema = null) : ViewObject throw new \Exception('View "' . $viewName . '" does not exist'); } - /** - * {@inheritdoc} - */ public function getColumnNames(string $table, ?string $schema = null) : array { if ($schema === null) { @@ -200,9 +174,6 @@ public function getColumnNames(string $table, ?string $schema = null) : array return array_keys($this->data['columns'][$schema][$table]); } - /** - * {@inheritdoc} - */ public function getColumns(string $table, ?string $schema = null) : array { if ($schema === null) { @@ -218,9 +189,6 @@ public function getColumns(string $table, ?string $schema = null) : array return $columns; } - /** - * {@inheritdoc} - */ public function getColumn(string $columnName, string $table, ?string $schema = null) : ColumnObject { if ($schema === null) { @@ -262,9 +230,6 @@ public function getColumn(string $columnName, string $table, ?string $schema = n return $column; } - /** - * {@inheritdoc} - */ public function getConstraints(string $table, ?string $schema = null) : array { if ($schema === null) { @@ -281,9 +246,6 @@ public function getConstraints(string $table, ?string $schema = null) : array return $constraints; } - /** - * {@inheritdoc} - */ public function getConstraint(string $constraintName, string $table, ?string $schema = null) : ConstraintObject { if ($schema === null) { @@ -318,9 +280,6 @@ public function getConstraint(string $constraintName, string $table, ?string $sc return $constraint; } - /** - * {@inheritdoc} - */ public function getConstraintKeys(string $constraint, string $table, ?string $schema = null) : array { if ($schema === null) { @@ -358,9 +317,6 @@ public function getConstraintKeys(string $constraint, string $table, ?string $sc return $keys; } - /** - * {@inheritdoc} - */ public function getTriggerNames(?string $schema = null) : array { if ($schema === null) { @@ -372,9 +328,6 @@ public function getTriggerNames(?string $schema = null) : array return array_keys($this->data['triggers'][$schema]); } - /** - * {@inheritdoc} - */ public function getTriggers(?string $schema = null) : array { if ($schema === null) { @@ -388,9 +341,6 @@ public function getTriggers(?string $schema = null) : array return $triggers; } - /** - * {@inheritdoc} - */ public function getTrigger(string $triggerName, ?string $schema = null) : TriggerObject { if ($schema === null) { @@ -426,11 +376,6 @@ public function getTrigger(string $triggerName, ?string $schema = null) : Trigge return $trigger; } - /** - * Prepare data hierarchy - * - * @param string $type - */ protected function prepareDataHierarchy(string $type) : void { $data = &$this->data; @@ -442,18 +387,10 @@ protected function prepareDataHierarchy(string $type) : void } } - /** - * Load schema data - */ protected function loadSchemaData() : void { } - /** - * Load table name data - * - * @param string $schema - */ protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { @@ -463,12 +400,6 @@ protected function loadTableNameData(string $schema) : void $this->prepareDataHierarchy('table_names', $schema); } - /** - * Load column data - * - * @param string $table - * @param string $schema - */ protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { @@ -478,12 +409,6 @@ protected function loadColumnData(string $table, string $schema) : void $this->prepareDataHierarchy('columns', $schema, $table); } - /** - * Load constraint data - * - * @param string $table - * @param string $schema - */ protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema])) { @@ -493,11 +418,6 @@ protected function loadConstraintData(string $table, string $schema) : void $this->prepareDataHierarchy('constraints', $schema); } - /** - * Load constraint data keys - * - * @param string $schema - */ protected function loadConstraintDataKeys(string $schema) : void { if (isset($this->data['constraint_keys'][$schema])) { @@ -507,12 +427,6 @@ protected function loadConstraintDataKeys(string $schema) : void $this->prepareDataHierarchy('constraint_keys', $schema); } - /** - * Load constraint references - * - * @param string $table - * @param string $schema - */ protected function loadConstraintReferences(string $table, string $schema) : void { if (isset($this->data['constraint_references'][$schema])) { @@ -522,11 +436,6 @@ protected function loadConstraintReferences(string $table, string $schema) : voi $this->prepareDataHierarchy('constraint_references', $schema); } - /** - * Load trigger data - * - * @param string $schema - */ protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { diff --git a/src/Metadata/Source/Factory.php b/src/Metadata/Source/Factory.php index 3104255094..375d3544b8 100644 --- a/src/Metadata/Source/Factory.php +++ b/src/Metadata/Source/Factory.php @@ -18,13 +18,6 @@ */ class Factory { - /** - * Create source from adapter - * - * @param Adapter $adapter - * @return MetadataInterface - * @throws InvalidArgumentException If adapter platform name not recognized. - */ public static function createSourceFromAdapter(Adapter $adapter) : MetadataInterface { $platformName = $adapter->getPlatform()->getName(); diff --git a/src/Metadata/Source/MysqlMetadata.php b/src/Metadata/Source/MysqlMetadata.php index f9f7184806..fee9455127 100644 --- a/src/Metadata/Source/MysqlMetadata.php +++ b/src/Metadata/Source/MysqlMetadata.php @@ -296,11 +296,6 @@ protected function loadConstraintData(string $table, string $schema) : void $this->data['constraints'][$schema][$table] = $constraints; } - /** - * Load constraint data names - * - * @param string $schema - */ protected function loadConstraintDataNames(string $schema) : void { if (isset($this->data['constraint_names'][$schema])) { diff --git a/src/Metadata/Source/OracleMetadata.php b/src/Metadata/Source/OracleMetadata.php index c14532165d..5416debefe 100644 --- a/src/Metadata/Source/OracleMetadata.php +++ b/src/Metadata/Source/OracleMetadata.php @@ -23,10 +23,6 @@ class OracleMetadata extends AbstractSource 'R' => 'FOREIGN_KEY' ]; - /** - * {@inheritdoc} - * @see \Zend\Db\Metadata\Source\AbstractSource::loadColumnData() - */ protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { @@ -75,12 +71,6 @@ protected function loadColumnData(string $table, string $schema) : void $this->data['columns'][$schema][$table] = $columns; } - /** - * Constraint type - * - * @param string $type - * @return string - */ protected function getConstraintType(string $type) : string { if (isset($this->constraintTypeMap[$type])) { @@ -90,10 +80,6 @@ protected function getConstraintType(string $type) : string return $type; } - /** - * {@inheritdoc} - * @see \Zend\Db\Metadata\Source\AbstractSource::loadConstraintData() - */ protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { @@ -170,10 +156,6 @@ protected function loadConstraintData(string $table, string $schema) : void } } - /** - * {@inheritdoc} - * @see \Zend\Db\Metadata\Source\AbstractSource::loadSchemaData() - */ protected function loadSchemaData() : void { if (isset($this->data['schemas'])) { @@ -192,10 +174,6 @@ protected function loadSchemaData() : void $this->data['schemas'] = $schemas; } - /** - * {@inheritdoc} - * @see \Zend\Db\Metadata\Source\AbstractSource::loadTableNameData() - */ protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { @@ -234,10 +212,6 @@ protected function loadTableNameData(string $schema) : void /** * FIXME: load trigger data - * - * {@inheritdoc} - * - * @see \Zend\Db\Metadata\Source\AbstractSource::loadTriggerData() */ protected function loadTriggerData(string $schema) : void { diff --git a/src/Metadata/Source/SqliteMetadata.php b/src/Metadata/Source/SqliteMetadata.php index a66a91b431..3f21c3a248 100644 --- a/src/Metadata/Source/SqliteMetadata.php +++ b/src/Metadata/Source/SqliteMetadata.php @@ -246,14 +246,6 @@ protected function loadTriggerData(string $schema) : void $this->data['triggers'][$schema] = $triggers; } - /** - * Fetch pragma - * - * @param string $name - * @param string|null $value - * @param string|null $schema - * @return array - */ protected function fetchPragma(string $name, ?string $value = null, ?string $schema = null) : array { $p = $this->adapter->getPlatform(); @@ -276,12 +268,6 @@ protected function fetchPragma(string $name, ?string $value = null, ?string $sch return []; } - /** - * Parse view - * - * @param string $sql - * @return array|void - */ protected function parseView(string $sql) : ?array { static $re = null; @@ -307,12 +293,6 @@ protected function parseView(string $sql) : ?array ]; } - /** - * Parse trigger - * - * @param string $sql - * @return array|null - */ protected function parseTrigger(string $sql) : ?array { static $re = null; @@ -371,10 +351,6 @@ protected function parseTrigger(string $sql) : ?array return $data; } - /** - * @param array $re - * @return string|null - */ protected function buildRegularExpression(array $re) : ?string { foreach ($re as &$value) { @@ -389,9 +365,6 @@ protected function buildRegularExpression(array $re) : ?string return $re; } - /** - * @return string|null - */ protected function getIdentifierRegularExpression() : ?string { static $re = null; @@ -407,9 +380,6 @@ protected function getIdentifierRegularExpression() : ?string return $re; } - /** - * @return string|null - */ protected function getIdentifierChainRegularExpression() : ?string { static $re = null; @@ -420,9 +390,6 @@ protected function getIdentifierChainRegularExpression() : ?string return $re; } - /** - * @return string|null - */ protected function getIdentifierListRegularExpression() : ?string { static $re = null;