diff --git a/3.0.0.md b/3.0.0.md index b1c3abfb90..4f7af77cec 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 + +`parseView()` and `parseTrigger()` now possibly return `array|null` instead of `array|void` 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 ''; diff --git a/src/Metadata/Metadata.php b/src/Metadata/Metadata.php index c00cdfcf83..386b73cf0f 100644 --- a/src/Metadata/Metadata.php +++ b/src/Metadata/Metadata.php @@ -1,160 +1,110 @@ source = Source\Factory::createSourceFromAdapter($adapter); } - /** - * {@inheritdoc} - */ - public function getTables($schema = null, $includeViews = false) + public function getTables(?string $schema = null, bool $includeViews = false) : array { return $this->source->getTables($schema, $includeViews); } - /** - * {@inheritdoc} - */ - public function getViews($schema = null) + public function getViews(?string $schema = null) : array { return $this->source->getViews($schema); } - /** - * {@inheritdoc} - */ - public function getTriggers($schema = null) + public function getTriggers(?string $schema = null) : array { return $this->source->getTriggers($schema); } - /** - * {@inheritdoc} - */ - public function getConstraints($table, $schema = null) + public function getConstraints(string $table, ?string $schema = null) : array { return $this->source->getConstraints($table, $schema); } - /** - * {@inheritdoc} - */ - public function getColumns($table, $schema = null) + public function getColumns(string $table, ?string $schema = null) : array { return $this->source->getColumns($table, $schema); } - /** - * {@inheritdoc} - */ - public function getConstraintKeys($constraint, $table, $schema = null) + public function getConstraintKeys($constraint, $table, ?string $schema = null) : array { return $this->source->getConstraintKeys($constraint, $table, $schema); } - /** - * {@inheritdoc} - */ - public function getConstraint($constraintName, $table, $schema = null) + public function getConstraint($constraintName, $table, ?string $schema = null) : ConstraintObject { return $this->source->getConstraint($constraintName, $table, $schema); } - /** - * {@inheritdoc} - */ - public function getSchemas() + public function getSchemas() : array { return $this->source->getSchemas(); } - /** - * {@inheritdoc} - */ - public function getTableNames($schema = null, $includeViews = false) + public function getTableNames(?string $schema = null, bool $includeViews = false) : array { return $this->source->getTableNames($schema, $includeViews); } - /** - * {@inheritdoc} - */ - public function getTable($tableName, $schema = null) + public function getTable($tableName, ?string $schema = null) : TableObject { return $this->source->getTable($tableName, $schema); } - /** - * {@inheritdoc} - */ - public function getViewNames($schema = null) + public function getViewNames(?string $schema = null) : array { return $this->source->getViewNames($schema); } - /** - * {@inheritdoc} - */ - public function getView($viewName, $schema = null) + public function getView($viewName, ?string $schema = null) : ViewObject { return $this->source->getView($viewName, $schema); } - /** - * {@inheritdoc} - */ - public function getTriggerNames($schema = null) + public function getTriggerNames(?string $schema = null) : array { return $this->source->getTriggerNames($schema); } - /** - * {@inheritdoc} - */ - public function getTrigger($triggerName, $schema = null) + public function getTrigger($triggerName, ?string $schema = null) : TriggerObject { return $this->source->getTrigger($triggerName, $schema); } - /** - * {@inheritdoc} - */ - public function getColumnNames($table, $schema = null) + public function getColumnNames(string $table, ?string $schema = null) : array { return $this->source->getColumnNames($table, $schema); } - /** - * {@inheritdoc} - */ - public function getColumn($columnName, $table, $schema = null) + public function getColumn($columnName, $table, ?string $schema = null) : ColumnObject { return $this->source->getColumn($columnName, $table, $schema); } diff --git a/src/Metadata/MetadataInterface.php b/src/Metadata/MetadataInterface.php index 5a395be2da..0a0c536566 100644 --- a/src/Metadata/MetadataInterface.php +++ b/src/Metadata/MetadataInterface.php @@ -1,14 +1,21 @@ setName($name); - } + $this->setName($name); } - /** - * Set columns - * - * @param array $columns - */ - public function setColumns(array $columns) + public function setColumns(array $columns) : void { $this->columns = $columns; } - /** - * Get columns - * - * @return array - */ - public function getColumns() + public function getColumns() : array { return $this->columns; } - /** - * Set constraints - * - * @param array $constraints - */ - public function setConstraints($constraints) + public function setConstraints(array $constraints) : void { $this->constraints = $constraints; } - /** - * Get constraints - * - * @return array - */ - public function getConstraints() + public function getConstraints() : array { return $this->constraints; } - /** - * Set name - * - * @param string $name - */ - public function setName($name) + public function setName(string $name) : void { $this->name = $name; } - /** - * Get 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 f377119b0d..729a45e926 100644 --- a/src/Metadata/Object/ColumnObject.php +++ b/src/Metadata/Object/ColumnObject.php @@ -1,361 +1,208 @@ setName($name); $this->setTableName($tableName); $this->setSchemaName($schemaName); } - /** - * Set name - * - * @param string $name - */ - public function setName($name) + public function setName(string $name) : void { $this->name = $name; } - /** - * Get name - * - * @return string - */ - public function getName() + public function getName() : string { return $this->name; } - /** - * Get table name - * - * @return string - */ - public function getTableName() + public function getTableName() : string { return $this->tableName; } - /** - * Set table name - * - * @param string $tableName - * @return self Provides a fluent interface - */ - public function setTableName($tableName) + public function setTableName(string $tableName) : self { $this->tableName = $tableName; return $this; } - /** - * Set schema name - * - * @param string $schemaName - */ - public function setSchemaName($schemaName) + public function setSchemaName(string $schemaName) : void { $this->schemaName = $schemaName; } - /** - * Get schema name - * - * @return string - */ - public function getSchemaName() + public function getSchemaName() : string { return $this->schemaName; } - /** - * @return int $ordinalPosition - */ - public function getOrdinalPosition() + public function getOrdinalPosition() : ?int { return $this->ordinalPosition; } - /** - * @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; } - /** - * @return null|string the $columnDefault - */ - public function getColumnDefault() + public function getColumnDefault() : ?string { return $this->columnDefault; } - /** - * @param mixed $columnDefault to set - * @return self Provides a fluent interface - */ - public function setColumnDefault($columnDefault) + public function setColumnDefault(string $columnDefault) : self { $this->columnDefault = $columnDefault; return $this; } - /** - * @return bool $isNullable - */ - public function getIsNullable() + public function getIsNullable() : bool { return $this->isNullable; } - /** - * @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; } - /** - * @return bool $isNullable - */ - public function isNullable() + public function isNullable() : bool { return $this->isNullable; } - /** - * @return null|string the $dataType - */ - public function getDataType() + public function getDataType() : ?string { return $this->dataType; } - /** - * @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; } - /** - * @return int|null the $characterMaximumLength - */ - public function getCharacterMaximumLength() + public function getCharacterMaximumLength() : ?int { return $this->characterMaximumLength; } - /** - * @param int $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; } - /** - * @return int|null the $characterOctetLength - */ - public function getCharacterOctetLength() + public function getCharacterOctetLength() : ?int { return $this->characterOctetLength; } - /** - * @param int $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; } - /** - * @return int the $numericPrecision - */ - public function getNumericPrecision() + public function getNumericPrecision() : ?int { return $this->numericPrecision; } - /** - * @param int $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; } - /** - * @return int the $numericScale - */ - public function getNumericScale() + public function getNumericScale() : ?int { return $this->numericScale; } - /** - * @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; } - /** - * @return bool - */ - public function getNumericUnsigned() + public function getNumericUnsigned() : bool { return $this->numericUnsigned; } - /** - * @param bool $numericUnsigned - * @return self Provides a fluent interface - */ - public function setNumericUnsigned($numericUnsigned) + public function setNumericUnsigned(bool $numericUnsigned) : self { $this->numericUnsigned = $numericUnsigned; return $this; } - /** - * @return bool - */ - public function isNumericUnsigned() + public function isNumericUnsigned() : bool { return $this->numericUnsigned; } - /** - * @return array the $errata - */ - public function getErratas() + public function getErratas() : array { return $this->errata; } - /** - * @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); @@ -363,24 +210,14 @@ public function setErratas(array $erratas) return $this; } - /** - * @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; } - /** - * @param string $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 9bed4bff20..1e3f819b85 100644 --- a/src/Metadata/Object/ConstraintKeyObject.php +++ b/src/Metadata/Object/ConstraintKeyObject.php @@ -1,248 +1,133 @@ setColumnName($column); } - /** - * Get column name - * - * @return string - */ - public function getColumnName() + public function getColumnName() : string { return $this->columnName; } - /** - * Set column name - * - * @param string $columnName - * @return self Provides a fluent interface - */ - public function setColumnName($columnName) + public function setColumnName(string $columnName) : self { $this->columnName = $columnName; return $this; } - /** - * Get ordinal position - * - * @return int - */ - public function getOrdinalPosition() + public function getOrdinalPosition() : ?int { return $this->ordinalPosition; } - /** - * Set ordinal position - * - * @param int $ordinalPosition - * @return self Provides a fluent interface - */ - public function setOrdinalPosition($ordinalPosition) + public function setOrdinalPosition($ordinalPosition) : self { $this->ordinalPosition = $ordinalPosition; return $this; } - /** - * Get position in unique constraint - * - * @return bool - */ - public function getPositionInUniqueConstraint() + public function getPositionInUniqueConstraint() : bool { return $this->positionInUniqueConstraint; } - /** - * Set position in unique constraint - * - * @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 - * - * @return string - */ - public function getReferencedTableSchema() + public function getReferencedTableSchema() : string { return $this->referencedTableSchema; } - /** - * Set referenced table schema - * - * @param string $referencedTableSchema - * @return self Provides a fluent interface - */ - public function setReferencedTableSchema($referencedTableSchema) + public function setReferencedTableSchema($referencedTableSchema) : self { $this->referencedTableSchema = $referencedTableSchema; return $this; } - /** - * Get referenced table name - * - * @return string - */ - public function getReferencedTableName() + public function getReferencedTableName() : string { return $this->referencedTableName; } - /** - * Set Referenced table name - * - * @param string $referencedTableName - * @return self Provides a fluent interface - */ - public function setReferencedTableName($referencedTableName) + public function setReferencedTableName(string $referencedTableName) : self { $this->referencedTableName = $referencedTableName; return $this; } - /** - * Get referenced column name - * - * @return string - */ - public function getReferencedColumnName() + public function getReferencedColumnName() : string { return $this->referencedColumnName; } - /** - * Set referenced column name - * - * @param string $referencedColumnName - * @return self Provides a fluent interface - */ - public function setReferencedColumnName($referencedColumnName) + public function setReferencedColumnName(string $referencedColumnName) : self { $this->referencedColumnName = $referencedColumnName; return $this; } - /** - * set foreign key update rule - * - * @param string $foreignKeyUpdateRule - */ - public function setForeignKeyUpdateRule($foreignKeyUpdateRule) + public function setForeignKeyUpdateRule($foreignKeyUpdateRule) : void { $this->foreignKeyUpdateRule = $foreignKeyUpdateRule; } - /** - * Get foreign key update rule - * - * @return string - */ - public function getForeignKeyUpdateRule() + public function getForeignKeyUpdateRule() : string { return $this->foreignKeyUpdateRule; } - /** - * Set foreign key delete rule - * - * @param string $foreignKeyDeleteRule - */ - public function setForeignKeyDeleteRule($foreignKeyDeleteRule) + public function setForeignKeyDeleteRule($foreignKeyDeleteRule) : void { $this->foreignKeyDeleteRule = $foreignKeyDeleteRule; } - /** - * get foreign key delete rule - * - * @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 15f79729d5..32c41b7778 100644 --- a/src/Metadata/Object/ConstraintObject.php +++ b/src/Metadata/Object/ConstraintObject.php @@ -1,411 +1,214 @@ setName($name); $this->setTableName($tableName); $this->setSchemaName($schemaName); } - /** - * Set name - * - * @param string $name - */ - public function setName($name) + public function setName(string $name) : void { $this->name = $name; } - /** - * Get name - * - * @return string - */ - public function getName() + public function getName() : string { return $this->name; } - /** - * Set schema name - * - * @param string $schemaName - */ - public function setSchemaName($schemaName) + public function setSchemaName($schemaName) : void { $this->schemaName = $schemaName; } - /** - * Get schema name - * - * @return string - */ - public function getSchemaName() + public function getSchemaName() : string { return $this->schemaName; } - /** - * Get table name - * - * @return string - */ - public function getTableName() + public function getTableName() : string { return $this->tableName; } - /** - * Set table name - * - * @param string $tableName - * @return self Provides a fluent interface - */ - public function setTableName($tableName) + public function setTableName($tableName) : self { $this->tableName = $tableName; return $this; } - /** - * Set type - * - * @param string $type - */ - public function setType($type) + public function setType($type) : void { $this->type = $type; } - /** - * Get type - * - * @return string - */ - public function getType() + public function getType() : string { return $this->type; } - public function hasColumns() + public function hasColumns() : bool { - return (! empty($this->columns)); + return ! empty($this->columns); } - /** - * Get Columns. - * - * @return string[] - */ - public function getColumns() + public function getColumns() : array { return $this->columns; } - /** - * Set Columns. - * - * @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; } - /** - * Get Referenced Table Schema. - * - * @return string - */ - public function getReferencedTableSchema() + public function getReferencedTableSchema() : string { return $this->referencedTableSchema; } - /** - * Set Referenced Table Schema. - * - * @param string $referencedTableSchema - * @return self Provides a fluent interface - */ - public function setReferencedTableSchema($referencedTableSchema) + public function setReferencedTableSchema($referencedTableSchema) : self { $this->referencedTableSchema = $referencedTableSchema; return $this; } - /** - * Get Referenced Table Name. - * - * @return string - */ - public function getReferencedTableName() + public function getReferencedTableName() : string { return $this->referencedTableName; } - /** - * Set Referenced Table Name. - * - * @param string $referencedTableName - * @return self Provides a fluent interface - */ - public function setReferencedTableName($referencedTableName) + public function setReferencedTableName($referencedTableName) : self { $this->referencedTableName = $referencedTableName; return $this; } - /** - * Get Referenced Columns. - * - * @return string[] - */ - public function getReferencedColumns() + public function getReferencedColumns() : array { return $this->referencedColumns; } - /** - * Set Referenced Columns. - * - * @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; } - /** - * Get Match Option. - * - * @return string - */ - public function getMatchOption() + public function getMatchOption() : string { return $this->matchOption; } - /** - * Set Match Option. - * - * @param string $matchOption - * @return self Provides a fluent interface - */ - public function setMatchOption($matchOption) + public function setMatchOption($matchOption) : self { $this->matchOption = $matchOption; return $this; } - /** - * Get Update Rule. - * - * @return string - */ - public function getUpdateRule() + public function getUpdateRule() : string { return $this->updateRule; } - /** - * Set Update Rule. - * - * @param string $updateRule - * @return self Provides a fluent interface - */ - public function setUpdateRule($updateRule) + public function setUpdateRule($updateRule) : self { $this->updateRule = $updateRule; return $this; } - /** - * Get Delete Rule. - * - * @return string - */ - public function getDeleteRule() + public function getDeleteRule() : string { return $this->deleteRule; } - /** - * Set Delete Rule. - * - * @param string $deleteRule - * @return self Provides a fluent interface - */ - public function setDeleteRule($deleteRule) + public function setDeleteRule($deleteRule) : self { $this->deleteRule = $deleteRule; return $this; } - /** - * Get Check Clause. - * - * @return string - */ - public function getCheckClause() + public function getCheckClause() : string { return $this->checkClause; } - /** - * Set Check Clause. - * - * @param string $checkClause - * @return self Provides a fluent interface - */ - public function setCheckClause($checkClause) + public function setCheckClause($checkClause) : self { $this->checkClause = $checkClause; return $this; } - /** - * Is primary key - * - * @return bool - */ - public function isPrimaryKey() + public function isPrimaryKey() : bool { - return ('PRIMARY KEY' == $this->type); + return ('PRIMARY KEY' === $this->type); } - /** - * Is unique key - * - * @return bool - */ - public function isUnique() + public function isUnique() : bool { - return ('UNIQUE' == $this->type); + return ('UNIQUE' === $this->type); } - /** - * Is foreign key - * - * @return bool - */ - public function isForeignKey() + public function isForeignKey() : bool { - return ('FOREIGN KEY' == $this->type); + return ('FOREIGN KEY' === $this->type); } - /** - * Is foreign key - * - * @return bool - */ - public function isCheck() + public function isCheck() : bool { - return ('CHECK' == $this->type); + return ('CHECK' === $this->type); } } diff --git a/src/Metadata/Object/TableObject.php b/src/Metadata/Object/TableObject.php index 291796ea77..8c49b6ff46 100644 --- a/src/Metadata/Object/TableObject.php +++ b/src/Metadata/Object/TableObject.php @@ -1,12 +1,12 @@ name; } - /** - * Set Name. - * - * @param string $name - * @return self Provides a fluent interface - */ - public function setName($name) + public function setName(string $name) : self { $this->name = $name; return $this; } - /** - * Get Event Manipulation. - * - * @return string - */ - public function getEventManipulation() + public function getEventManipulation() : string { return $this->eventManipulation; } - /** - * Set Event Manipulation. - * - * @param string $eventManipulation - * @return self Provides a fluent interface - */ - public function setEventManipulation($eventManipulation) + public function setEventManipulation(string $eventManipulation) : self { $this->eventManipulation = $eventManipulation; return $this; } - /** - * Get Event Object Catalog. - * - * @return string - */ - public function getEventObjectCatalog() + public function getEventObjectCatalog() : string { return $this->eventObjectCatalog; } - /** - * Set Event Object Catalog. - * - * @param string $eventObjectCatalog - * @return self Provides a fluent interface - */ - public function setEventObjectCatalog($eventObjectCatalog) + public function setEventObjectCatalog(string $eventObjectCatalog) : self { $this->eventObjectCatalog = $eventObjectCatalog; return $this; } - /** - * Get Event Object Schema. - * - * @return string - */ - public function getEventObjectSchema() + public function getEventObjectSchema() : string { return $this->eventObjectSchema; } - /** - * Set Event Object Schema. - * - * @param string $eventObjectSchema - * @return self Provides a fluent interface - */ - public function setEventObjectSchema($eventObjectSchema) + public function setEventObjectSchema(string $eventObjectSchema) : self { $this->eventObjectSchema = $eventObjectSchema; return $this; } - /** - * Get Event Object Table. - * - * @return string - */ - public function getEventObjectTable() + public function getEventObjectTable() : string { return $this->eventObjectTable; } - /** - * Set Event Object Table. - * - * @param string $eventObjectTable - * @return self Provides a fluent interface - */ - public function setEventObjectTable($eventObjectTable) + public function setEventObjectTable(string $eventObjectTable) : self { $this->eventObjectTable = $eventObjectTable; return $this; } - /** - * Get Action Order. - * - * @return string - */ - public function getActionOrder() + public function getActionOrder() : string { return $this->actionOrder; } - /** - * Set Action Order. - * - * @param string $actionOrder - * @return self Provides a fluent interface - */ - public function setActionOrder($actionOrder) + public function setActionOrder(string $actionOrder) : self { $this->actionOrder = $actionOrder; return $this; } - /** - * Get Action Condition. - * - * @return string - */ - public function getActionCondition() + public function getActionCondition() : string { return $this->actionCondition; } - /** - * Set Action Condition. - * - * @param string $actionCondition - * @return self Provides a fluent interface - */ - public function setActionCondition($actionCondition) + public function setActionCondition(string $actionCondition) : self { $this->actionCondition = $actionCondition; return $this; } - /** - * Get Action Statement. - * - * @return string - */ - public function getActionStatement() + public function getActionStatement() : string { return $this->actionStatement; } - /** - * Set Action Statement. - * - * @param string $actionStatement - * @return self Provides a fluent interface - */ - public function setActionStatement($actionStatement) + public function setActionStatement(string $actionStatement) : self { $this->actionStatement = $actionStatement; return $this; } - /** - * Get Action Orientation. - * - * @return string - */ - public function getActionOrientation() + public function getActionOrientation() : string { return $this->actionOrientation; } - /** - * Set Action Orientation. - * - * @param string $actionOrientation - * @return self Provides a fluent interface - */ - public function setActionOrientation($actionOrientation) + public function setActionOrientation(string $actionOrientation) : self { $this->actionOrientation = $actionOrientation; return $this; } - /** - * Get Action Timing. - * - * @return string - */ - public function getActionTiming() + public function getActionTiming() : string { return $this->actionTiming; } - /** - * Set Action Timing. - * - * @param string $actionTiming - * @return self Provides a fluent interface - */ - public function setActionTiming($actionTiming) + public function setActionTiming(string $actionTiming) : self { $this->actionTiming = $actionTiming; return $this; } - /** - * Get Action Reference Old Table. - * - * @return string - */ - public function getActionReferenceOldTable() + public function getActionReferenceOldTable() : string { return $this->actionReferenceOldTable; } - /** - * Set Action Reference Old Table. - * - * @param string $actionReferenceOldTable - * @return self Provides a fluent interface - */ - public function setActionReferenceOldTable($actionReferenceOldTable) + public function setActionReferenceOldTable(string $actionReferenceOldTable) : self { $this->actionReferenceOldTable = $actionReferenceOldTable; return $this; } - /** - * Get Action Reference New Table. - * - * @return string - */ - public function getActionReferenceNewTable() + public function getActionReferenceNewTable() : string { return $this->actionReferenceNewTable; } - /** - * Set Action Reference New Table. - * - * @param string $actionReferenceNewTable - * @return self Provides a fluent interface - */ - public function setActionReferenceNewTable($actionReferenceNewTable) + public function setActionReferenceNewTable(string $actionReferenceNewTable) : self { $this->actionReferenceNewTable = $actionReferenceNewTable; return $this; } - /** - * Get Action Reference Old Row. - * - * @return string - */ - public function getActionReferenceOldRow() + public function getActionReferenceOldRow() : string { return $this->actionReferenceOldRow; } - /** - * Set Action Reference Old Row. - * - * @param string $actionReferenceOldRow - * @return self Provides a fluent interface - */ - public function setActionReferenceOldRow($actionReferenceOldRow) + public function setActionReferenceOldRow(string $actionReferenceOldRow) : self { $this->actionReferenceOldRow = $actionReferenceOldRow; return $this; } - /** - * Get Action Reference New Row. - * - * @return string - */ - public function getActionReferenceNewRow() + public function getActionReferenceNewRow() : string { return $this->actionReferenceNewRow; } - /** - * Set Action Reference New Row. - * - * @param string $actionReferenceNewRow - * @return self Provides a fluent interface - */ - public function setActionReferenceNewRow($actionReferenceNewRow) + public function setActionReferenceNewRow(string $actionReferenceNewRow) : self { $this->actionReferenceNewRow = $actionReferenceNewRow; return $this; } - /** - * Get Created. - * - * @return \DateTime - */ - public function getCreated() + public function getCreated(): ?DateTime { return $this->created; } - /** - * Set 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 e0b5bde10c..db2bea1226 100644 --- a/src/Metadata/Object/ViewObject.php +++ b/src/Metadata/Object/ViewObject.php @@ -1,75 +1,59 @@ viewDefinition; } - /** - * @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; } - /** - * @return string $checkOption - */ - public function getCheckOption() + public function getCheckOption() : string { return $this->checkOption; } - /** - * @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; } - /** - * @return bool $isUpdatable - */ - public function getIsUpdatable() + public function getIsUpdatable() : bool { return $this->isUpdatable; } - /** - * @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 0bd5c162e3..d334bd7670 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -1,12 +1,12 @@ adapter = $adapter; - $this->defaultSchema = ($adapter->getCurrentSchema()) ?: self::DEFAULT_SCHEMA; + $this->defaultSchema = $adapter->getCurrentSchema() ?: self::DEFAULT_SCHEMA; } /** - * Get schemas - * + * @inheritdoc */ - public function getSchemas() + public function getSchemas() : array { $this->loadSchemaData(); return $this->data['schemas']; } - /** - * {@inheritdoc} - */ - public function getTableNames($schema = null, $includeViews = false) + public function getTableNames(?string $schema = null, bool $includeViews = false) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -79,17 +61,14 @@ public function getTableNames($schema = null, $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; } } return $tableNames; } - /** - * {@inheritdoc} - */ - public function getTables($schema = null, $includeViews = false) + public function getTables(?string $schema = null, bool $includeViews = false) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -102,10 +81,7 @@ public function getTables($schema = null, $includeViews = false) return $tables; } - /** - * {@inheritdoc} - */ - public function getTable($tableName, $schema = null) + public function getTable(string $tableName, ?string $schema = null) : TableObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -138,10 +114,7 @@ public function getTable($tableName, $schema = null) return $table; } - /** - * {@inheritdoc} - */ - public function getViewNames($schema = null) + public function getViewNames(?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -151,17 +124,14 @@ public function getViewNames($schema = null) $viewNames = []; foreach ($this->data['table_names'][$schema] as $tableName => $data) { - if ('VIEW' == $data['table_type']) { + if ('VIEW' === $data['table_type']) { $viewNames[] = $tableName; } } return $viewNames; } - /** - * {@inheritdoc} - */ - public function getViews($schema = null) + public function getViews(?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -174,10 +144,7 @@ public function getViews($schema = null) return $views; } - /** - * {@inheritdoc} - */ - public function getView($viewName, $schema = null) + public function getView(string $viewName, ?string $schema = null) : ViewObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -186,16 +153,13 @@ public function getView($viewName, $schema = null) $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'); } - /** - * {@inheritdoc} - */ - public function getColumnNames($table, $schema = null) + public function getColumnNames(string $table, ?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -210,10 +174,7 @@ public function getColumnNames($table, $schema = null) return array_keys($this->data['columns'][$schema][$table]); } - /** - * {@inheritdoc} - */ - public function getColumns($table, $schema = null) + public function getColumns(string $table, ?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -228,10 +189,7 @@ public function getColumns($table, $schema = null) return $columns; } - /** - * {@inheritdoc} - */ - public function getColumn($columnName, $table, $schema = null) + public function getColumn(string $columnName, string $table, ?string $schema = null) : ColumnObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -272,10 +230,7 @@ public function getColumn($columnName, $table, $schema = null) return $column; } - /** - * {@inheritdoc} - */ - public function getConstraints($table, $schema = null) + public function getConstraints(string $table, ?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -291,10 +246,7 @@ public function getConstraints($table, $schema = null) return $constraints; } - /** - * {@inheritdoc} - */ - public function getConstraint($constraintName, $table, $schema = null) + public function getConstraint(string $constraintName, string $table, ?string $schema = null) : ConstraintObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -328,10 +280,7 @@ public function getConstraint($constraintName, $table, $schema = null) return $constraint; } - /** - * {@inheritdoc} - */ - public function getConstraintKeys($constraint, $table, $schema = null) + public function getConstraintKeys(string $constraint, string $table, ?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -342,7 +291,7 @@ public function getConstraintKeys($constraint, $table, $schema = null) // 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; } } @@ -351,7 +300,7 @@ public function getConstraintKeys($constraint, $table, $schema = null) $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])) { @@ -368,10 +317,7 @@ public function getConstraintKeys($constraint, $table, $schema = null) return $keys; } - /** - * {@inheritdoc} - */ - public function getTriggerNames($schema = null) + public function getTriggerNames(?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -382,10 +328,7 @@ public function getTriggerNames($schema = null) return array_keys($this->data['triggers'][$schema]); } - /** - * {@inheritdoc} - */ - public function getTriggers($schema = null) + public function getTriggers(?string $schema = null) : array { if ($schema === null) { $schema = $this->defaultSchema; @@ -398,10 +341,7 @@ public function getTriggers($schema = null) return $triggers; } - /** - * {@inheritdoc} - */ - public function getTrigger($triggerName, $schema = null) + public function getTrigger(string $triggerName, ?string $schema = null) : TriggerObject { if ($schema === null) { $schema = $this->defaultSchema; @@ -436,13 +376,7 @@ public function getTrigger($triggerName, $schema = null) return $trigger; } - /** - * Prepare data hierarchy - * - * @param string $type - * @param string $key ... - */ - protected function prepareDataHierarchy($type) + protected function prepareDataHierarchy(string $type) : void { $data = &$this->data; foreach (func_get_args() as $key) { @@ -453,19 +387,11 @@ protected function prepareDataHierarchy($type) } } - /** - * Load schema data - */ - protected function loadSchemaData() + protected function loadSchemaData() : void { } - /** - * Load table name data - * - * @param string $schema - */ - protected function loadTableNameData($schema) + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -474,13 +400,7 @@ protected function loadTableNameData($schema) $this->prepareDataHierarchy('table_names', $schema); } - /** - * Load column data - * - * @param string $table - * @param string $schema - */ - protected function loadColumnData($table, $schema) + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -489,13 +409,7 @@ protected function loadColumnData($table, $schema) $this->prepareDataHierarchy('columns', $schema, $table); } - /** - * Load constraint data - * - * @param string $table - * @param string $schema - */ - protected function loadConstraintData($table, $schema) + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema])) { return; @@ -504,12 +418,7 @@ protected function loadConstraintData($table, $schema) $this->prepareDataHierarchy('constraints', $schema); } - /** - * Load constraint data keys - * - * @param string $schema - */ - protected function loadConstraintDataKeys($schema) + protected function loadConstraintDataKeys(string $schema) : void { if (isset($this->data['constraint_keys'][$schema])) { return; @@ -518,13 +427,7 @@ protected function loadConstraintDataKeys($schema) $this->prepareDataHierarchy('constraint_keys', $schema); } - /** - * Load constraint references - * - * @param string $table - * @param string $schema - */ - protected function loadConstraintReferences($table, $schema) + protected function loadConstraintReferences(string $table, string $schema) : void { if (isset($this->data['constraint_references'][$schema])) { return; @@ -533,12 +436,7 @@ protected function loadConstraintReferences($table, $schema) $this->prepareDataHierarchy('constraint_references', $schema); } - /** - * Load trigger data - * - * @param string $schema - */ - protected function loadTriggerData($schema) + 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 fb8ec71858..375d3544b8 100644 --- a/src/Metadata/Source/Factory.php +++ b/src/Metadata/Source/Factory.php @@ -1,12 +1,12 @@ getPlatform()->getName(); diff --git a/src/Metadata/Source/MysqlMetadata.php b/src/Metadata/Source/MysqlMetadata.php index c366fe9971..fee9455127 100644 --- a/src/Metadata/Source/MysqlMetadata.php +++ b/src/Metadata/Source/MysqlMetadata.php @@ -1,19 +1,22 @@ data['schemas'])) { return; @@ -37,7 +40,10 @@ protected function loadSchemaData() $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) + /** + * @inheritdoc + */ + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -70,7 +76,7 @@ protected function loadTableNameData($schema) . ' 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,14 +92,17 @@ protected function loadTableNameData($schema) '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'], ]; } $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) + /** + * @inheritdoc + */ + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -130,7 +139,7 @@ protected function loadColumnData($table, $schema) . ' 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,13 +170,13 @@ protected function loadColumnData($table, $schema) $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, ]; } @@ -175,7 +184,10 @@ protected function loadColumnData($table, $schema) $this->data['columns'][$schema][$table] = $columns; } - protected function loadConstraintData($table, $schema) + /** + * @inheritdoc + */ + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -230,7 +242,7 @@ protected function loadConstraintData($table, $schema) . ' 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 +266,7 @@ protected function loadConstraintData($table, $schema) 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 { @@ -284,7 +296,7 @@ protected function loadConstraintData($table, $schema) $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadConstraintDataNames($schema) + protected function loadConstraintDataNames(string $schema) : void { if (isset($this->data['constraint_names'][$schema])) { return; @@ -314,7 +326,7 @@ protected function loadConstraintDataNames($schema) . ' 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 { @@ -332,7 +344,10 @@ protected function loadConstraintDataNames($schema) $this->data['constraint_names'][$schema] = $data; } - protected function loadConstraintDataKeys($schema) + /** + * @inheritdoc + */ + protected function loadConstraintDataKeys(string $schema) : void { if (isset($this->data['constraint_keys'][$schema])) { return; @@ -365,7 +380,7 @@ protected function loadConstraintDataKeys($schema) . ' 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 { @@ -383,7 +398,10 @@ protected function loadConstraintDataKeys($schema) $this->data['constraint_keys'][$schema] = $data; } - protected function loadConstraintReferences($table, $schema) + /** + * @inheritdoc + */ + protected function loadConstraintReferences(string $table, string $schema) : void { parent::loadConstraintReferences($table, $schema); @@ -423,7 +441,7 @@ protected function loadConstraintReferences($table, $schema) . '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 { @@ -441,7 +459,10 @@ protected function loadConstraintReferences($table, $schema) $this->data['constraint_references'][$schema] = $data; } - protected function loadTriggerData($schema) + /** + * @inheritdoc + */ + protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { return; @@ -479,7 +500,7 @@ protected function loadTriggerData($schema) . ' 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 0ffa743d28..5416debefe 100644 --- a/src/Metadata/Source/OracleMetadata.php +++ b/src/Metadata/Source/OracleMetadata.php @@ -1,12 +1,12 @@ 'CHECK', 'P' => 'PRIMARY KEY', 'R' => 'FOREIGN_KEY' ]; - /** - * {@inheritdoc} - * @see \Zend\Db\Metadata\Source\AbstractSource::loadColumnData() - */ - protected function loadColumnData($table, $schema) + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -63,7 +57,7 @@ protected function loadColumnData($table, $schema) $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, @@ -75,16 +69,9 @@ protected function loadColumnData($table, $schema) } $this->data['columns'][$schema][$table] = $columns; - return $this; } - /** - * Constraint type - * - * @param string $type - * @return string - */ - protected function getConstraintType($type) + protected function getConstraintType(string $type) : string { if (isset($this->constraintTypeMap[$type])) { return $this->constraintTypeMap[$type]; @@ -93,11 +80,7 @@ protected function getConstraintType($type) return $type; } - /** - * {@inheritdoc} - * @see \Zend\Db\Metadata\Source\AbstractSource::loadConstraintData() - */ - protected function loadConstraintData($table, $schema) + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -148,14 +131,14 @@ protected function loadConstraintData($table, $schema) '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']; @@ -171,15 +154,9 @@ 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; @@ -197,14 +174,10 @@ protected function loadSchemaData() $this->data['schemas'] = $schemas; } - /** - * {@inheritdoc} - * @see \Zend\Db\Metadata\Source\AbstractSource::loadTableNameData() - */ - protected function loadTableNameData($schema) + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { - return $this; + return; } $this->prepareDataHierarchy('table_names', $schema); @@ -235,17 +208,12 @@ protected function loadTableNameData($schema) } $this->data['table_names'][$schema] = $tables; - return $this; } /** * FIXME: load trigger data - * - * {@inheritdoc} - * - * @see \Zend\Db\Metadata\Source\AbstractSource::loadTriggerData() */ - protected function loadTriggerData($schema) + 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 8b43c7ef30..316abe5f21 100644 --- a/src/Metadata/Source/PostgresqlMetadata.php +++ b/src/Metadata/Source/PostgresqlMetadata.php @@ -1,19 +1,22 @@ data['schemas'])) { return; @@ -38,7 +41,10 @@ protected function loadSchemaData() $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) + /** + * @inheritdoc + */ + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -71,7 +77,7 @@ protected function loadTableNameData($schema) . ' 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,14 +93,17 @@ protected function loadTableNameData($schema) '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'], ]; } $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) + /** + * @inheritdoc + */ + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -129,7 +138,7 @@ protected function loadColumnData($table, $schema) . ' 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 +149,7 @@ protected function loadColumnData($table, $schema) $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'], @@ -154,7 +163,10 @@ protected function loadColumnData($table, $schema) $this->data['columns'][$schema][$table] = $columns; } - protected function loadConstraintData($table, $schema) + /** + * @inheritdoc + */ + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -228,7 +240,7 @@ protected function loadConstraintData($table, $schema) . ' 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 +269,12 @@ protected function loadConstraintData($table, $schema) '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']; @@ -281,7 +293,10 @@ protected function loadConstraintData($table, $schema) $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadTriggerData($schema) + /** + * @inheritdoc + */ + protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { return; @@ -323,7 +338,7 @@ protected function loadTriggerData($schema) . ' 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 9cdad7f807..4d4820ffc2 100644 --- a/src/Metadata/Source/SqlServerMetadata.php +++ b/src/Metadata/Source/SqlServerMetadata.php @@ -1,19 +1,22 @@ data['schemas'])) { return; @@ -37,7 +40,10 @@ protected function loadSchemaData() $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) + /** + * @inheritdoc + */ + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -70,7 +76,7 @@ protected function loadTableNameData($schema) . ' 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,14 +92,17 @@ protected function loadTableNameData($schema) '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'], ]; } $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) + /** + * @inheritdoc + */ + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -129,7 +138,7 @@ protected function loadColumnData($table, $schema) . ' 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 +152,7 @@ protected function loadColumnData($table, $schema) $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'], @@ -157,7 +166,10 @@ protected function loadColumnData($table, $schema) $this->data['columns'][$schema][$table] = $columns; } - protected function loadConstraintData($table, $schema) + /** + * @inheritdoc + */ + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -231,7 +243,7 @@ protected function loadConstraintData($table, $schema) . ' 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 +273,12 @@ protected function loadConstraintData($table, $schema) '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']; @@ -285,7 +297,10 @@ protected function loadConstraintData($table, $schema) $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadTriggerData($schema) + /** + * @inheritdoc + */ + protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { return; @@ -321,7 +336,7 @@ protected function loadTriggerData($schema) . ' 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 b189c3b271..3f21c3a248 100644 --- a/src/Metadata/Source/SqliteMetadata.php +++ b/src/Metadata/Source/SqliteMetadata.php @@ -1,12 +1,12 @@ data['schemas'])) { return; @@ -28,7 +31,10 @@ protected function loadSchemaData() $this->data['schemas'] = $schemas; } - protected function loadTableNameData($schema) + /** + * @inheritdoc + */ + protected function loadTableNameData(string $schema) : void { if (isset($this->data['table_names'][$schema])) { return; @@ -45,7 +51,7 @@ protected function loadTableNameData($schema) $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 @@ -70,7 +76,10 @@ protected function loadTableNameData($schema) $this->data['table_names'][$schema] = $tables; } - protected function loadColumnData($table, $schema) + /** + * @inheritdoc + */ + protected function loadColumnData(string $table, string $schema) : void { if (isset($this->data['columns'][$schema][$table])) { return; @@ -103,7 +112,10 @@ protected function loadColumnData($table, $schema) $this->data['sqlite_columns'][$schema][$table] = $results; } - protected function loadConstraintData($table, $schema) + /** + * @inheritdoc + */ + protected function loadConstraintData(string $table, string $schema) : void { if (isset($this->data['constraints'][$schema][$table])) { return; @@ -186,7 +198,10 @@ protected function loadConstraintData($table, $schema) $this->data['constraints'][$schema][$table] = $constraints; } - protected function loadTriggerData($schema) + /** + * @inheritdoc + */ + protected function loadTriggerData(string $schema) : void { if (isset($this->data['triggers'][$schema])) { return; @@ -231,7 +246,7 @@ protected function loadTriggerData($schema) $this->data['triggers'][$schema] = $triggers; } - protected function fetchPragma($name, $value = null, $schema = null) + protected function fetchPragma(string $name, ?string $value = null, ?string $schema = null) : array { $p = $this->adapter->getPlatform(); @@ -253,7 +268,7 @@ protected function fetchPragma($name, $value = null, $schema = null) return []; } - protected function parseView($sql) + protected function parseView(string $sql) : ?array { static $re = null; if (null === $re) { @@ -271,14 +286,14 @@ protected function parseView($sql) } if (! preg_match($re, $sql, $matches)) { - return; + return null; } return [ 'view_definition' => $matches['view_definition'], ]; } - protected function parseTrigger($sql) + protected function parseTrigger(string $sql) : ?array { static $re = null; if (null === $re) { @@ -306,7 +321,7 @@ protected function parseTrigger($sql) } if (! preg_match($re, $sql, $matches)) { - return; + return null; } $data = []; @@ -324,7 +339,7 @@ protected function parseTrigger($sql) } 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'; } @@ -336,7 +351,7 @@ protected function parseTrigger($sql) return $data; } - protected function buildRegularExpression(array $re) + protected function buildRegularExpression(array $re) : ?string { foreach ($re as &$value) { if (is_array($value)) { @@ -350,7 +365,7 @@ protected function buildRegularExpression(array $re) return $re; } - protected function getIdentifierRegularExpression() + protected function getIdentifierRegularExpression() : ?string { static $re = null; if (null === $re) { @@ -365,7 +380,7 @@ protected function getIdentifierRegularExpression() return $re; } - protected function getIdentifierChainRegularExpression() + protected function getIdentifierChainRegularExpression() : ?string { static $re = null; if (null === $re) { @@ -375,7 +390,7 @@ protected function getIdentifierChainRegularExpression() return $re; } - protected function getIdentifierListRegularExpression() + protected function getIdentifierListRegularExpression() : ?string { static $re = null; if (null === $re) {