Unverified Commit f9dd6a3f authored by Jonathan H. Wage's avatar Jonathan H. Wage Committed by Sergei Morozov

Add proper types to Doctrine\DBAL\Schema namespace.

parent ab424a1d
# Upgrade to 3.0 # Upgrade to 3.0
## BC BREAK: Changes in the `Doctrine\DBAL\Schema` API
- Method `Doctrine\DBAL\Schema\AbstractSchemaManager::_getPortableViewDefinition()` no longer optionally returns false. It will always return a `Doctrine\DBAL\Schema\View` instance.
- Method `Doctrine\DBAL\Schema\Comparator::diffTable()` now optionally returns null instead of false.
- Property `Doctrine\DBAL\Schema\TableDiff::$newName` is now optionally null instead of false.
- Method `Doctrine\DBAL\Schema\AbstractSchemaManager::tablesExist()` no longer accepts a string. Use `Doctrine\DBAL\Schema\AbstractSchemaManager::tableExists()` instead.
- Method `Doctrine\DBAL\Schema\OracleSchemaManager::createDatabase()` no longer accepts `null` for `$database` argument.
- Removed unused method `Doctrine\DBAL\Schema\AbstractSchemaManager::_getPortableFunctionsList()`
- Removed unused method `Doctrine\DBAL\Schema\AbstractSchemaManager::_getPortableFunctionDefinition()`
- Removed unused method `Doctrine\DBAL\Schema\OracleSchemaManager::_getPortableFunctionDefinition()`
- Removed unused method `Doctrine\DBAL\Schema\SqliteSchemaManager::_getPortableTableIndexDefinition()`
## BC BREAK: Changes in the `Doctrine\DBAL\Driver` API ## BC BREAK: Changes in the `Doctrine\DBAL\Driver` API
1. The `$username` and `$password` arguments of `::connect()` are no longer nullable. Use an empty string to indicate empty username or password. 1. The `$username` and `$password` arguments of `::connect()` are no longer nullable. Use an empty string to indicate empty username or password.
......
...@@ -25,7 +25,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs ...@@ -25,7 +25,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
/** @var AbstractPlatform */ /** @var AbstractPlatform */
private $platform; private $platform;
/** @var string[] */ /** @var array<int, string> */
private $sql = []; private $sql = [];
public function __construct(Column $column, Table $table, AbstractPlatform $platform) public function __construct(Column $column, Table $table, AbstractPlatform $platform)
...@@ -74,7 +74,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs ...@@ -74,7 +74,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
} }
/** /**
* @return string[] * @return array<int, string>
*/ */
public function getSql() public function getSql()
{ {
......
...@@ -89,7 +89,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs ...@@ -89,7 +89,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
} }
/** /**
* @return string[] * @return array<int, string>
*/ */
public function getSql() public function getSql()
{ {
......
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Exception;
use Doctrine\DBAL\DBALException;
use function sprintf;
class DatabaseRequired extends DBALException
{
public static function new(string $methodName) : self
{
return new self(
sprintf(
'A database is required for the method: %s.',
$methodName
)
);
}
}
...@@ -28,7 +28,7 @@ class TableGeneratorSchemaVisitor implements Visitor ...@@ -28,7 +28,7 @@ class TableGeneratorSchemaVisitor implements Visitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptSchema(Schema $schema) public function acceptSchema(Schema $schema) : void
{ {
$table = $schema->createTable($this->generatorTableName); $table = $schema->createTable($this->generatorTableName);
$table->addColumn('sequence_name', 'string'); $table->addColumn('sequence_name', 'string');
...@@ -39,35 +39,35 @@ class TableGeneratorSchemaVisitor implements Visitor ...@@ -39,35 +39,35 @@ class TableGeneratorSchemaVisitor implements Visitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptTable(Table $table) public function acceptTable(Table $table) : void
{ {
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptColumn(Table $table, Column $column) public function acceptColumn(Table $table, Column $column) : void
{ {
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void
{ {
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptIndex(Table $table, Index $index) public function acceptIndex(Table $table, Index $index) : void
{ {
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence) : void
{ {
} }
} }
...@@ -1274,7 +1274,7 @@ abstract class AbstractPlatform ...@@ -1274,7 +1274,7 @@ abstract class AbstractPlatform
* Returns the SQL statement(s) to create a table with the specified name, columns and constraints * Returns the SQL statement(s) to create a table with the specified name, columns and constraints
* on this platform. * on this platform.
* *
* @return string[] The sequence of SQL statements. * @return array<int, string> The sequence of SQL statements.
* *
* @throws DBALException * @throws DBALException
*/ */
...@@ -1420,7 +1420,7 @@ abstract class AbstractPlatform ...@@ -1420,7 +1420,7 @@ abstract class AbstractPlatform
* @param mixed[][] $columns * @param mixed[][] $columns
* @param mixed[] $options * @param mixed[] $options
* *
* @return string[] * @return array<int, string>
*/ */
protected function _getCreateTableSQL(string $tableName, array $columns, array $options = []) : array protected function _getCreateTableSQL(string $tableName, array $columns, array $options = []) : array
{ {
...@@ -1450,7 +1450,7 @@ abstract class AbstractPlatform ...@@ -1450,7 +1450,7 @@ abstract class AbstractPlatform
} }
$query .= ')'; $query .= ')';
$sql[] = $query; $sql = [$query];
if (isset($options['foreignKeys'])) { if (isset($options['foreignKeys'])) {
foreach ((array) $options['foreignKeys'] as $definition) { foreach ((array) $options['foreignKeys'] as $definition) {
...@@ -1656,7 +1656,7 @@ abstract class AbstractPlatform ...@@ -1656,7 +1656,7 @@ abstract class AbstractPlatform
* *
* This method returns an array of SQL statements, since some platforms need several statements. * This method returns an array of SQL statements, since some platforms need several statements.
* *
* @return string[] * @return array<int, string>
* *
* @throws DBALException If not supported on this platform. * @throws DBALException If not supported on this platform.
*/ */
...@@ -1805,7 +1805,7 @@ abstract class AbstractPlatform ...@@ -1805,7 +1805,7 @@ abstract class AbstractPlatform
$sql = []; $sql = [];
$newName = $diff->getNewName(); $newName = $diff->getNewName();
if ($newName !== false) { if ($newName !== null) {
$tableName = $newName->getQuotedName($this); $tableName = $newName->getQuotedName($this);
} else { } else {
$tableName = $diff->getName($this)->getQuotedName($this); $tableName = $diff->getName($this)->getQuotedName($this);
......
...@@ -597,7 +597,7 @@ class DB2Platform extends AbstractPlatform ...@@ -597,7 +597,7 @@ class DB2Platform extends AbstractPlatform
$newName = $diff->getNewName(); $newName = $diff->getNewName();
if ($newName !== false) { if ($newName !== null) {
$sql[] = sprintf( $sql[] = sprintf(
'RENAME TABLE %s TO %s', 'RENAME TABLE %s TO %s',
$diff->getName($this)->getQuotedName($this), $diff->getName($this)->getQuotedName($this),
......
...@@ -510,7 +510,7 @@ SQL ...@@ -510,7 +510,7 @@ SQL
$queryParts = []; $queryParts = [];
$newName = $diff->getNewName(); $newName = $diff->getNewName();
if ($newName !== false) { if ($newName !== null) {
$queryParts[] = 'RENAME TO ' . $newName->getQuotedName($this); $queryParts[] = 'RENAME TO ' . $newName->getQuotedName($this);
} }
...@@ -815,7 +815,7 @@ SQL ...@@ -815,7 +815,7 @@ SQL
$sql = []; $sql = [];
$newName = $diff->getNewName(); $newName = $diff->getNewName();
if ($newName !== false) { if ($newName !== null) {
$tableName = $newName->getQuotedName($this); $tableName = $newName->getQuotedName($this);
} else { } else {
$tableName = $diff->getName($this)->getQuotedName($this); $tableName = $diff->getName($this)->getQuotedName($this);
......
...@@ -461,7 +461,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -461,7 +461,7 @@ class OraclePlatform extends AbstractPlatform
} }
/** /**
* @return string[] * @return array<int, string>
*/ */
public function getCreateAutoincrementSql(string $name, string $table, int $start = 1) : array public function getCreateAutoincrementSql(string $name, string $table, int $start = 1) : array
{ {
...@@ -854,7 +854,7 @@ SQL ...@@ -854,7 +854,7 @@ SQL
$newName = $diff->getNewName(); $newName = $diff->getNewName();
if ($newName !== false) { if ($newName !== null) {
$sql[] = sprintf( $sql[] = sprintf(
'ALTER TABLE %s RENAME TO %s', 'ALTER TABLE %s RENAME TO %s',
$diff->getName($this)->getQuotedName($this), $diff->getName($this)->getQuotedName($this),
......
...@@ -591,7 +591,7 @@ SQL ...@@ -591,7 +591,7 @@ SQL
$newName = $diff->getNewName(); $newName = $diff->getNewName();
if ($newName !== false) { if ($newName !== null) {
$sql[] = sprintf( $sql[] = sprintf(
'ALTER TABLE %s RENAME TO %s', 'ALTER TABLE %s RENAME TO %s',
$diff->getName($this)->getQuotedName($this), $diff->getName($this)->getQuotedName($this),
......
...@@ -190,7 +190,7 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -190,7 +190,7 @@ class SQLAnywherePlatform extends AbstractPlatform
$newName = $diff->getNewName(); $newName = $diff->getNewName();
if ($newName !== false) { if ($newName !== null) {
$sql[] = $this->getAlterTableClause($diff->getName($this)) . ' ' . $sql[] = $this->getAlterTableClause($diff->getName($this)) . ' ' .
$this->getAlterTableRenameTableClause($newName); $this->getAlterTableRenameTableClause($newName);
} }
......
...@@ -579,7 +579,7 @@ SQL ...@@ -579,7 +579,7 @@ SQL
$newName = $diff->getNewName(); $newName = $diff->getNewName();
if ($newName !== false) { if ($newName !== null) {
$sql[] = "sp_RENAME '" . $diff->getName($this)->getQuotedName($this) . "', '" . $newName->getName() . "'"; $sql[] = "sp_RENAME '" . $diff->getName($this)->getQuotedName($this) . "', '" . $newName->getName() . "'";
/** /**
......
...@@ -684,7 +684,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -684,7 +684,7 @@ class SqlitePlatform extends AbstractPlatform
$sql = []; $sql = [];
$tableName = $diff->getNewName(); $tableName = $diff->getNewName();
if ($tableName === false) { if ($tableName === null) {
$tableName = $diff->getName($this); $tableName = $diff->getName($this);
} }
...@@ -911,7 +911,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -911,7 +911,7 @@ class SqlitePlatform extends AbstractPlatform
$newName = $diff->getNewName(); $newName = $diff->getNewName();
if ($newName !== false) { if ($newName !== null) {
$sql[] = sprintf( $sql[] = sprintf(
'ALTER TABLE %s RENAME TO %s', 'ALTER TABLE %s RENAME TO %s',
$newTable->getQuotedName($this), $newTable->getQuotedName($this),
...@@ -993,7 +993,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -993,7 +993,7 @@ class SqlitePlatform extends AbstractPlatform
} }
if (! $this->onSchemaAlterTable($diff, $tableSql)) { if (! $this->onSchemaAlterTable($diff, $tableSql)) {
if ($diff->newName !== false) { if ($diff->newName !== null) {
$newTable = new Identifier($diff->newName); $newTable = new Identifier($diff->newName);
$sql[] = 'ALTER TABLE ' . $table->getQuotedName($this) . ' RENAME TO ' . $newTable->getQuotedName($this); $sql[] = 'ALTER TABLE ' . $table->getQuotedName($this) . ' RENAME TO ' . $newTable->getQuotedName($this);
} }
......
...@@ -39,12 +39,8 @@ abstract class AbstractAsset ...@@ -39,12 +39,8 @@ abstract class AbstractAsset
/** /**
* Sets the name of this asset. * Sets the name of this asset.
*
* @param string $name
*
* @return void
*/ */
protected function _setName($name) protected function _setName(string $name) : void
{ {
if ($this->isIdentifierQuoted($name)) { if ($this->isIdentifierQuoted($name)) {
$this->_quoted = true; $this->_quoted = true;
...@@ -60,12 +56,8 @@ abstract class AbstractAsset ...@@ -60,12 +56,8 @@ abstract class AbstractAsset
/** /**
* Is this asset in the default namespace? * Is this asset in the default namespace?
*
* @param string $defaultNamespaceName
*
* @return bool
*/ */
public function isInDefaultNamespace($defaultNamespaceName) public function isInDefaultNamespace(string $defaultNamespaceName) : bool
{ {
return $this->_namespace === $defaultNamespaceName || $this->_namespace === null; return $this->_namespace === $defaultNamespaceName || $this->_namespace === null;
} }
...@@ -74,10 +66,8 @@ abstract class AbstractAsset ...@@ -74,10 +66,8 @@ abstract class AbstractAsset
* Gets the namespace name of this asset. * Gets the namespace name of this asset.
* *
* If NULL is returned this means the default namespace is used. * If NULL is returned this means the default namespace is used.
*
* @return string|null
*/ */
public function getNamespaceName() public function getNamespaceName() : ?string
{ {
return $this->_namespace; return $this->_namespace;
} }
...@@ -85,12 +75,8 @@ abstract class AbstractAsset ...@@ -85,12 +75,8 @@ abstract class AbstractAsset
/** /**
* The shortest name is stripped of the default namespace. All other * The shortest name is stripped of the default namespace. All other
* namespaced elements are returned as full-qualified names. * namespaced elements are returned as full-qualified names.
*
* @param string|null $defaultNamespaceName
*
* @return string
*/ */
public function getShortestName($defaultNamespaceName) public function getShortestName(?string $defaultNamespaceName) : string
{ {
$shortestName = $this->getName(); $shortestName = $this->getName();
if ($this->_namespace === $defaultNamespaceName) { if ($this->_namespace === $defaultNamespaceName) {
...@@ -108,12 +94,8 @@ abstract class AbstractAsset ...@@ -108,12 +94,8 @@ abstract class AbstractAsset
* *
* Every non-namespaced element is prefixed with the default namespace * Every non-namespaced element is prefixed with the default namespace
* name which is passed as argument to this method. * name which is passed as argument to this method.
*
* @param string $defaultNamespaceName
*
* @return string
*/ */
public function getFullQualifiedName($defaultNamespaceName) public function getFullQualifiedName(string $defaultNamespaceName) : string
{ {
$name = $this->getName(); $name = $this->getName();
if (! $this->_namespace) { if (! $this->_namespace) {
...@@ -125,44 +107,32 @@ abstract class AbstractAsset ...@@ -125,44 +107,32 @@ abstract class AbstractAsset
/** /**
* Checks if this asset's name is quoted. * Checks if this asset's name is quoted.
*
* @return bool
*/ */
public function isQuoted() public function isQuoted() : bool
{ {
return $this->_quoted; return $this->_quoted;
} }
/** /**
* Checks if this identifier is quoted. * Checks if this identifier is quoted.
*
* @param string $identifier
*
* @return bool
*/ */
protected function isIdentifierQuoted($identifier) protected function isIdentifierQuoted(string $identifier) : bool
{ {
return isset($identifier[0]) && ($identifier[0] === '`' || $identifier[0] === '"' || $identifier[0] === '['); return isset($identifier[0]) && ($identifier[0] === '`' || $identifier[0] === '"' || $identifier[0] === '[');
} }
/** /**
* Trim quotes from the identifier. * Trim quotes from the identifier.
*
* @param string $identifier
*
* @return string
*/ */
protected function trimQuotes($identifier) protected function trimQuotes(string $identifier) : string
{ {
return str_replace(['`', '"', '[', ']'], '', $identifier); return str_replace(['`', '"', '[', ']'], '', $identifier);
} }
/** /**
* Returns the name of this schema asset. * Returns the name of this schema asset.
*
* @return string
*/ */
public function getName() public function getName() : string
{ {
if ($this->_namespace) { if ($this->_namespace) {
return $this->_namespace . '.' . $this->_name; return $this->_namespace . '.' . $this->_name;
...@@ -174,10 +144,8 @@ abstract class AbstractAsset ...@@ -174,10 +144,8 @@ abstract class AbstractAsset
/** /**
* Gets the quoted representation of this asset but only if it was defined with one. Otherwise * Gets the quoted representation of this asset but only if it was defined with one. Otherwise
* return the plain unquoted value as inserted. * return the plain unquoted value as inserted.
*
* @return string
*/ */
public function getQuotedName(AbstractPlatform $platform) public function getQuotedName(AbstractPlatform $platform) : string
{ {
$keywords = $platform->getReservedKeywordsList(); $keywords = $platform->getReservedKeywordsList();
$parts = explode('.', $this->getName()); $parts = explode('.', $this->getName());
...@@ -195,13 +163,9 @@ abstract class AbstractAsset ...@@ -195,13 +163,9 @@ abstract class AbstractAsset
* however building idents automatically for foreign keys, composite keys or such can easily create * however building idents automatically for foreign keys, composite keys or such can easily create
* very long names. * very long names.
* *
* @param string[] $columnNames * @param array<int, string> $columnNames
* @param string $prefix
* @param int $maxSize
*
* @return string
*/ */
protected function _generateIdentifierName($columnNames, $prefix = '', $maxSize = 30) protected function _generateIdentifierName(array $columnNames, string $prefix = '', int $maxSize = 30) : string
{ {
$hash = implode('', array_map(static function ($column) { $hash = implode('', array_map(static function ($column) {
return dechex(crc32($column)); return dechex(crc32($column));
......
...@@ -10,12 +10,14 @@ use Doctrine\DBAL\DBALException; ...@@ -10,12 +10,14 @@ use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs; use Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs;
use Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs; use Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs;
use Doctrine\DBAL\Events; use Doctrine\DBAL\Events;
use Doctrine\DBAL\Exception\DatabaseRequired;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\Exception\NotSupported; use Doctrine\DBAL\Platforms\Exception\NotSupported;
use Throwable; use Throwable;
use function array_filter; use function array_filter;
use function array_intersect; use function array_intersect;
use function array_map; use function array_map;
use function array_shift;
use function array_values; use function array_values;
use function assert; use function assert;
use function call_user_func_array; use function call_user_func_array;
...@@ -57,10 +59,8 @@ abstract class AbstractSchemaManager ...@@ -57,10 +59,8 @@ abstract class AbstractSchemaManager
/** /**
* Returns the associated platform. * Returns the associated platform.
*
* @return AbstractPlatform
*/ */
public function getDatabasePlatform() public function getDatabasePlatform() : AbstractPlatform
{ {
return $this->_platform; return $this->_platform;
} }
...@@ -97,9 +97,9 @@ abstract class AbstractSchemaManager ...@@ -97,9 +97,9 @@ abstract class AbstractSchemaManager
/** /**
* Lists the available databases for this connection. * Lists the available databases for this connection.
* *
* @return string[] * @return array<int, string>
*/ */
public function listDatabases() public function listDatabases() : array
{ {
$sql = $this->_platform->getListDatabasesSQL(); $sql = $this->_platform->getListDatabasesSQL();
...@@ -111,9 +111,9 @@ abstract class AbstractSchemaManager ...@@ -111,9 +111,9 @@ abstract class AbstractSchemaManager
/** /**
* Returns a list of all namespaces in the current database. * Returns a list of all namespaces in the current database.
* *
* @return string[] * @return array<int, string>
*/ */
public function listNamespaceNames() public function listNamespaceNames() : array
{ {
$sql = $this->_platform->getListNamespacesSQL(); $sql = $this->_platform->getListNamespacesSQL();
...@@ -125,15 +125,15 @@ abstract class AbstractSchemaManager ...@@ -125,15 +125,15 @@ abstract class AbstractSchemaManager
/** /**
* Lists the available sequences for this connection. * Lists the available sequences for this connection.
* *
* @param string|null $database * @return array<int, Sequence>
*
* @return Sequence[]
*/ */
public function listSequences($database = null) public function listSequences(?string $database = null) : array
{ {
if ($database === null) { $database = $this->ensureDatabase(
$database = $this->_conn->getDatabase(); $database ?? $this->_conn->getDatabase(),
} __METHOD__
);
$sql = $this->_platform->getListSequencesSQL($database); $sql = $this->_platform->getListSequencesSQL($database);
$sequences = $this->_conn->fetchAll($sql); $sequences = $this->_conn->fetchAll($sql);
...@@ -151,16 +151,14 @@ abstract class AbstractSchemaManager ...@@ -151,16 +151,14 @@ abstract class AbstractSchemaManager
* of a table. Where a RDBMS specifies more details, these are held * of a table. Where a RDBMS specifies more details, these are held
* in the platformDetails array. * in the platformDetails array.
* *
* @param string $table The name of the table. * @return array<string, Column>
* @param string|null $database
*
* @return Column[]
*/ */
public function listTableColumns($table, $database = null) public function listTableColumns(string $table, ?string $database = null) : array
{ {
if (! $database) { $database = $this->ensureDatabase(
$database = $this->_conn->getDatabase(); $database ?? $this->_conn->getDatabase(),
} __METHOD__
);
$sql = $this->_platform->getListTableColumnsSQL($table, $database); $sql = $this->_platform->getListTableColumnsSQL($table, $database);
...@@ -174,11 +172,9 @@ abstract class AbstractSchemaManager ...@@ -174,11 +172,9 @@ abstract class AbstractSchemaManager
* *
* Keys of the portable indexes list are all lower-cased. * Keys of the portable indexes list are all lower-cased.
* *
* @param string $table The name of the table. * @return array<string, Index>
*
* @return Index[]
*/ */
public function listTableIndexes($table) public function listTableIndexes(string $table) : array
{ {
$sql = $this->_platform->getListTableIndexesSQL($table, $this->_conn->getDatabase()); $sql = $this->_platform->getListTableIndexesSQL($table, $this->_conn->getDatabase());
...@@ -190,25 +186,26 @@ abstract class AbstractSchemaManager ...@@ -190,25 +186,26 @@ abstract class AbstractSchemaManager
/** /**
* Returns true if all the given tables exist. * Returns true if all the given tables exist.
* *
* The usage of a string $tableNames is deprecated. Pass a one-element array instead. * @param array<int, string> $tableNames
*
* @param string|string[] $tableNames
*
* @return bool
*/ */
public function tablesExist($tableNames) public function tablesExist(array $tableNames) : bool
{ {
$tableNames = array_map('strtolower', (array) $tableNames); $tableNames = array_map('strtolower', $tableNames);
return count($tableNames) === count(array_intersect($tableNames, array_map('strtolower', $this->listTableNames()))); return count($tableNames) === count(array_intersect($tableNames, array_map('strtolower', $this->listTableNames())));
} }
public function tableExists(string $tableName) : bool
{
return $this->tablesExist([$tableName]);
}
/** /**
* Returns a list of all tables in the current database. * Returns a list of all tables in the current database.
* *
* @return string[] * @return array<int, string>
*/ */
public function listTableNames() public function listTableNames() : array
{ {
$sql = $this->_platform->getListTablesSQL(); $sql = $this->_platform->getListTablesSQL();
...@@ -222,11 +219,11 @@ abstract class AbstractSchemaManager ...@@ -222,11 +219,11 @@ abstract class AbstractSchemaManager
* Filters asset names if they are configured to return only a subset of all * Filters asset names if they are configured to return only a subset of all
* the found elements. * the found elements.
* *
* @param mixed[] $assetNames * @param array<int, mixed> $assetNames
* *
* @return mixed[] * @return array<int, mixed>
*/ */
protected function filterAssetNames($assetNames) protected function filterAssetNames(array $assetNames)
{ {
$filter = $this->_conn->getConfiguration()->getSchemaAssetsFilter(); $filter = $this->_conn->getConfiguration()->getSchemaAssetsFilter();
if (! $filter) { if (! $filter) {
...@@ -239,9 +236,9 @@ abstract class AbstractSchemaManager ...@@ -239,9 +236,9 @@ abstract class AbstractSchemaManager
/** /**
* Lists the tables for this connection. * Lists the tables for this connection.
* *
* @return Table[] * @return array<int, Table>
*/ */
public function listTables() public function listTables() : array
{ {
$tableNames = $this->listTableNames(); $tableNames = $this->listTableNames();
...@@ -253,12 +250,7 @@ abstract class AbstractSchemaManager ...@@ -253,12 +250,7 @@ abstract class AbstractSchemaManager
return $tables; return $tables;
} }
/** public function listTableDetails(string $tableName) : Table
* @param string $tableName
*
* @return Table
*/
public function listTableDetails($tableName)
{ {
$columns = $this->listTableColumns($tableName); $columns = $this->listTableColumns($tableName);
$foreignKeys = []; $foreignKeys = [];
...@@ -275,13 +267,17 @@ abstract class AbstractSchemaManager ...@@ -275,13 +267,17 @@ abstract class AbstractSchemaManager
/** /**
* Lists the views this connection has. * Lists the views this connection has.
* *
* @return View[] * @return array<string, View>
*/ */
public function listViews() public function listViews() : array
{ {
$database = $this->_conn->getDatabase(); $database = $this->ensureDatabase(
$sql = $this->_platform->getListViewsSQL($database); $this->_conn->getDatabase(),
$views = $this->_conn->fetchAll($sql); __METHOD__
);
$sql = $this->_platform->getListViewsSQL($database);
$views = $this->_conn->fetchAll($sql);
return $this->_getPortableViewsList($views); return $this->_getPortableViewsList($views);
} }
...@@ -289,12 +285,9 @@ abstract class AbstractSchemaManager ...@@ -289,12 +285,9 @@ abstract class AbstractSchemaManager
/** /**
* Lists the foreign keys for the given table. * Lists the foreign keys for the given table.
* *
* @param string $table The name of the table. * @return array<int|string, ForeignKeyConstraint>
* @param string|null $database
*
* @return ForeignKeyConstraint[]
*/ */
public function listTableForeignKeys($table, $database = null) public function listTableForeignKeys(string $table, ?string $database = null) : array
{ {
if ($database === null) { if ($database === null) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
...@@ -311,24 +304,16 @@ abstract class AbstractSchemaManager ...@@ -311,24 +304,16 @@ abstract class AbstractSchemaManager
* Drops a database. * Drops a database.
* *
* NOTE: You can not drop the database this SchemaManager is currently connected to. * NOTE: You can not drop the database this SchemaManager is currently connected to.
*
* @param string $database The name of the database to drop.
*
* @return void
*/ */
public function dropDatabase($database) public function dropDatabase(string $database) : void
{ {
$this->_execSql($this->_platform->getDropDatabaseSQL($database)); $this->_execSql($this->_platform->getDropDatabaseSQL($database));
} }
/** /**
* Drops the given table. * Drops the given table.
*
* @param string $tableName The name of the table to drop.
*
* @return void
*/ */
public function dropTable($tableName) public function dropTable(string $tableName) : void
{ {
$this->_execSql($this->_platform->getDropTableSQL($tableName)); $this->_execSql($this->_platform->getDropTableSQL($tableName));
} }
...@@ -338,10 +323,8 @@ abstract class AbstractSchemaManager ...@@ -338,10 +323,8 @@ abstract class AbstractSchemaManager
* *
* @param Index|string $index The name of the index. * @param Index|string $index The name of the index.
* @param Table|string $table The name of the table. * @param Table|string $table The name of the table.
*
* @return void
*/ */
public function dropIndex($index, $table) public function dropIndex($index, $table) : void
{ {
if ($index instanceof Index) { if ($index instanceof Index) {
$index = $index->getQuotedName($this->_platform); $index = $index->getQuotedName($this->_platform);
...@@ -354,10 +337,8 @@ abstract class AbstractSchemaManager ...@@ -354,10 +337,8 @@ abstract class AbstractSchemaManager
* Drops the constraint from the given table. * Drops the constraint from the given table.
* *
* @param Table|string $table The name of the table. * @param Table|string $table The name of the table.
*
* @return void
*/ */
public function dropConstraint(Constraint $constraint, $table) public function dropConstraint(Constraint $constraint, $table) : void
{ {
$this->_execSql($this->_platform->getDropConstraintSQL($constraint, $table)); $this->_execSql($this->_platform->getDropConstraintSQL($constraint, $table));
} }
...@@ -367,34 +348,24 @@ abstract class AbstractSchemaManager ...@@ -367,34 +348,24 @@ abstract class AbstractSchemaManager
* *
* @param ForeignKeyConstraint|string $foreignKey The name of the foreign key. * @param ForeignKeyConstraint|string $foreignKey The name of the foreign key.
* @param Table|string $table The name of the table with the foreign key. * @param Table|string $table The name of the table with the foreign key.
*
* @return void
*/ */
public function dropForeignKey($foreignKey, $table) public function dropForeignKey($foreignKey, $table) : void
{ {
$this->_execSql($this->_platform->getDropForeignKeySQL($foreignKey, $table)); $this->_execSql($this->_platform->getDropForeignKeySQL($foreignKey, $table));
} }
/** /**
* Drops a sequence with a given name. * Drops a sequence with a given name.
*
* @param string $name The name of the sequence to drop.
*
* @return void
*/ */
public function dropSequence($name) public function dropSequence(string $name) : void
{ {
$this->_execSql($this->_platform->getDropSequenceSQL($name)); $this->_execSql($this->_platform->getDropSequenceSQL($name));
} }
/** /**
* Drops a view. * Drops a view.
*
* @param string $name The name of the view.
*
* @return void
*/ */
public function dropView($name) public function dropView(string $name) : void
{ {
$this->_execSql($this->_platform->getDropViewSQL($name)); $this->_execSql($this->_platform->getDropViewSQL($name));
} }
...@@ -403,22 +374,16 @@ abstract class AbstractSchemaManager ...@@ -403,22 +374,16 @@ abstract class AbstractSchemaManager
/** /**
* Creates a new database. * Creates a new database.
*
* @param string $database The name of the database to create.
*
* @return void
*/ */
public function createDatabase($database) public function createDatabase(string $database) : void
{ {
$this->_execSql($this->_platform->getCreateDatabaseSQL($database)); $this->_execSql($this->_platform->getCreateDatabaseSQL($database));
} }
/** /**
* Creates a new table. * Creates a new table.
*
* @return void
*/ */
public function createTable(Table $table) public function createTable(Table $table) : void
{ {
$createFlags = AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS; $createFlags = AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS;
$this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags)); $this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags));
...@@ -427,13 +392,9 @@ abstract class AbstractSchemaManager ...@@ -427,13 +392,9 @@ abstract class AbstractSchemaManager
/** /**
* Creates a new sequence. * Creates a new sequence.
* *
* @param Sequence $sequence
*
* @return void
*
* @throws ConnectionException If something fails at database level. * @throws ConnectionException If something fails at database level.
*/ */
public function createSequence($sequence) public function createSequence(Sequence $sequence) : void
{ {
$this->_execSql($this->_platform->getCreateSequenceSQL($sequence)); $this->_execSql($this->_platform->getCreateSequenceSQL($sequence));
} }
...@@ -442,10 +403,8 @@ abstract class AbstractSchemaManager ...@@ -442,10 +403,8 @@ abstract class AbstractSchemaManager
* Creates a constraint on a table. * Creates a constraint on a table.
* *
* @param Table|string $table * @param Table|string $table
*
* @return void
*/ */
public function createConstraint(Constraint $constraint, $table) public function createConstraint(Constraint $constraint, $table) : void
{ {
$this->_execSql($this->_platform->getCreateConstraintSQL($constraint, $table)); $this->_execSql($this->_platform->getCreateConstraintSQL($constraint, $table));
} }
...@@ -454,10 +413,8 @@ abstract class AbstractSchemaManager ...@@ -454,10 +413,8 @@ abstract class AbstractSchemaManager
* Creates a new index on a table. * Creates a new index on a table.
* *
* @param Table|string $table The name of the table on which the index is to be created. * @param Table|string $table The name of the table on which the index is to be created.
*
* @return void
*/ */
public function createIndex(Index $index, $table) public function createIndex(Index $index, $table) : void
{ {
$this->_execSql($this->_platform->getCreateIndexSQL($index, $table)); $this->_execSql($this->_platform->getCreateIndexSQL($index, $table));
} }
...@@ -467,20 +424,16 @@ abstract class AbstractSchemaManager ...@@ -467,20 +424,16 @@ abstract class AbstractSchemaManager
* *
* @param ForeignKeyConstraint $foreignKey The ForeignKey instance. * @param ForeignKeyConstraint $foreignKey The ForeignKey instance.
* @param Table|string $table The name of the table on which the foreign key is to be created. * @param Table|string $table The name of the table on which the foreign key is to be created.
*
* @return void
*/ */
public function createForeignKey(ForeignKeyConstraint $foreignKey, $table) public function createForeignKey(ForeignKeyConstraint $foreignKey, $table) : void
{ {
$this->_execSql($this->_platform->getCreateForeignKeySQL($foreignKey, $table)); $this->_execSql($this->_platform->getCreateForeignKeySQL($foreignKey, $table));
} }
/** /**
* Creates a new view. * Creates a new view.
*
* @return void
*/ */
public function createView(View $view) public function createView(View $view) : void
{ {
$this->_execSql($this->_platform->getCreateViewSQL($view->getQuotedName($this->_platform), $view->getSql())); $this->_execSql($this->_platform->getCreateViewSQL($view->getQuotedName($this->_platform), $view->getSql()));
} }
...@@ -494,10 +447,8 @@ abstract class AbstractSchemaManager ...@@ -494,10 +447,8 @@ abstract class AbstractSchemaManager
* @see createConstraint() * @see createConstraint()
* *
* @param Table|string $table * @param Table|string $table
*
* @return void
*/ */
public function dropAndCreateConstraint(Constraint $constraint, $table) public function dropAndCreateConstraint(Constraint $constraint, $table) : void
{ {
$this->tryMethod('dropConstraint', $constraint, $table); $this->tryMethod('dropConstraint', $constraint, $table);
$this->createConstraint($constraint, $table); $this->createConstraint($constraint, $table);
...@@ -507,10 +458,8 @@ abstract class AbstractSchemaManager ...@@ -507,10 +458,8 @@ abstract class AbstractSchemaManager
* Drops and creates a new index on a table. * Drops and creates a new index on a table.
* *
* @param Table|string $table The name of the table on which the index is to be created. * @param Table|string $table The name of the table on which the index is to be created.
*
* @return void
*/ */
public function dropAndCreateIndex(Index $index, $table) public function dropAndCreateIndex(Index $index, $table) : void
{ {
$this->tryMethod('dropIndex', $index->getQuotedName($this->_platform), $table); $this->tryMethod('dropIndex', $index->getQuotedName($this->_platform), $table);
$this->createIndex($index, $table); $this->createIndex($index, $table);
...@@ -521,10 +470,8 @@ abstract class AbstractSchemaManager ...@@ -521,10 +470,8 @@ abstract class AbstractSchemaManager
* *
* @param ForeignKeyConstraint $foreignKey An associative array that defines properties of the foreign key to be created. * @param ForeignKeyConstraint $foreignKey An associative array that defines properties of the foreign key to be created.
* @param Table|string $table The name of the table on which the foreign key is to be created. * @param Table|string $table The name of the table on which the foreign key is to be created.
*
* @return void
*/ */
public function dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, $table) public function dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, $table) : void
{ {
$this->tryMethod('dropForeignKey', $foreignKey, $table); $this->tryMethod('dropForeignKey', $foreignKey, $table);
$this->createForeignKey($foreignKey, $table); $this->createForeignKey($foreignKey, $table);
...@@ -533,11 +480,9 @@ abstract class AbstractSchemaManager ...@@ -533,11 +480,9 @@ abstract class AbstractSchemaManager
/** /**
* Drops and create a new sequence. * Drops and create a new sequence.
* *
* @return void
*
* @throws ConnectionException If something fails at database level. * @throws ConnectionException If something fails at database level.
*/ */
public function dropAndCreateSequence(Sequence $sequence) public function dropAndCreateSequence(Sequence $sequence) : void
{ {
$this->tryMethod('dropSequence', $sequence->getQuotedName($this->_platform)); $this->tryMethod('dropSequence', $sequence->getQuotedName($this->_platform));
$this->createSequence($sequence); $this->createSequence($sequence);
...@@ -545,10 +490,8 @@ abstract class AbstractSchemaManager ...@@ -545,10 +490,8 @@ abstract class AbstractSchemaManager
/** /**
* Drops and creates a new table. * Drops and creates a new table.
*
* @return void
*/ */
public function dropAndCreateTable(Table $table) public function dropAndCreateTable(Table $table) : void
{ {
$this->tryMethod('dropTable', $table->getQuotedName($this->_platform)); $this->tryMethod('dropTable', $table->getQuotedName($this->_platform));
$this->createTable($table); $this->createTable($table);
...@@ -556,12 +499,8 @@ abstract class AbstractSchemaManager ...@@ -556,12 +499,8 @@ abstract class AbstractSchemaManager
/** /**
* Drops and creates a new database. * Drops and creates a new database.
*
* @param string $database The name of the database to create.
*
* @return void
*/ */
public function dropAndCreateDatabase($database) public function dropAndCreateDatabase(string $database) : void
{ {
$this->tryMethod('dropDatabase', $database); $this->tryMethod('dropDatabase', $database);
$this->createDatabase($database); $this->createDatabase($database);
...@@ -569,10 +508,8 @@ abstract class AbstractSchemaManager ...@@ -569,10 +508,8 @@ abstract class AbstractSchemaManager
/** /**
* Drops and creates a new view. * Drops and creates a new view.
*
* @return void
*/ */
public function dropAndCreateView(View $view) public function dropAndCreateView(View $view) : void
{ {
$this->tryMethod('dropView', $view->getQuotedName($this->_platform)); $this->tryMethod('dropView', $view->getQuotedName($this->_platform));
$this->createView($view); $this->createView($view);
...@@ -582,10 +519,8 @@ abstract class AbstractSchemaManager ...@@ -582,10 +519,8 @@ abstract class AbstractSchemaManager
/** /**
* Alters an existing tables schema. * Alters an existing tables schema.
*
* @return void
*/ */
public function alterTable(TableDiff $tableDiff) public function alterTable(TableDiff $tableDiff) : void
{ {
$queries = $this->_platform->getAlterTableSQL($tableDiff); $queries = $this->_platform->getAlterTableSQL($tableDiff);
...@@ -600,13 +535,8 @@ abstract class AbstractSchemaManager ...@@ -600,13 +535,8 @@ abstract class AbstractSchemaManager
/** /**
* Renames a given table to another name. * Renames a given table to another name.
*
* @param string $name The current name of the table.
* @param string $newName The new name of the table.
*
* @return void
*/ */
public function renameTable($name, $newName) public function renameTable(string $name, string $newName) : void
{ {
$tableDiff = new TableDiff($name); $tableDiff = new TableDiff($name);
$tableDiff->newName = $newName; $tableDiff->newName = $newName;
...@@ -619,11 +549,11 @@ abstract class AbstractSchemaManager ...@@ -619,11 +549,11 @@ abstract class AbstractSchemaManager
*/ */
/** /**
* @param mixed[] $databases * @param array<int, mixed> $databases
* *
* @return string[] * @return array<int, string>
*/ */
protected function _getPortableDatabasesList($databases) protected function _getPortableDatabasesList(array $databases) : array
{ {
$list = []; $list = [];
foreach ($databases as $value) { foreach ($databases as $value) {
...@@ -642,11 +572,11 @@ abstract class AbstractSchemaManager ...@@ -642,11 +572,11 @@ abstract class AbstractSchemaManager
/** /**
* Converts a list of namespace names from the native DBMS data definition to a portable Doctrine definition. * Converts a list of namespace names from the native DBMS data definition to a portable Doctrine definition.
* *
* @param mixed[][] $namespaces The list of namespace names in the native DBMS data definition. * @param array<int, array<int, mixed>> $namespaces The list of namespace names in the native DBMS data definition.
* *
* @return string[] * @return array<int, string>
*/ */
protected function getPortableNamespacesList(array $namespaces) protected function getPortableNamespacesList(array $namespaces) : array
{ {
$namespacesList = []; $namespacesList = [];
...@@ -658,68 +588,29 @@ abstract class AbstractSchemaManager ...@@ -658,68 +588,29 @@ abstract class AbstractSchemaManager
} }
/** /**
* @param mixed $database * @param array<string, string> $database
*
* @return mixed
*/ */
protected function _getPortableDatabaseDefinition($database) protected function _getPortableDatabaseDefinition(array $database) : string
{ {
return $database; return array_shift($database);
} }
/** /**
* Converts a namespace definition from the native DBMS data definition to a portable Doctrine definition. * Converts a namespace definition from the native DBMS data definition to a portable Doctrine definition.
* *
* @param mixed[] $namespace The native DBMS namespace definition. * @param array<string|int, mixed> $namespace The native DBMS namespace definition.
*
* @return mixed
*/
protected function getPortableNamespaceDefinition(array $namespace)
{
return $namespace;
}
/**
* @deprecated
*
* @param mixed[][] $functions
*
* @return mixed[][]
*/
protected function _getPortableFunctionsList($functions)
{
$list = [];
foreach ($functions as $value) {
$value = $this->_getPortableFunctionDefinition($value);
if (! $value) {
continue;
}
$list[] = $value;
}
return $list;
}
/**
* @deprecated
*
* @param mixed[] $function
*
* @return mixed
*/ */
protected function _getPortableFunctionDefinition($function) protected function getPortableNamespaceDefinition(array $namespace) : string
{ {
return $function; return array_shift($namespace);
} }
/** /**
* @param mixed[][] $triggers * @param array<int, array<int, mixed>> $triggers
* *
* @return mixed[][] * @return array<int, string>
*/ */
protected function _getPortableTriggersList($triggers) protected function _getPortableTriggersList(array $triggers)
{ {
$list = []; $list = [];
foreach ($triggers as $value) { foreach ($triggers as $value) {
...@@ -736,21 +627,19 @@ abstract class AbstractSchemaManager ...@@ -736,21 +627,19 @@ abstract class AbstractSchemaManager
} }
/** /**
* @param mixed[] $trigger * @param array<string|int, mixed> $trigger
*
* @return mixed
*/ */
protected function _getPortableTriggerDefinition($trigger) protected function _getPortableTriggerDefinition(array $trigger) : string
{ {
return $trigger; return array_shift($trigger);
} }
/** /**
* @param mixed[][] $sequences * @param array<int, array<string, mixed>> $sequences
* *
* @return Sequence[] * @return array<int, Sequence>
*/ */
protected function _getPortableSequencesList($sequences) protected function _getPortableSequencesList(array $sequences) : array
{ {
$list = []; $list = [];
...@@ -762,13 +651,11 @@ abstract class AbstractSchemaManager ...@@ -762,13 +651,11 @@ abstract class AbstractSchemaManager
} }
/** /**
* @param mixed[] $sequence * @param array<string, mixed> $sequence
*
* @return Sequence
* *
* @throws DBALException * @throws DBALException
*/ */
protected function _getPortableSequenceDefinition($sequence) protected function _getPortableSequenceDefinition(array $sequence) : Sequence
{ {
throw NotSupported::new('Sequences'); throw NotSupported::new('Sequences');
} }
...@@ -778,13 +665,11 @@ abstract class AbstractSchemaManager ...@@ -778,13 +665,11 @@ abstract class AbstractSchemaManager
* *
* The name of the created column instance however is kept in its case. * The name of the created column instance however is kept in its case.
* *
* @param string $table The name of the table. * @param array<int, array<string, mixed>> $tableColumns
* @param string $database
* @param mixed[][] $tableColumns
* *
* @return Column[] * @return array<string, Column>
*/ */
protected function _getPortableTableColumnList($table, $database, $tableColumns) protected function _getPortableTableColumnList(string $table, string $database, array $tableColumns) : array
{ {
$eventManager = $this->_platform->getEventManager(); $eventManager = $this->_platform->getEventManager();
...@@ -819,18 +704,16 @@ abstract class AbstractSchemaManager ...@@ -819,18 +704,16 @@ abstract class AbstractSchemaManager
/** /**
* Gets Table Column Definition. * Gets Table Column Definition.
* *
* @param mixed[] $tableColumn * @param array<string, mixed> $tableColumn
*
* @return Column
*/ */
abstract protected function _getPortableTableColumnDefinition($tableColumn); abstract protected function _getPortableTableColumnDefinition(array $tableColumn) : Column;
/** /**
* Aggregates and groups the index results according to the required data result. * Aggregates and groups the index results according to the required data result.
* *
* @param mixed[][] $tableIndexRows * @param array<int, array<string, mixed>> $tableIndexRows
* *
* @return Index[] * @return array<string, Index>
*/ */
protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{ {
...@@ -895,11 +778,11 @@ abstract class AbstractSchemaManager ...@@ -895,11 +778,11 @@ abstract class AbstractSchemaManager
} }
/** /**
* @param mixed[][] $tables * @param array<int, array<string, mixed>> $tables
* *
* @return string[] * @return array<int, string>
*/ */
protected function _getPortableTablesList($tables) protected function _getPortableTablesList(array $tables) : array
{ {
$list = []; $list = [];
foreach ($tables as $value) { foreach ($tables as $value) {
...@@ -916,21 +799,19 @@ abstract class AbstractSchemaManager ...@@ -916,21 +799,19 @@ abstract class AbstractSchemaManager
} }
/** /**
* @param mixed $table * @param array<string, string> $table
*
* @return string
*/ */
protected function _getPortableTableDefinition($table) protected function _getPortableTableDefinition(array $table) : string
{ {
return $table; return array_shift($table);
} }
/** /**
* @param mixed[][] $users * @param array<int, array<string, mixed>> $users
* *
* @return string[][] * @return array<int, array<string, mixed>>
*/ */
protected function _getPortableUsersList($users) protected function _getPortableUsersList(array $users) : array
{ {
$list = []; $list = [];
foreach ($users as $value) { foreach ($users as $value) {
...@@ -947,53 +828,46 @@ abstract class AbstractSchemaManager ...@@ -947,53 +828,46 @@ abstract class AbstractSchemaManager
} }
/** /**
* @param string[] $user * @param array<string, mixed> $user
* *
* @return string[] * @return array<string, mixed>
*/ */
protected function _getPortableUserDefinition($user) protected function _getPortableUserDefinition(array $user) : array
{ {
return $user; return $user;
} }
/** /**
* @param mixed[][] $views * @param array<int, array<string, mixed>> $views
* *
* @return View[] * @return array<string, View>
*/ */
protected function _getPortableViewsList($views) protected function _getPortableViewsList(array $views) : array
{ {
$list = []; $list = [];
foreach ($views as $value) { foreach ($views as $value) {
$view = $this->_getPortableViewDefinition($value); $view = $this->_getPortableViewDefinition($value);
$name = strtolower($view->getQuotedName($this->_platform));
if (! $view) { $list[$name] = $view;
continue;
}
$viewName = strtolower($view->getQuotedName($this->_platform));
$list[$viewName] = $view;
} }
return $list; return $list;
} }
/** /**
* @param mixed[] $view * @param array<string, mixed> $view
*
* @return View|false
*/ */
protected function _getPortableViewDefinition($view) protected function _getPortableViewDefinition(array $view) : View
{ {
return false; throw NotSupported::new('Views');
} }
/** /**
* @param mixed[][] $tableForeignKeys * @param array<int|string, array<string, mixed>> $tableForeignKeys
* *
* @return ForeignKeyConstraint[] * @return array<int, ForeignKeyConstraint>
*/ */
protected function _getPortableTableForeignKeysList($tableForeignKeys) protected function _getPortableTableForeignKeysList(array $tableForeignKeys) : array
{ {
$list = []; $list = [];
...@@ -1005,21 +879,17 @@ abstract class AbstractSchemaManager ...@@ -1005,21 +879,17 @@ abstract class AbstractSchemaManager
} }
/** /**
* @param mixed $tableForeignKey * @param array<string, mixed> $tableForeignKey
*
* @return ForeignKeyConstraint
*/ */
protected function _getPortableTableForeignKeyDefinition($tableForeignKey) protected function _getPortableTableForeignKeyDefinition(array $tableForeignKey) : ForeignKeyConstraint
{ {
return $tableForeignKey; throw NotSupported::new('ForeignKey');
} }
/** /**
* @param string[]|string $sql * @param array<int, string>|string $sql
*
* @return void
*/ */
protected function _execSql($sql) protected function _execSql($sql) : void
{ {
foreach ((array) $sql as $query) { foreach ((array) $sql as $query) {
$this->_conn->executeUpdate($query); $this->_conn->executeUpdate($query);
...@@ -1028,10 +898,8 @@ abstract class AbstractSchemaManager ...@@ -1028,10 +898,8 @@ abstract class AbstractSchemaManager
/** /**
* Creates a schema instance for the current database. * Creates a schema instance for the current database.
*
* @return Schema
*/ */
public function createSchema() public function createSchema() : Schema
{ {
$namespaces = []; $namespaces = [];
...@@ -1052,10 +920,8 @@ abstract class AbstractSchemaManager ...@@ -1052,10 +920,8 @@ abstract class AbstractSchemaManager
/** /**
* Creates the configuration for this schema. * Creates the configuration for this schema.
*
* @return SchemaConfig
*/ */
public function createSchemaConfig() public function createSchemaConfig() : SchemaConfig
{ {
$schemaConfig = new SchemaConfig(); $schemaConfig = new SchemaConfig();
$schemaConfig->setMaxIdentifierLength($this->_platform->getMaxIdentifierLength()); $schemaConfig->setMaxIdentifierLength($this->_platform->getMaxIdentifierLength());
...@@ -1087,9 +953,9 @@ abstract class AbstractSchemaManager ...@@ -1087,9 +953,9 @@ abstract class AbstractSchemaManager
* For databases that don't support subschema/namespaces this method * For databases that don't support subschema/namespaces this method
* returns the name of the currently connected database. * returns the name of the currently connected database.
* *
* @return string[] * @return array<int, string>
*/ */
public function getSchemaSearchPaths() public function getSchemaSearchPaths() : array
{ {
return [$this->_conn->getDatabase()]; return [$this->_conn->getDatabase()];
} }
...@@ -1110,4 +976,16 @@ abstract class AbstractSchemaManager ...@@ -1110,4 +976,16 @@ abstract class AbstractSchemaManager
return $match[2]; return $match[2];
} }
/**
* @throws DatabaseRequired
*/
private function ensureDatabase(?string $database, string $methodName) : string
{
if ($database === null) {
throw DatabaseRequired::new($methodName);
}
return $database;
}
} }
...@@ -43,7 +43,7 @@ class Column extends AbstractAsset ...@@ -43,7 +43,7 @@ class Column extends AbstractAsset
/** @var bool */ /** @var bool */
protected $_autoincrement = false; protected $_autoincrement = false;
/** @var mixed[] */ /** @var array<string, mixed> */
protected $_platformOptions = []; protected $_platformOptions = [];
/** @var string|null */ /** @var string|null */
...@@ -52,13 +52,13 @@ class Column extends AbstractAsset ...@@ -52,13 +52,13 @@ class Column extends AbstractAsset
/** @var string|null */ /** @var string|null */
protected $_comment; protected $_comment;
/** @var mixed[] */ /** @var array<string, mixed> */
protected $_customSchemaOptions = []; protected $_customSchemaOptions = [];
/** /**
* Creates a new Column. * Creates a new Column.
* *
* @param mixed[] $options * @param array<string, mixed> $options
*/ */
public function __construct(string $name, Type $type, array $options = []) public function __construct(string $name, Type $type, array $options = [])
{ {
...@@ -68,7 +68,7 @@ class Column extends AbstractAsset ...@@ -68,7 +68,7 @@ class Column extends AbstractAsset
} }
/** /**
* @param mixed[] $options * @param array<string, mixed> $options
*/ */
public function setOptions(array $options) : self public function setOptions(array $options) : self
{ {
...@@ -154,7 +154,7 @@ class Column extends AbstractAsset ...@@ -154,7 +154,7 @@ class Column extends AbstractAsset
} }
/** /**
* @param mixed[] $platformOptions * @param array<string, mixed> $platformOptions
*/ */
public function setPlatformOptions(array $platformOptions) : self public function setPlatformOptions(array $platformOptions) : self
{ {
...@@ -224,7 +224,7 @@ class Column extends AbstractAsset ...@@ -224,7 +224,7 @@ class Column extends AbstractAsset
} }
/** /**
* @return mixed[] * @return array<string, mixed>
*/ */
public function getPlatformOptions() : array public function getPlatformOptions() : array
{ {
...@@ -297,7 +297,7 @@ class Column extends AbstractAsset ...@@ -297,7 +297,7 @@ class Column extends AbstractAsset
} }
/** /**
* @param mixed[] $customSchemaOptions * @param array<string, mixed> $customSchemaOptions
*/ */
public function setCustomSchemaOptions(array $customSchemaOptions) : self public function setCustomSchemaOptions(array $customSchemaOptions) : self
{ {
...@@ -307,7 +307,7 @@ class Column extends AbstractAsset ...@@ -307,7 +307,7 @@ class Column extends AbstractAsset
} }
/** /**
* @return mixed[] * @return array<string, mixed>
*/ */
public function getCustomSchemaOptions() : array public function getCustomSchemaOptions() : array
{ {
...@@ -315,7 +315,7 @@ class Column extends AbstractAsset ...@@ -315,7 +315,7 @@ class Column extends AbstractAsset
} }
/** /**
* @return mixed[] * @return array<string, mixed>
*/ */
public function toArray() : array public function toArray() : array
{ {
......
...@@ -17,17 +17,16 @@ class ColumnDiff ...@@ -17,17 +17,16 @@ class ColumnDiff
/** @var Column */ /** @var Column */
public $column; public $column;
/** @var string[] */ /** @var array<int, string> */
public $changedProperties = []; public $changedProperties = [];
/** @var Column|null */ /** @var Column|null */
public $fromColumn; public $fromColumn;
/** /**
* @param string $oldColumnName * @param array<string> $changedProperties
* @param string[] $changedProperties
*/ */
public function __construct($oldColumnName, Column $column, array $changedProperties = [], ?Column $fromColumn = null) public function __construct(string $oldColumnName, Column $column, array $changedProperties = [], ?Column $fromColumn = null)
{ {
$this->oldColumnName = $oldColumnName; $this->oldColumnName = $oldColumnName;
$this->column = $column; $this->column = $column;
...@@ -35,20 +34,12 @@ class ColumnDiff ...@@ -35,20 +34,12 @@ class ColumnDiff
$this->fromColumn = $fromColumn; $this->fromColumn = $fromColumn;
} }
/** public function hasChanged(string $propertyName) : bool
* @param string $propertyName
*
* @return bool
*/
public function hasChanged($propertyName)
{ {
return in_array($propertyName, $this->changedProperties); return in_array($propertyName, $this->changedProperties);
} }
/** public function getOldColumnName() : Identifier
* @return Identifier
*/
public function getOldColumnName()
{ {
$quote = $this->fromColumn && $this->fromColumn->isQuoted(); $quote = $this->fromColumn && $this->fromColumn->isQuoted();
......
...@@ -21,10 +21,7 @@ use function strtolower; ...@@ -21,10 +21,7 @@ use function strtolower;
*/ */
class Comparator class Comparator
{ {
/** public static function compareSchemas(Schema $fromSchema, Schema $toSchema) : SchemaDiff
* @return SchemaDiff
*/
public static function compareSchemas(Schema $fromSchema, Schema $toSchema)
{ {
$c = new self(); $c = new self();
...@@ -37,10 +34,8 @@ class Comparator ...@@ -37,10 +34,8 @@ class Comparator
* The returned differences are returned in such a way that they contain the * The returned differences are returned in such a way that they contain the
* operations to change the schema stored in $fromSchema to the schema that is * operations to change the schema stored in $fromSchema to the schema that is
* stored in $toSchema. * stored in $toSchema.
*
* @return SchemaDiff
*/ */
public function compare(Schema $fromSchema, Schema $toSchema) public function compare(Schema $fromSchema, Schema $toSchema) : SchemaDiff
{ {
$diff = new SchemaDiff(); $diff = new SchemaDiff();
$diff->fromSchema = $fromSchema; $diff->fromSchema = $fromSchema;
...@@ -69,7 +64,7 @@ class Comparator ...@@ -69,7 +64,7 @@ class Comparator
$diff->newTables[$tableName] = $toSchema->getTable($tableName); $diff->newTables[$tableName] = $toSchema->getTable($tableName);
} else { } else {
$tableDifferences = $this->diffTable($fromSchema->getTable($tableName), $toSchema->getTable($tableName)); $tableDifferences = $this->diffTable($fromSchema->getTable($tableName), $toSchema->getTable($tableName));
if ($tableDifferences !== false) { if ($tableDifferences !== null) {
$diff->changedTables[$tableName] = $tableDifferences; $diff->changedTables[$tableName] = $tableDifferences;
} }
} }
...@@ -152,13 +147,7 @@ class Comparator ...@@ -152,13 +147,7 @@ class Comparator
return $diff; return $diff;
} }
/** private function isAutoIncrementSequenceInSchema(Schema $schema, Sequence $sequence) : bool
* @param Schema $schema
* @param Sequence $sequence
*
* @return bool
*/
private function isAutoIncrementSequenceInSchema($schema, $sequence)
{ {
foreach ($schema->getTables() as $table) { foreach ($schema->getTables() as $table) {
if ($sequence->isAutoIncrementsFor($table)) { if ($sequence->isAutoIncrementsFor($table)) {
...@@ -169,10 +158,7 @@ class Comparator ...@@ -169,10 +158,7 @@ class Comparator
return false; return false;
} }
/** public function diffSequence(Sequence $sequence1, Sequence $sequence2) : bool
* @return bool
*/
public function diffSequence(Sequence $sequence1, Sequence $sequence2)
{ {
if ($sequence1->getAllocationSize() !== $sequence2->getAllocationSize()) { if ($sequence1->getAllocationSize() !== $sequence2->getAllocationSize()) {
return true; return true;
...@@ -185,10 +171,8 @@ class Comparator ...@@ -185,10 +171,8 @@ class Comparator
* Returns the difference between the tables $table1 and $table2. * Returns the difference between the tables $table1 and $table2.
* *
* If there are no differences this method returns the boolean false. * If there are no differences this method returns the boolean false.
*
* @return TableDiff|false
*/ */
public function diffTable(Table $table1, Table $table2) public function diffTable(Table $table1, Table $table2) : ?TableDiff
{ {
$changes = 0; $changes = 0;
$tableDifferences = new TableDiff($table1->getName()); $tableDifferences = new TableDiff($table1->getName());
...@@ -294,16 +278,14 @@ class Comparator ...@@ -294,16 +278,14 @@ class Comparator
$changes++; $changes++;
} }
return $changes ? $tableDifferences : false; return $changes ? $tableDifferences : null;
} }
/** /**
* Try to find columns that only changed their name, rename operations maybe cheaper than add/drop * Try to find columns that only changed their name, rename operations maybe cheaper than add/drop
* however ambiguities between different possibilities should not lead to renaming at all. * however ambiguities between different possibilities should not lead to renaming at all.
*
* @return void
*/ */
private function detectColumnRenamings(TableDiff $tableDifferences) private function detectColumnRenamings(TableDiff $tableDifferences) : void
{ {
$renameCandidates = []; $renameCandidates = [];
foreach ($tableDifferences->addedColumns as $addedColumnName => $addedColumn) { foreach ($tableDifferences->addedColumns as $addedColumnName => $addedColumn) {
...@@ -340,10 +322,8 @@ class Comparator ...@@ -340,10 +322,8 @@ class Comparator
/** /**
* Try to find indexes that only changed their name, rename operations maybe cheaper than add/drop * Try to find indexes that only changed their name, rename operations maybe cheaper than add/drop
* however ambiguities between different possibilities should not lead to renaming at all. * however ambiguities between different possibilities should not lead to renaming at all.
*
* @return void
*/ */
private function detectIndexRenamings(TableDiff $tableDifferences) private function detectIndexRenamings(TableDiff $tableDifferences) : void
{ {
$renameCandidates = []; $renameCandidates = [];
...@@ -384,10 +364,7 @@ class Comparator ...@@ -384,10 +364,7 @@ class Comparator
} }
} }
/** public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2) : bool
* @return bool
*/
public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2)
{ {
if (array_map('strtolower', $key1->getUnquotedLocalColumns()) !== array_map('strtolower', $key2->getUnquotedLocalColumns())) { if (array_map('strtolower', $key1->getUnquotedLocalColumns()) !== array_map('strtolower', $key2->getUnquotedLocalColumns())) {
return true; return true;
...@@ -414,9 +391,9 @@ class Comparator ...@@ -414,9 +391,9 @@ class Comparator
* If there are differences this method returns $field2, otherwise the * If there are differences this method returns $field2, otherwise the
* boolean false. * boolean false.
* *
* @return string[] * @return array<int, string>
*/ */
public function diffColumn(Column $column1, Column $column2) public function diffColumn(Column $column1, Column $column2) : array
{ {
$properties1 = $column1->toArray(); $properties1 = $column1->toArray();
$properties2 = $column2->toArray(); $properties2 = $column2->toArray();
...@@ -502,10 +479,8 @@ class Comparator ...@@ -502,10 +479,8 @@ class Comparator
* *
* Compares $index1 with $index2 and returns $index2 if there are any * Compares $index1 with $index2 and returns $index2 if there are any
* differences or false in case there are no differences. * differences or false in case there are no differences.
*
* @return bool
*/ */
public function diffIndex(Index $index1, Index $index2) public function diffIndex(Index $index1, Index $index2) : bool
{ {
return ! ($index1->isFullfilledBy($index2) && $index2->isFullfilledBy($index1)); return ! ($index1->isFullfilledBy($index2) && $index2->isFullfilledBy($index1));
} }
......
...@@ -11,23 +11,17 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; ...@@ -11,23 +11,17 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
*/ */
interface Constraint interface Constraint
{ {
/** public function getName() : string;
* @return string
*/
public function getName();
/** public function getQuotedName(AbstractPlatform $platform) : string;
* @return string
*/
public function getQuotedName(AbstractPlatform $platform);
/** /**
* Returns the names of the referencing table columns * Returns the names of the referencing table columns
* the constraint is associated with. * the constraint is associated with.
* *
* @return string[] * @return array<int, string>
*/ */
public function getColumns(); public function getColumns() : array;
/** /**
* Returns the quoted representation of the column names * Returns the quoted representation of the column names
...@@ -39,7 +33,7 @@ interface Constraint ...@@ -39,7 +33,7 @@ interface Constraint
* *
* @param AbstractPlatform $platform The platform to use for quotation. * @param AbstractPlatform $platform The platform to use for quotation.
* *
* @return string[] * @return array<int, string>
*/ */
public function getQuotedColumns(AbstractPlatform $platform); public function getQuotedColumns(AbstractPlatform $platform) : array;
} }
...@@ -43,7 +43,7 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -43,7 +43,7 @@ class DB2SchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableColumnDefinition($tableColumn) protected function _getPortableTableColumnDefinition(array $tableColumn) : Column
{ {
$tableColumn = array_change_key_case($tableColumn, CASE_LOWER); $tableColumn = array_change_key_case($tableColumn, CASE_LOWER);
...@@ -105,7 +105,7 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -105,7 +105,7 @@ class DB2SchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTablesList($tables) protected function _getPortableTablesList(array $tables) : array
{ {
$tableNames = []; $tableNames = [];
foreach ($tables as $tableRow) { foreach ($tables as $tableRow) {
...@@ -132,7 +132,7 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -132,7 +132,7 @@ class DB2SchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableForeignKeyDefinition($tableForeignKey) protected function _getPortableTableForeignKeyDefinition(array $tableForeignKey) : ForeignKeyConstraint
{ {
return new ForeignKeyConstraint( return new ForeignKeyConstraint(
$tableForeignKey['local_columns'], $tableForeignKey['local_columns'],
...@@ -146,7 +146,7 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -146,7 +146,7 @@ class DB2SchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableForeignKeysList($tableForeignKeys) protected function _getPortableTableForeignKeysList(array $tableForeignKeys) : array
{ {
$foreignKeys = []; $foreignKeys = [];
...@@ -176,7 +176,7 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -176,7 +176,7 @@ class DB2SchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableViewDefinition($view) protected function _getPortableViewDefinition(array $view) : View
{ {
$view = array_change_key_case($view, CASE_LOWER); $view = array_change_key_case($view, CASE_LOWER);
// sadly this still segfaults on PDO_IBM, see http://pecl.php.net/bugs/bug.php?id=17199 // sadly this still segfaults on PDO_IBM, see http://pecl.php.net/bugs/bug.php?id=17199
...@@ -191,7 +191,7 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -191,7 +191,7 @@ class DB2SchemaManager extends AbstractSchemaManager
return new View($view['name'], $sql); return new View($view['name'], $sql);
} }
public function listTableDetails($tableName) : Table public function listTableDetails(string $tableName) : Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
......
...@@ -27,9 +27,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -27,9 +27,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Asset identifier instances of the referencing table column names the foreign key constraint is associated with. * Asset identifier instances of the referencing table column names the foreign key constraint is associated with.
* array($columnName => Identifier)
* *
* @var Identifier[] * @var array<string, Identifier>
*/ */
protected $_localColumnNames; protected $_localColumnNames;
...@@ -42,27 +41,26 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -42,27 +41,26 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Asset identifier instances of the referenced table column names the foreign key constraint is associated with. * Asset identifier instances of the referenced table column names the foreign key constraint is associated with.
* array($columnName => Identifier)
* *
* @var Identifier[] * @var array<string, Identifier>
*/ */
protected $_foreignColumnNames; protected $_foreignColumnNames;
/** /**
* Options associated with the foreign key constraint. * Options associated with the foreign key constraint.
* *
* @var mixed[] * @var array<string, mixed>
*/ */
protected $_options; protected $_options;
/** /**
* Initializes the foreign key constraint. * Initializes the foreign key constraint.
* *
* @param string[] $localColumnNames Names of the referencing table columns. * @param array<int, string> $localColumnNames Names of the referencing table columns.
* @param Table|string $foreignTableName Referenced table. * @param Table|string $foreignTableName Referenced table.
* @param string[] $foreignColumnNames Names of the referenced table columns. * @param array<int, string> $foreignColumnNames Names of the referenced table columns.
* @param string|null $name Name of the foreign key constraint. * @param string|null $name Name of the foreign key constraint.
* @param mixed[] $options Options associated with the foreign key constraint. * @param array<string, mixed> $options Options associated with the foreign key constraint.
*/ */
public function __construct(array $localColumnNames, $foreignTableName, array $foreignColumnNames, $name = null, array $options = []) public function __construct(array $localColumnNames, $foreignTableName, array $foreignColumnNames, $name = null, array $options = [])
{ {
...@@ -83,9 +81,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -83,9 +81,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
} }
/** /**
* @param string[] $names * @param array<int, string> $names
* *
* @return Identifier[] * @return array<string, Identifier>
*/ */
private function createIdentifierMap(array $names) : array private function createIdentifierMap(array $names) : array
{ {
...@@ -101,10 +99,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -101,10 +99,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Returns the name of the referencing table * Returns the name of the referencing table
* the foreign key constraint is associated with. * the foreign key constraint is associated with.
*
* @return string
*/ */
public function getLocalTableName() public function getLocalTableName() : string
{ {
return $this->_localTable->getName(); return $this->_localTable->getName();
} }
...@@ -112,20 +108,13 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -112,20 +108,13 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Sets the Table instance of the referencing table * Sets the Table instance of the referencing table
* the foreign key constraint is associated with. * the foreign key constraint is associated with.
*
* @param Table $table Instance of the referencing table.
*
* @return void
*/ */
public function setLocalTable(Table $table) public function setLocalTable(Table $table) : void
{ {
$this->_localTable = $table; $this->_localTable = $table;
} }
/** public function getLocalTable() : Table
* @return Table
*/
public function getLocalTable()
{ {
return $this->_localTable; return $this->_localTable;
} }
...@@ -134,9 +123,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -134,9 +123,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* Returns the names of the referencing table columns * Returns the names of the referencing table columns
* the foreign key constraint is associated with. * the foreign key constraint is associated with.
* *
* @return string[] * @return array<int, string>
*/ */
public function getLocalColumns() public function getLocalColumns() : array
{ {
return array_keys($this->_localColumnNames); return array_keys($this->_localColumnNames);
} }
...@@ -151,9 +140,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -151,9 +140,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* *
* @param AbstractPlatform $platform The platform to use for quotation. * @param AbstractPlatform $platform The platform to use for quotation.
* *
* @return string[] * @return array<int, string>
*/ */
public function getQuotedLocalColumns(AbstractPlatform $platform) public function getQuotedLocalColumns(AbstractPlatform $platform) : array
{ {
$columns = []; $columns = [];
...@@ -167,9 +156,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -167,9 +156,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Returns unquoted representation of local table column names for comparison with other FK * Returns unquoted representation of local table column names for comparison with other FK
* *
* @return string[] * @return array<int, string>
*/ */
public function getUnquotedLocalColumns() public function getUnquotedLocalColumns() : array
{ {
return array_map([$this, 'trimQuotes'], $this->getLocalColumns()); return array_map([$this, 'trimQuotes'], $this->getLocalColumns());
} }
...@@ -177,9 +166,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -177,9 +166,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Returns unquoted representation of foreign table column names for comparison with other FK * Returns unquoted representation of foreign table column names for comparison with other FK
* *
* @return string[] * @return array<int, string>
*/ */
public function getUnquotedForeignColumns() public function getUnquotedForeignColumns() : array
{ {
return array_map([$this, 'trimQuotes'], $this->getForeignColumns()); return array_map([$this, 'trimQuotes'], $this->getForeignColumns());
} }
...@@ -189,7 +178,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -189,7 +178,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* *
* @see getLocalColumns * @see getLocalColumns
*/ */
public function getColumns() public function getColumns() : array
{ {
return $this->getLocalColumns(); return $this->getLocalColumns();
} }
...@@ -206,9 +195,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -206,9 +195,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* *
* @param AbstractPlatform $platform The platform to use for quotation. * @param AbstractPlatform $platform The platform to use for quotation.
* *
* @return string[] * @return array<int, string>
*/ */
public function getQuotedColumns(AbstractPlatform $platform) public function getQuotedColumns(AbstractPlatform $platform) : array
{ {
return $this->getQuotedLocalColumns($platform); return $this->getQuotedLocalColumns($platform);
} }
...@@ -216,20 +205,16 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -216,20 +205,16 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Returns the name of the referenced table * Returns the name of the referenced table
* the foreign key constraint is associated with. * the foreign key constraint is associated with.
*
* @return string
*/ */
public function getForeignTableName() public function getForeignTableName() : string
{ {
return $this->_foreignTableName->getName(); return $this->_foreignTableName->getName();
} }
/** /**
* Returns the non-schema qualified foreign table name. * Returns the non-schema qualified foreign table name.
*
* @return string
*/ */
public function getUnqualifiedForeignTableName() public function getUnqualifiedForeignTableName() : string
{ {
$name = $this->_foreignTableName->getName(); $name = $this->_foreignTableName->getName();
$position = strrpos($name, '.'); $position = strrpos($name, '.');
...@@ -250,10 +235,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -250,10 +235,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* Otherwise the plain unquoted value as inserted is returned. * Otherwise the plain unquoted value as inserted is returned.
* *
* @param AbstractPlatform $platform The platform to use for quotation. * @param AbstractPlatform $platform The platform to use for quotation.
*
* @return string
*/ */
public function getQuotedForeignTableName(AbstractPlatform $platform) public function getQuotedForeignTableName(AbstractPlatform $platform) : string
{ {
return $this->_foreignTableName->getQuotedName($platform); return $this->_foreignTableName->getQuotedName($platform);
} }
...@@ -262,9 +245,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -262,9 +245,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* Returns the names of the referenced table columns * Returns the names of the referenced table columns
* the foreign key constraint is associated with. * the foreign key constraint is associated with.
* *
* @return string[] * @return array<int, string>
*/ */
public function getForeignColumns() public function getForeignColumns() : array
{ {
return array_keys($this->_foreignColumnNames); return array_keys($this->_foreignColumnNames);
} }
...@@ -279,9 +262,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -279,9 +262,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* *
* @param AbstractPlatform $platform The platform to use for quotation. * @param AbstractPlatform $platform The platform to use for quotation.
* *
* @return string[] * @return array<int, string>
*/ */
public function getQuotedForeignColumns(AbstractPlatform $platform) public function getQuotedForeignColumns(AbstractPlatform $platform) : array
{ {
$columns = []; $columns = [];
...@@ -295,12 +278,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -295,12 +278,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Returns whether or not a given option * Returns whether or not a given option
* is associated with the foreign key constraint. * is associated with the foreign key constraint.
*
* @param string $name Name of the option to check.
*
* @return bool
*/ */
public function hasOption($name) public function hasOption(string $name) : bool
{ {
return isset($this->_options[$name]); return isset($this->_options[$name]);
} }
...@@ -308,11 +287,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -308,11 +287,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Returns an option associated with the foreign key constraint. * Returns an option associated with the foreign key constraint.
* *
* @param string $name Name of the option the foreign key constraint is associated with.
*
* @return mixed * @return mixed
*/ */
public function getOption($name) public function getOption(string $name)
{ {
return $this->_options[$name]; return $this->_options[$name];
} }
...@@ -320,9 +297,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -320,9 +297,9 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Returns the options associated with the foreign key constraint. * Returns the options associated with the foreign key constraint.
* *
* @return mixed[] * @return array<string, mixed>
*/ */
public function getOptions() public function getOptions() : array
{ {
return $this->_options; return $this->_options;
} }
...@@ -330,10 +307,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -330,10 +307,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Returns the referential action for UPDATE operations * Returns the referential action for UPDATE operations
* on the referenced table the foreign key constraint is associated with. * on the referenced table the foreign key constraint is associated with.
*
* @return string|null
*/ */
public function onUpdate() public function onUpdate() : ?string
{ {
return $this->onEvent('onUpdate'); return $this->onEvent('onUpdate');
} }
...@@ -341,10 +316,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -341,10 +316,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/** /**
* Returns the referential action for DELETE operations * Returns the referential action for DELETE operations
* on the referenced table the foreign key constraint is associated with. * on the referenced table the foreign key constraint is associated with.
*
* @return string|null
*/ */
public function onDelete() public function onDelete() : ?string
{ {
return $this->onEvent('onDelete'); return $this->onEvent('onDelete');
} }
...@@ -354,10 +327,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -354,10 +327,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* on the referenced table the foreign key constraint is associated with. * on the referenced table the foreign key constraint is associated with.
* *
* @param string $event Name of the database operation/event to return the referential action for. * @param string $event Name of the database operation/event to return the referential action for.
*
* @return string|null
*/ */
private function onEvent($event) private function onEvent(string $event) : ?string
{ {
if (isset($this->_options[$event])) { if (isset($this->_options[$event])) {
$onEvent = strtoupper($this->_options[$event]); $onEvent = strtoupper($this->_options[$event]);
...@@ -367,7 +338,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -367,7 +338,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
} }
} }
return false; return null;
} }
/** /**
...@@ -377,10 +348,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -377,10 +348,8 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* matches one of the given index's columns, `false` otherwise. * matches one of the given index's columns, `false` otherwise.
* *
* @param Index $index The index to be checked against. * @param Index $index The index to be checked against.
*
* @return bool
*/ */
public function intersectsIndexColumns(Index $index) public function intersectsIndexColumns(Index $index) : bool
{ {
foreach ($index->getColumns() as $indexColumn) { foreach ($index->getColumns() as $indexColumn) {
foreach ($this->_localColumnNames as $localColumn) { foreach ($this->_localColumnNames as $localColumn) {
......
...@@ -16,7 +16,7 @@ class Identifier extends AbstractAsset ...@@ -16,7 +16,7 @@ class Identifier extends AbstractAsset
* @param string $identifier Identifier name to wrap. * @param string $identifier Identifier name to wrap.
* @param bool $quote Whether to force quoting the given identifier. * @param bool $quote Whether to force quoting the given identifier.
*/ */
public function __construct($identifier, $quote = false) public function __construct(string $identifier, bool $quote = false)
{ {
$this->_setName($identifier); $this->_setName($identifier);
......
...@@ -5,23 +5,20 @@ declare(strict_types=1); ...@@ -5,23 +5,20 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use InvalidArgumentException;
use function array_filter; use function array_filter;
use function array_keys; use function array_keys;
use function array_map; use function array_map;
use function array_search; use function array_search;
use function array_shift; use function array_shift;
use function count; use function count;
use function is_string;
use function strtolower; use function strtolower;
class Index extends AbstractAsset implements Constraint class Index extends AbstractAsset implements Constraint
{ {
/** /**
* Asset identifier instances of the column names the index is associated with. * Asset identifier instances of the column names the index is associated with.
* array($columnName => Identifier)
* *
* @var Identifier[] * @var array<string, Identifier>
*/ */
protected $_columns = []; protected $_columns = [];
...@@ -33,9 +30,8 @@ class Index extends AbstractAsset implements Constraint ...@@ -33,9 +30,8 @@ class Index extends AbstractAsset implements Constraint
/** /**
* Platform specific flags for indexes. * Platform specific flags for indexes.
* array($flagName => true)
* *
* @var true[] * @var array<string, true>
*/ */
protected $_flags = []; protected $_flags = [];
...@@ -43,19 +39,16 @@ class Index extends AbstractAsset implements Constraint ...@@ -43,19 +39,16 @@ class Index extends AbstractAsset implements Constraint
* Platform specific options * Platform specific options
* *
* @todo $_flags should eventually be refactored into options * @todo $_flags should eventually be refactored into options
* @var mixed[] * @var array<string, mixed>
*/ */
private $options = []; private $options = [];
/** /**
* @param string $indexName * @param array<int, string> $columns
* @param string[] $columns * @param array<int, string> $flags
* @param bool $isUnique * @param array<string, mixed> $options
* @param bool $isPrimary
* @param string[] $flags
* @param mixed[] $options
*/ */
public function __construct($indexName, array $columns, $isUnique = false, $isPrimary = false, array $flags = [], array $options = []) public function __construct(?string $indexName, array $columns, bool $isUnique = false, bool $isPrimary = false, array $flags = [], array $options = [])
{ {
$isUnique = $isUnique || $isPrimary; $isUnique = $isUnique || $isPrimary;
...@@ -76,26 +69,15 @@ class Index extends AbstractAsset implements Constraint ...@@ -76,26 +69,15 @@ class Index extends AbstractAsset implements Constraint
} }
} }
/** protected function _addColumn(string $column) : void
* @param string $column
*
* @return void
*
* @throws InvalidArgumentException
*/
protected function _addColumn($column)
{ {
if (! is_string($column)) {
throw new InvalidArgumentException('Expecting a string as Index Column');
}
$this->_columns[$column] = new Identifier($column); $this->_columns[$column] = new Identifier($column);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getColumns() public function getColumns() : array
{ {
return array_keys($this->_columns); return array_keys($this->_columns);
} }
...@@ -103,7 +85,7 @@ class Index extends AbstractAsset implements Constraint ...@@ -103,7 +85,7 @@ class Index extends AbstractAsset implements Constraint
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getQuotedColumns(AbstractPlatform $platform) public function getQuotedColumns(AbstractPlatform $platform) : array
{ {
$subParts = $platform->supportsColumnLengthIndexes() && $this->hasOption('lengths') $subParts = $platform->supportsColumnLengthIndexes() && $this->hasOption('lengths')
? $this->getOption('lengths') : []; ? $this->getOption('lengths') : [];
...@@ -126,46 +108,32 @@ class Index extends AbstractAsset implements Constraint ...@@ -126,46 +108,32 @@ class Index extends AbstractAsset implements Constraint
} }
/** /**
* @return string[] * @return array<int, string>
*/ */
public function getUnquotedColumns() public function getUnquotedColumns() : array
{ {
return array_map([$this, 'trimQuotes'], $this->getColumns()); return array_map([$this, 'trimQuotes'], $this->getColumns());
} }
/** /**
* Is the index neither unique nor primary key? * Is the index neither unique nor primary key?
*
* @return bool
*/ */
public function isSimpleIndex() public function isSimpleIndex() : bool
{ {
return ! $this->_isPrimary && ! $this->_isUnique; return ! $this->_isPrimary && ! $this->_isUnique;
} }
/** public function isUnique() : bool
* @return bool
*/
public function isUnique()
{ {
return $this->_isUnique; return $this->_isUnique;
} }
/** public function isPrimary() : bool
* @return bool
*/
public function isPrimary()
{ {
return $this->_isPrimary; return $this->_isPrimary;
} }
/** public function hasColumnAtPosition(string $columnName, int $pos = 0) : bool
* @param string $columnName
* @param int $pos
*
* @return bool
*/
public function hasColumnAtPosition($columnName, $pos = 0)
{ {
$columnName = $this->trimQuotes(strtolower($columnName)); $columnName = $this->trimQuotes(strtolower($columnName));
$indexColumns = array_map('strtolower', $this->getUnquotedColumns()); $indexColumns = array_map('strtolower', $this->getUnquotedColumns());
...@@ -176,11 +144,9 @@ class Index extends AbstractAsset implements Constraint ...@@ -176,11 +144,9 @@ class Index extends AbstractAsset implements Constraint
/** /**
* Checks if this index exactly spans the given column names in the correct order. * Checks if this index exactly spans the given column names in the correct order.
* *
* @param string[] $columnNames * @param array<int, string> $columnNames
*
* @return bool
*/ */
public function spansColumns(array $columnNames) public function spansColumns(array $columnNames) : bool
{ {
$columns = $this->getColumns(); $columns = $this->getColumns();
$numberOfColumns = count($columns); $numberOfColumns = count($columns);
...@@ -199,10 +165,8 @@ class Index extends AbstractAsset implements Constraint ...@@ -199,10 +165,8 @@ class Index extends AbstractAsset implements Constraint
/** /**
* Checks if the other index already fulfills all the indexing and constraint needs of the current one. * Checks if the other index already fulfills all the indexing and constraint needs of the current one.
*
* @return bool
*/ */
public function isFullfilledBy(Index $other) public function isFullfilledBy(Index $other) : bool
{ {
// allow the other index to be equally large only. It being larger is an option // allow the other index to be equally large only. It being larger is an option
// but it creates a problem with scenarios of the kind PRIMARY KEY(foo,bar) UNIQUE(foo) // but it creates a problem with scenarios of the kind PRIMARY KEY(foo,bar) UNIQUE(foo)
...@@ -242,10 +206,8 @@ class Index extends AbstractAsset implements Constraint ...@@ -242,10 +206,8 @@ class Index extends AbstractAsset implements Constraint
/** /**
* Detects if the other index is a non-unique, non primary index that can be overwritten by this one. * Detects if the other index is a non-unique, non primary index that can be overwritten by this one.
*
* @return bool
*/ */
public function overrules(Index $other) public function overrules(Index $other) : bool
{ {
if ($other->isPrimary()) { if ($other->isPrimary()) {
return false; return false;
...@@ -261,9 +223,9 @@ class Index extends AbstractAsset implements Constraint ...@@ -261,9 +223,9 @@ class Index extends AbstractAsset implements Constraint
/** /**
* Returns platform specific flags for indexes. * Returns platform specific flags for indexes.
* *
* @return string[] * @return array<int, string>
*/ */
public function getFlags() public function getFlags() : array
{ {
return array_keys($this->_flags); return array_keys($this->_flags);
} }
...@@ -271,13 +233,9 @@ class Index extends AbstractAsset implements Constraint ...@@ -271,13 +233,9 @@ class Index extends AbstractAsset implements Constraint
/** /**
* Adds Flag for an index that translates to platform specific handling. * Adds Flag for an index that translates to platform specific handling.
* *
* @param string $flag
*
* @return Index
*
* @example $index->addFlag('CLUSTERED') * @example $index->addFlag('CLUSTERED')
*/ */
public function addFlag($flag) public function addFlag(string $flag) : self
{ {
$this->_flags[strtolower($flag)] = true; $this->_flags[strtolower($flag)] = true;
...@@ -286,62 +244,45 @@ class Index extends AbstractAsset implements Constraint ...@@ -286,62 +244,45 @@ class Index extends AbstractAsset implements Constraint
/** /**
* Does this index have a specific flag? * Does this index have a specific flag?
*
* @param string $flag
*
* @return bool
*/ */
public function hasFlag($flag) public function hasFlag(string $flag) : bool
{ {
return isset($this->_flags[strtolower($flag)]); return isset($this->_flags[strtolower($flag)]);
} }
/** /**
* Removes a flag. * Removes a flag.
*
* @param string $flag
*
* @return void
*/ */
public function removeFlag($flag) public function removeFlag(string $flag) : void
{ {
unset($this->_flags[strtolower($flag)]); unset($this->_flags[strtolower($flag)]);
} }
/** public function hasOption(string $name) : bool
* @param string $name
*
* @return bool
*/
public function hasOption($name)
{ {
return isset($this->options[strtolower($name)]); return isset($this->options[strtolower($name)]);
} }
/** /**
* @param string $name
*
* @return mixed * @return mixed
*/ */
public function getOption($name) public function getOption(string $name)
{ {
return $this->options[strtolower($name)]; return $this->options[strtolower($name)];
} }
/** /**
* @return mixed[] * @return array<string, mixed>
*/ */
public function getOptions() public function getOptions() : array
{ {
return $this->options; return $this->options;
} }
/** /**
* Return whether the two indexes have the same partial index * Return whether the two indexes have the same partial index
*
* @return bool
*/ */
private function samePartialIndex(Index $other) private function samePartialIndex(Index $other) : bool
{ {
if ($this->hasOption('where') && $other->hasOption('where') && $this->getOption('where') === $other->getOption('where')) { if ($this->hasOption('where') && $other->hasOption('where') && $this->getOption('where') === $other->getOption('where')) {
return true; return true;
......
...@@ -48,7 +48,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -48,7 +48,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableViewDefinition($view) protected function _getPortableViewDefinition(array $view) : View
{ {
return new View($view['TABLE_NAME'], $view['VIEW_DEFINITION']); return new View($view['TABLE_NAME'], $view['VIEW_DEFINITION']);
} }
...@@ -56,7 +56,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -56,7 +56,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableDefinition($table) protected function _getPortableTableDefinition(array $table) : string
{ {
return array_shift($table); return array_shift($table);
} }
...@@ -64,7 +64,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -64,7 +64,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableUserDefinition($user) protected function _getPortableUserDefinition(array $user) : array
{ {
return [ return [
'user' => $user['User'], 'user' => $user['User'],
...@@ -100,7 +100,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -100,7 +100,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableDatabaseDefinition($database) protected function _getPortableDatabaseDefinition(array $database) : string
{ {
return $database['Database']; return $database['Database'];
} }
...@@ -108,7 +108,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -108,7 +108,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableColumnDefinition($tableColumn) protected function _getPortableTableColumnDefinition(array $tableColumn) : Column
{ {
$tableColumn = array_change_key_case($tableColumn, CASE_LOWER); $tableColumn = array_change_key_case($tableColumn, CASE_LOWER);
...@@ -248,7 +248,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -248,7 +248,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableForeignKeysList($tableForeignKeys) protected function _getPortableTableForeignKeysList(array $tableForeignKeys) : array
{ {
$list = []; $list = [];
foreach ($tableForeignKeys as $value) { foreach ($tableForeignKeys as $value) {
...@@ -291,7 +291,10 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -291,7 +291,10 @@ class MySqlSchemaManager extends AbstractSchemaManager
return $result; return $result;
} }
public function listTableDetails($tableName) /**
* {@inheritdoc}
*/
public function listTableDetails(string $tableName) : Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
...@@ -322,7 +325,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -322,7 +325,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
} }
/** /**
* @return string[]|true[] * @return array<string, string>|array<string, true>
*/ */
private function parseCreateOptions(?string $string) : array private function parseCreateOptions(?string $string) : array
{ {
......
...@@ -29,7 +29,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -29,7 +29,7 @@ class OracleSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dropDatabase($database) public function dropDatabase(string $database) : void
{ {
try { try {
parent::dropDatabase($database); parent::dropDatabase($database);
...@@ -58,7 +58,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -58,7 +58,7 @@ class OracleSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableViewDefinition($view) protected function _getPortableViewDefinition(array $view) : View
{ {
$view = array_change_key_case($view, CASE_LOWER); $view = array_change_key_case($view, CASE_LOWER);
...@@ -68,7 +68,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -68,7 +68,7 @@ class OracleSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableUserDefinition($user) protected function _getPortableUserDefinition(array $user) : array
{ {
$user = array_change_key_case($user, CASE_LOWER); $user = array_change_key_case($user, CASE_LOWER);
...@@ -80,7 +80,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -80,7 +80,7 @@ class OracleSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableDefinition($table) protected function _getPortableTableDefinition(array $table) : string
{ {
$table = array_change_key_case($table, CASE_LOWER); $table = array_change_key_case($table, CASE_LOWER);
...@@ -120,7 +120,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -120,7 +120,7 @@ class OracleSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableColumnDefinition($tableColumn) protected function _getPortableTableColumnDefinition(array $tableColumn) : Column
{ {
$tableColumn = array_change_key_case($tableColumn, CASE_LOWER); $tableColumn = array_change_key_case($tableColumn, CASE_LOWER);
...@@ -211,7 +211,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -211,7 +211,7 @@ class OracleSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableForeignKeysList($tableForeignKeys) protected function _getPortableTableForeignKeysList(array $tableForeignKeys) : array
{ {
$list = []; $list = [];
foreach ($tableForeignKeys as $value) { foreach ($tableForeignKeys as $value) {
...@@ -254,7 +254,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -254,7 +254,7 @@ class OracleSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableSequenceDefinition($sequence) protected function _getPortableSequenceDefinition(array $sequence) : Sequence
{ {
$sequence = array_change_key_case($sequence, CASE_LOWER); $sequence = array_change_key_case($sequence, CASE_LOWER);
...@@ -270,17 +270,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -270,17 +270,7 @@ class OracleSchemaManager extends AbstractSchemaManager
* *
* @deprecated * @deprecated
*/ */
protected function _getPortableFunctionDefinition($function) protected function _getPortableDatabaseDefinition(array $database) : string
{
$function = array_change_key_case($function, CASE_LOWER);
return $function['name'];
}
/**
* {@inheritdoc}
*/
protected function _getPortableDatabaseDefinition($database)
{ {
$database = array_change_key_case($database, CASE_LOWER); $database = array_change_key_case($database, CASE_LOWER);
...@@ -292,12 +282,8 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -292,12 +282,8 @@ class OracleSchemaManager extends AbstractSchemaManager
* *
* Calling this method without an argument or by passing NULL is deprecated. * Calling this method without an argument or by passing NULL is deprecated.
*/ */
public function createDatabase($database = null) public function createDatabase(string $database) : void
{ {
if ($database === null) {
$database = $this->_conn->getDatabase();
}
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$username = $database; $username = $database;
$password = $params['password']; $password = $params['password'];
...@@ -309,12 +295,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -309,12 +295,7 @@ class OracleSchemaManager extends AbstractSchemaManager
$this->_conn->executeUpdate($query); $this->_conn->executeUpdate($query);
} }
/** public function dropAutoincrement(string $table) : bool
* @param string $table
*
* @return bool
*/
public function dropAutoincrement($table)
{ {
assert($this->_platform instanceof OraclePlatform); assert($this->_platform instanceof OraclePlatform);
...@@ -329,7 +310,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -329,7 +310,7 @@ class OracleSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dropTable($name) public function dropTable(string $name) : void
{ {
$this->tryMethod('dropAutoincrement', $name); $this->tryMethod('dropAutoincrement', $name);
...@@ -341,12 +322,8 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -341,12 +322,8 @@ class OracleSchemaManager extends AbstractSchemaManager
* *
* Quotes non-uppercase identifiers explicitly to preserve case * Quotes non-uppercase identifiers explicitly to preserve case
* and thus make references to the particular identifier work. * and thus make references to the particular identifier work.
*
* @param string $identifier The identifier to quote.
*
* @return string The quoted identifier.
*/ */
private function getQuotedIdentifierName($identifier) private function getQuotedIdentifierName(string $identifier) : string
{ {
if (preg_match('/[a-z]/', $identifier)) { if (preg_match('/[a-z]/', $identifier)) {
return $this->_platform->quoteIdentifier($identifier); return $this->_platform->quoteIdentifier($identifier);
...@@ -361,10 +338,8 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -361,10 +338,8 @@ class OracleSchemaManager extends AbstractSchemaManager
* This is useful to force DROP USER operations which could fail because of active user sessions. * This is useful to force DROP USER operations which could fail because of active user sessions.
* *
* @param string $user The name of the user to kill sessions for. * @param string $user The name of the user to kill sessions for.
*
* @return void
*/ */
private function killUserSessions($user) private function killUserSessions(string $user) : void
{ {
$sql = <<<SQL $sql = <<<SQL
SELECT SELECT
...@@ -393,7 +368,7 @@ SQL; ...@@ -393,7 +368,7 @@ SQL;
} }
} }
public function listTableDetails($tableName) : Table public function listTableDetails(string $tableName) : Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
......
...@@ -32,15 +32,15 @@ use function trim; ...@@ -32,15 +32,15 @@ use function trim;
*/ */
class PostgreSqlSchemaManager extends AbstractSchemaManager class PostgreSqlSchemaManager extends AbstractSchemaManager
{ {
/** @var string[] */ /** @var array<int, string> */
private $existingSchemaPaths; private $existingSchemaPaths;
/** /**
* Gets all the existing schema names. * Gets all the existing schema names.
* *
* @return string[] * @return array<int, string>
*/ */
public function getSchemaNames() public function getSchemaNames() : array
{ {
$statement = $this->_conn->executeQuery("SELECT nspname FROM pg_namespace WHERE nspname !~ '^pg_.*' AND nspname != 'information_schema'"); $statement = $this->_conn->executeQuery("SELECT nspname FROM pg_namespace WHERE nspname !~ '^pg_.*' AND nspname != 'information_schema'");
...@@ -52,9 +52,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -52,9 +52,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
* *
* This is a PostgreSQL only function. * This is a PostgreSQL only function.
* *
* @return string[] * @return array<int, string>
*/ */
public function getSchemaSearchPaths() public function getSchemaSearchPaths() : array
{ {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$schema = explode(',', $this->_conn->fetchColumn('SHOW search_path')); $schema = explode(',', $this->_conn->fetchColumn('SHOW search_path'));
...@@ -71,9 +71,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -71,9 +71,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
* *
* This is a PostgreSQL only function. * This is a PostgreSQL only function.
* *
* @return string[] * @return array<int, string>
*/ */
public function getExistingSchemaSearchPaths() public function getExistingSchemaSearchPaths() : array
{ {
if ($this->existingSchemaPaths === null) { if ($this->existingSchemaPaths === null) {
$this->determineExistingSchemaSearchPaths(); $this->determineExistingSchemaSearchPaths();
...@@ -86,10 +86,8 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -86,10 +86,8 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
* Sets or resets the order of the existing schemas in the current search path of the user. * Sets or resets the order of the existing schemas in the current search path of the user.
* *
* This is a PostgreSQL only function. * This is a PostgreSQL only function.
*
* @return void
*/ */
public function determineExistingSchemaSearchPaths() public function determineExistingSchemaSearchPaths() : void
{ {
$names = $this->getSchemaNames(); $names = $this->getSchemaNames();
$paths = $this->getSchemaSearchPaths(); $paths = $this->getSchemaSearchPaths();
...@@ -102,7 +100,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -102,7 +100,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dropDatabase($database) public function dropDatabase(string $database) : void
{ {
try { try {
parent::dropDatabase($database); parent::dropDatabase($database);
...@@ -131,7 +129,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -131,7 +129,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableForeignKeyDefinition($tableForeignKey) protected function _getPortableTableForeignKeyDefinition(array $tableForeignKey) : ForeignKeyConstraint
{ {
$onUpdate = null; $onUpdate = null;
$onDelete = null; $onDelete = null;
...@@ -166,7 +164,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -166,7 +164,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTriggerDefinition($trigger) protected function _getPortableTriggerDefinition(array $trigger) : string
{ {
return $trigger['trigger_name']; return $trigger['trigger_name'];
} }
...@@ -174,7 +172,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -174,7 +172,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableViewDefinition($view) protected function _getPortableViewDefinition(array $view) : View
{ {
return new View($view['schemaname'] . '.' . $view['viewname'], $view['definition']); return new View($view['schemaname'] . '.' . $view['viewname'], $view['definition']);
} }
...@@ -182,7 +180,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -182,7 +180,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableUserDefinition($user) protected function _getPortableUserDefinition(array $user) : array
{ {
return [ return [
'user' => $user['usename'], 'user' => $user['usename'],
...@@ -193,7 +191,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -193,7 +191,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableDefinition($table) protected function _getPortableTableDefinition(array $table) : string
{ {
$schemas = $this->getExistingSchemaSearchPaths(); $schemas = $this->getExistingSchemaSearchPaths();
$firstSchema = array_shift($schemas); $firstSchema = array_shift($schemas);
...@@ -248,7 +246,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -248,7 +246,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableDatabaseDefinition($database) protected function _getPortableDatabaseDefinition(array $database) : string
{ {
return $database['datname']; return $database['datname'];
} }
...@@ -256,7 +254,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -256,7 +254,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableSequencesList($sequences) protected function _getPortableSequencesList(array $sequences) : array
{ {
$sequenceDefinitions = []; $sequenceDefinitions = [];
...@@ -282,7 +280,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -282,7 +280,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getPortableNamespaceDefinition(array $namespace) protected function getPortableNamespaceDefinition(array $namespace) : string
{ {
return $namespace['nspname']; return $namespace['nspname'];
} }
...@@ -290,7 +288,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -290,7 +288,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableSequenceDefinition($sequence) protected function _getPortableSequenceDefinition(array $sequence) : Sequence
{ {
if ($sequence['schemaname'] !== 'public') { if ($sequence['schemaname'] !== 'public') {
$sequenceName = $sequence['schemaname'] . '.' . $sequence['relname']; $sequenceName = $sequence['schemaname'] . '.' . $sequence['relname'];
...@@ -311,7 +309,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -311,7 +309,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableColumnDefinition($tableColumn) protected function _getPortableTableColumnDefinition(array $tableColumn) : Column
{ {
$tableColumn = array_change_key_case($tableColumn, CASE_LOWER); $tableColumn = array_change_key_case($tableColumn, CASE_LOWER);
...@@ -493,7 +491,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -493,7 +491,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
return str_replace("''", "'", $default); return str_replace("''", "'", $default);
} }
public function listTableDetails($tableName) : Table public function listTableDetails(string $tableName) : Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
......
...@@ -24,7 +24,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -24,7 +24,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
* *
* @see startDatabase * @see startDatabase
*/ */
public function createDatabase($database) public function createDatabase(string $database) : void
{ {
parent::createDatabase($database); parent::createDatabase($database);
$this->startDatabase($database); $this->startDatabase($database);
...@@ -39,29 +39,19 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -39,29 +39,19 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
* *
* @see stopDatabase * @see stopDatabase
*/ */
public function dropDatabase($database) public function dropDatabase(string $database) : void
{ {
$this->tryMethod('stopDatabase', $database); $this->tryMethod('stopDatabase', $database);
parent::dropDatabase($database); parent::dropDatabase($database);
} }
/** public function startDatabase(string $database)
* Starts a database.
*
* @param string $database The name of the database to start.
*/
public function startDatabase($database)
{ {
assert($this->_platform instanceof SQLAnywherePlatform); assert($this->_platform instanceof SQLAnywherePlatform);
$this->_execSql($this->_platform->getStartDatabaseSQL($database)); $this->_execSql($this->_platform->getStartDatabaseSQL($database));
} }
/** public function stopDatabase(string $database)
* Stops a database.
*
* @param string $database The name of the database to stop.
*/
public function stopDatabase($database)
{ {
assert($this->_platform instanceof SQLAnywherePlatform); assert($this->_platform instanceof SQLAnywherePlatform);
$this->_execSql($this->_platform->getStopDatabaseSQL($database)); $this->_execSql($this->_platform->getStopDatabaseSQL($database));
...@@ -70,7 +60,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -70,7 +60,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableDatabaseDefinition($database) protected function _getPortableDatabaseDefinition(array $database) : string
{ {
return $database['name']; return $database['name'];
} }
...@@ -78,7 +68,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -78,7 +68,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableSequenceDefinition($sequence) protected function _getPortableSequenceDefinition(array $sequence) : Sequence
{ {
return new Sequence($sequence['sequence_name'], $sequence['increment_by'], $sequence['start_with']); return new Sequence($sequence['sequence_name'], $sequence['increment_by'], $sequence['start_with']);
} }
...@@ -86,7 +76,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -86,7 +76,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableColumnDefinition($tableColumn) protected function _getPortableTableColumnDefinition(array $tableColumn) : Column
{ {
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment']) $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'])
?? $this->_platform->getDoctrineTypeMapping($tableColumn['type']); ?? $this->_platform->getDoctrineTypeMapping($tableColumn['type']);
...@@ -141,7 +131,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -141,7 +131,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableDefinition($table) protected function _getPortableTableDefinition(array $table) : string
{ {
return $table['table_name']; return $table['table_name'];
} }
...@@ -149,7 +139,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -149,7 +139,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableForeignKeyDefinition($tableForeignKey) protected function _getPortableTableForeignKeyDefinition(array $tableForeignKey) : ForeignKeyConstraint
{ {
return new ForeignKeyConstraint( return new ForeignKeyConstraint(
$tableForeignKey['local_columns'], $tableForeignKey['local_columns'],
...@@ -163,7 +153,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -163,7 +153,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableForeignKeysList($tableForeignKeys) protected function _getPortableTableForeignKeysList(array $tableForeignKeys) : array
{ {
$foreignKeys = []; $foreignKeys = [];
...@@ -223,7 +213,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -223,7 +213,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableViewDefinition($view) protected function _getPortableViewDefinition(array $view) : View
{ {
$definition = preg_replace('/^.*\s+as\s+SELECT(.*)/i', 'SELECT$1', $view['view_def']); $definition = preg_replace('/^.*\s+as\s+SELECT(.*)/i', 'SELECT$1', $view['view_def']);
assert(is_string($definition)); assert(is_string($definition));
......
...@@ -28,7 +28,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -28,7 +28,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dropDatabase($database) public function dropDatabase(string $database) : void
{ {
try { try {
parent::dropDatabase($database); parent::dropDatabase($database);
...@@ -57,7 +57,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -57,7 +57,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableSequenceDefinition($sequence) protected function _getPortableSequenceDefinition(array $sequence) : Sequence
{ {
return new Sequence($sequence['name'], (int) $sequence['increment'], (int) $sequence['start_value']); return new Sequence($sequence['name'], (int) $sequence['increment'], (int) $sequence['start_value']);
} }
...@@ -65,7 +65,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -65,7 +65,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableColumnDefinition($tableColumn) protected function _getPortableTableColumnDefinition(array $tableColumn) : Column
{ {
$dbType = strtok($tableColumn['type'], '(), '); $dbType = strtok($tableColumn['type'], '(), ');
assert(is_string($dbType)); assert(is_string($dbType));
...@@ -159,7 +159,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -159,7 +159,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableForeignKeysList($tableForeignKeys) protected function _getPortableTableForeignKeysList(array $tableForeignKeys) : array
{ {
$foreignKeys = []; $foreignKeys = [];
...@@ -201,7 +201,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -201,7 +201,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableForeignKeyDefinition($tableForeignKey) protected function _getPortableTableForeignKeyDefinition(array $tableForeignKey) : ForeignKeyConstraint
{ {
return new ForeignKeyConstraint( return new ForeignKeyConstraint(
$tableForeignKey['local_columns'], $tableForeignKey['local_columns'],
...@@ -215,7 +215,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -215,7 +215,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableDefinition($table) protected function _getPortableTableDefinition(array $table) : string
{ {
if (isset($table['schema_name']) && $table['schema_name'] !== 'dbo') { if (isset($table['schema_name']) && $table['schema_name'] !== 'dbo') {
return $table['schema_name'] . '.' . $table['name']; return $table['schema_name'] . '.' . $table['name'];
...@@ -227,7 +227,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -227,7 +227,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableDatabaseDefinition($database) protected function _getPortableDatabaseDefinition(array $database) : string
{ {
return $database['name']; return $database['name'];
} }
...@@ -235,7 +235,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -235,7 +235,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getPortableNamespaceDefinition(array $namespace) protected function getPortableNamespaceDefinition(array $namespace) : string
{ {
return $namespace['name']; return $namespace['name'];
} }
...@@ -243,7 +243,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -243,7 +243,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableViewDefinition($view) protected function _getPortableViewDefinition(array $view) : View
{ {
// @todo // @todo
return new View($view['name'], ''); return new View($view['name'], '');
...@@ -252,7 +252,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -252,7 +252,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function listTableIndexes($table) public function listTableIndexes(string $table) : array
{ {
$sql = $this->_platform->getListTableIndexesSQL($table, $this->_conn->getDatabase()); $sql = $this->_platform->getListTableIndexesSQL($table, $this->_conn->getDatabase());
...@@ -278,7 +278,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -278,7 +278,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function alterTable(TableDiff $tableDiff) public function alterTable(TableDiff $tableDiff) : void
{ {
if (count($tableDiff->removedColumns) > 0) { if (count($tableDiff->removedColumns) > 0) {
foreach ($tableDiff->removedColumns as $col) { foreach ($tableDiff->removedColumns as $col) {
...@@ -300,13 +300,8 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -300,13 +300,8 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* Returns the SQL to retrieve the constraints for a given column. * Returns the SQL to retrieve the constraints for a given column.
*
* @param string $table
* @param string $column
*
* @return string
*/ */
private function getColumnConstraintSQL($table, $column) private function getColumnConstraintSQL(string $table, string $column) : string
{ {
return "SELECT SysObjects.[Name] return "SELECT SysObjects.[Name]
FROM SysObjects INNER JOIN (SELECT [Name],[ID] FROM SysObjects WHERE XType = 'U') AS Tab FROM SysObjects INNER JOIN (SELECT [Name],[ID] FROM SysObjects WHERE XType = 'U') AS Tab
...@@ -321,12 +316,8 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -321,12 +316,8 @@ class SQLServerSchemaManager extends AbstractSchemaManager
* Closes currently active connections on the given database. * Closes currently active connections on the given database.
* *
* This is useful to force DROP DATABASE operations which could fail because of active connections. * This is useful to force DROP DATABASE operations which could fail because of active connections.
*
* @param string $database The name of the database to close currently active connections for.
*
* @return void
*/ */
private function closeActiveDatabaseConnections($database) private function closeActiveDatabaseConnections(string $database) : void
{ {
$database = new Identifier($database); $database = new Identifier($database);
...@@ -338,10 +329,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -338,10 +329,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
); );
} }
/** public function listTableDetails(string $tableName) : Table
* @param string $tableName
*/
public function listTableDetails($tableName) : Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
......
...@@ -47,23 +47,23 @@ class Schema extends AbstractAsset ...@@ -47,23 +47,23 @@ class Schema extends AbstractAsset
/** /**
* The namespaces in this schema. * The namespaces in this schema.
* *
* @var string[] * @var array<string, string>
*/ */
private $namespaces = []; private $namespaces = [];
/** @var Table[] */ /** @var array<string, Table> */
protected $_tables = []; protected $_tables = [];
/** @var Sequence[] */ /** @var array<string, Sequence> */
protected $_sequences = []; protected $_sequences = [];
/** @var SchemaConfig */ /** @var SchemaConfig */
protected $_schemaConfig = false; protected $_schemaConfig;
/** /**
* @param Table[] $tables * @param array<Table> $tables
* @param Sequence[] $sequences * @param array<Sequence> $sequences
* @param string[] $namespaces * @param array<string> $namespaces
*/ */
public function __construct( public function __construct(
array $tables = [], array $tables = [],
...@@ -90,20 +90,15 @@ class Schema extends AbstractAsset ...@@ -90,20 +90,15 @@ class Schema extends AbstractAsset
} }
} }
/** public function hasExplicitForeignKeyIndexes() : bool
* @return bool
*/
public function hasExplicitForeignKeyIndexes()
{ {
return $this->_schemaConfig->hasExplicitForeignKeyIndexes(); return $this->_schemaConfig->hasExplicitForeignKeyIndexes();
} }
/** /**
* @return void
*
* @throws SchemaException * @throws SchemaException
*/ */
protected function _addTable(Table $table) protected function _addTable(Table $table) : void
{ {
$namespaceName = $table->getNamespaceName(); $namespaceName = $table->getNamespaceName();
$tableName = $table->getFullQualifiedName($this->getName()); $tableName = $table->getFullQualifiedName($this->getName());
...@@ -123,11 +118,9 @@ class Schema extends AbstractAsset ...@@ -123,11 +118,9 @@ class Schema extends AbstractAsset
} }
/** /**
* @return void
*
* @throws SchemaException * @throws SchemaException
*/ */
protected function _addSequence(Sequence $sequence) protected function _addSequence(Sequence $sequence) : void
{ {
$namespaceName = $sequence->getNamespaceName(); $namespaceName = $sequence->getNamespaceName();
$seqName = $sequence->getFullQualifiedName($this->getName()); $seqName = $sequence->getFullQualifiedName($this->getName());
...@@ -148,9 +141,9 @@ class Schema extends AbstractAsset ...@@ -148,9 +141,9 @@ class Schema extends AbstractAsset
/** /**
* Returns the namespaces of this schema. * Returns the namespaces of this schema.
* *
* @return string[] A list of namespace names. * @return array<string, string> A list of namespace names.
*/ */
public function getNamespaces() public function getNamespaces() : array
{ {
return $this->namespaces; return $this->namespaces;
} }
...@@ -158,21 +151,17 @@ class Schema extends AbstractAsset ...@@ -158,21 +151,17 @@ class Schema extends AbstractAsset
/** /**
* Gets all tables of this schema. * Gets all tables of this schema.
* *
* @return Table[] * @return array<string, Table>
*/ */
public function getTables() public function getTables() : array
{ {
return $this->_tables; return $this->_tables;
} }
/** /**
* @param string $tableName
*
* @return Table
*
* @throws SchemaException * @throws SchemaException
*/ */
public function getTable($tableName) public function getTable(string $tableName) : Table
{ {
$tableName = $this->getFullQualifiedAssetName($tableName); $tableName = $this->getFullQualifiedAssetName($tableName);
if (! isset($this->_tables[$tableName])) { if (! isset($this->_tables[$tableName])) {
...@@ -182,12 +171,7 @@ class Schema extends AbstractAsset ...@@ -182,12 +171,7 @@ class Schema extends AbstractAsset
return $this->_tables[$tableName]; return $this->_tables[$tableName];
} }
/** private function getFullQualifiedAssetName(string $name) : string
* @param string $name
*
* @return string
*/
private function getFullQualifiedAssetName($name)
{ {
$name = $this->getUnquotedAssetName($name); $name = $this->getUnquotedAssetName($name);
...@@ -200,12 +184,8 @@ class Schema extends AbstractAsset ...@@ -200,12 +184,8 @@ class Schema extends AbstractAsset
/** /**
* Returns the unquoted representation of a given asset name. * Returns the unquoted representation of a given asset name.
*
* @param string $assetName Quoted or unquoted representation of an asset name.
*
* @return string
*/ */
private function getUnquotedAssetName($assetName) private function getUnquotedAssetName(string $assetName) : string
{ {
if ($this->isIdentifierQuoted($assetName)) { if ($this->isIdentifierQuoted($assetName)) {
return $this->trimQuotes($assetName); return $this->trimQuotes($assetName);
...@@ -216,12 +196,8 @@ class Schema extends AbstractAsset ...@@ -216,12 +196,8 @@ class Schema extends AbstractAsset
/** /**
* Does this schema have a namespace with the given name? * Does this schema have a namespace with the given name?
*
* @param string $namespaceName
*
* @return bool
*/ */
public function hasNamespace($namespaceName) public function hasNamespace(string $namespaceName) : bool
{ {
$namespaceName = strtolower($this->getUnquotedAssetName($namespaceName)); $namespaceName = strtolower($this->getUnquotedAssetName($namespaceName));
...@@ -230,12 +206,8 @@ class Schema extends AbstractAsset ...@@ -230,12 +206,8 @@ class Schema extends AbstractAsset
/** /**
* Does this schema have a table with the given name? * Does this schema have a table with the given name?
*
* @param string $tableName
*
* @return bool
*/ */
public function hasTable($tableName) public function hasTable(string $tableName) : bool
{ {
$tableName = $this->getFullQualifiedAssetName($tableName); $tableName = $this->getFullQualifiedAssetName($tableName);
...@@ -245,19 +217,14 @@ class Schema extends AbstractAsset ...@@ -245,19 +217,14 @@ class Schema extends AbstractAsset
/** /**
* Gets all table names, prefixed with a schema name, even the default one if present. * Gets all table names, prefixed with a schema name, even the default one if present.
* *
* @return string[] * @return array<int, string>
*/ */
public function getTableNames() public function getTableNames() : array
{ {
return array_keys($this->_tables); return array_keys($this->_tables);
} }
/** public function hasSequence(string $sequenceName) : bool
* @param string $sequenceName
*
* @return bool
*/
public function hasSequence($sequenceName)
{ {
$sequenceName = $this->getFullQualifiedAssetName($sequenceName); $sequenceName = $this->getFullQualifiedAssetName($sequenceName);
...@@ -265,13 +232,9 @@ class Schema extends AbstractAsset ...@@ -265,13 +232,9 @@ class Schema extends AbstractAsset
} }
/** /**
* @param string $sequenceName
*
* @return Sequence
*
* @throws SchemaException * @throws SchemaException
*/ */
public function getSequence($sequenceName) public function getSequence(string $sequenceName) : Sequence
{ {
$sequenceName = $this->getFullQualifiedAssetName($sequenceName); $sequenceName = $this->getFullQualifiedAssetName($sequenceName);
if (! $this->hasSequence($sequenceName)) { if (! $this->hasSequence($sequenceName)) {
...@@ -282,9 +245,9 @@ class Schema extends AbstractAsset ...@@ -282,9 +245,9 @@ class Schema extends AbstractAsset
} }
/** /**
* @return Sequence[] * @return array<string, Sequence>
*/ */
public function getSequences() public function getSequences() : array
{ {
return $this->_sequences; return $this->_sequences;
} }
...@@ -292,13 +255,11 @@ class Schema extends AbstractAsset ...@@ -292,13 +255,11 @@ class Schema extends AbstractAsset
/** /**
* Creates a new namespace. * Creates a new namespace.
* *
* @param string $namespaceName The name of the namespace to create. * @return $this
*
* @return \Doctrine\DBAL\Schema\Schema This schema instance.
* *
* @throws SchemaException * @throws SchemaException
*/ */
public function createNamespace($namespaceName) public function createNamespace(string $namespaceName) : self
{ {
$unquotedNamespaceName = strtolower($this->getUnquotedAssetName($namespaceName)); $unquotedNamespaceName = strtolower($this->getUnquotedAssetName($namespaceName));
...@@ -313,12 +274,8 @@ class Schema extends AbstractAsset ...@@ -313,12 +274,8 @@ class Schema extends AbstractAsset
/** /**
* Creates a new table. * Creates a new table.
*
* @param string $tableName
*
* @return Table
*/ */
public function createTable($tableName) public function createTable(string $tableName) : Table
{ {
$table = new Table($tableName); $table = new Table($tableName);
$this->_addTable($table); $this->_addTable($table);
...@@ -333,12 +290,9 @@ class Schema extends AbstractAsset ...@@ -333,12 +290,9 @@ class Schema extends AbstractAsset
/** /**
* Renames a table. * Renames a table.
* *
* @param string $oldTableName * @return $this
* @param string $newTableName
*
* @return \Doctrine\DBAL\Schema\Schema
*/ */
public function renameTable($oldTableName, $newTableName) public function renameTable(string $oldTableName, string $newTableName) : self
{ {
$table = $this->getTable($oldTableName); $table = $this->getTable($oldTableName);
$table->_setName($newTableName); $table->_setName($newTableName);
...@@ -352,11 +306,9 @@ class Schema extends AbstractAsset ...@@ -352,11 +306,9 @@ class Schema extends AbstractAsset
/** /**
* Drops a table from the schema. * Drops a table from the schema.
* *
* @param string $tableName * @return $this
*
* @return \Doctrine\DBAL\Schema\Schema
*/ */
public function dropTable($tableName) public function dropTable(string $tableName) : self
{ {
$tableName = $this->getFullQualifiedAssetName($tableName); $tableName = $this->getFullQualifiedAssetName($tableName);
$this->getTable($tableName); $this->getTable($tableName);
...@@ -367,14 +319,8 @@ class Schema extends AbstractAsset ...@@ -367,14 +319,8 @@ class Schema extends AbstractAsset
/** /**
* Creates a new sequence. * Creates a new sequence.
*
* @param string $sequenceName
* @param int $allocationSize
* @param int $initialValue
*
* @return Sequence
*/ */
public function createSequence($sequenceName, $allocationSize = 1, $initialValue = 1) public function createSequence(string $sequenceName, int $allocationSize = 1, int $initialValue = 1) : Sequence
{ {
$seq = new Sequence($sequenceName, $allocationSize, $initialValue); $seq = new Sequence($sequenceName, $allocationSize, $initialValue);
$this->_addSequence($seq); $this->_addSequence($seq);
...@@ -383,11 +329,9 @@ class Schema extends AbstractAsset ...@@ -383,11 +329,9 @@ class Schema extends AbstractAsset
} }
/** /**
* @param string $sequenceName * @return $this
*
* @return \Doctrine\DBAL\Schema\Schema
*/ */
public function dropSequence($sequenceName) public function dropSequence(string $sequenceName) : self
{ {
$sequenceName = $this->getFullQualifiedAssetName($sequenceName); $sequenceName = $this->getFullQualifiedAssetName($sequenceName);
unset($this->_sequences[$sequenceName]); unset($this->_sequences[$sequenceName]);
...@@ -398,9 +342,9 @@ class Schema extends AbstractAsset ...@@ -398,9 +342,9 @@ class Schema extends AbstractAsset
/** /**
* Returns an array of necessary SQL queries to create the schema on the given platform. * Returns an array of necessary SQL queries to create the schema on the given platform.
* *
* @return string[] * @return array<int, string>
*/ */
public function toSql(AbstractPlatform $platform) public function toSql(AbstractPlatform $platform) : array
{ {
$sqlCollector = new CreateSchemaSqlCollector($platform); $sqlCollector = new CreateSchemaSqlCollector($platform);
$this->visit($sqlCollector); $this->visit($sqlCollector);
...@@ -411,9 +355,9 @@ class Schema extends AbstractAsset ...@@ -411,9 +355,9 @@ class Schema extends AbstractAsset
/** /**
* Return an array of necessary SQL queries to drop the schema on the given platform. * Return an array of necessary SQL queries to drop the schema on the given platform.
* *
* @return string[] * @return array<int, string>
*/ */
public function toDropSql(AbstractPlatform $platform) public function toDropSql(AbstractPlatform $platform) : array
{ {
$dropSqlCollector = new DropSchemaSqlCollector($platform); $dropSqlCollector = new DropSchemaSqlCollector($platform);
$this->visit($dropSqlCollector); $this->visit($dropSqlCollector);
...@@ -422,9 +366,9 @@ class Schema extends AbstractAsset ...@@ -422,9 +366,9 @@ class Schema extends AbstractAsset
} }
/** /**
* @return string[] * @return array<int, string>
*/ */
public function getMigrateToSql(Schema $toSchema, AbstractPlatform $platform) public function getMigrateToSql(Schema $toSchema, AbstractPlatform $platform) : array
{ {
$comparator = new Comparator(); $comparator = new Comparator();
$schemaDiff = $comparator->compare($this, $toSchema); $schemaDiff = $comparator->compare($this, $toSchema);
...@@ -433,9 +377,9 @@ class Schema extends AbstractAsset ...@@ -433,9 +377,9 @@ class Schema extends AbstractAsset
} }
/** /**
* @return string[] * @return array<int, string>
*/ */
public function getMigrateFromSql(Schema $fromSchema, AbstractPlatform $platform) public function getMigrateFromSql(Schema $fromSchema, AbstractPlatform $platform) : array
{ {
$comparator = new Comparator(); $comparator = new Comparator();
$schemaDiff = $comparator->compare($fromSchema, $this); $schemaDiff = $comparator->compare($fromSchema, $this);
...@@ -443,10 +387,7 @@ class Schema extends AbstractAsset ...@@ -443,10 +387,7 @@ class Schema extends AbstractAsset
return $schemaDiff->toSql($platform); return $schemaDiff->toSql($platform);
} }
/** public function visit(Visitor $visitor) : void
* @return void
*/
public function visit(Visitor $visitor)
{ {
$visitor->acceptSchema($this); $visitor->acceptSchema($this);
......
...@@ -15,66 +15,44 @@ class SchemaConfig ...@@ -15,66 +15,44 @@ class SchemaConfig
/** @var int */ /** @var int */
protected $maxIdentifierLength = 63; protected $maxIdentifierLength = 63;
/** @var string */ /** @var string|null */
protected $name; protected $name;
/** @var mixed[] */ /** @var array<string, mixed> */
protected $defaultTableOptions = []; protected $defaultTableOptions = [];
/** public function hasExplicitForeignKeyIndexes() : bool
* @return bool
*/
public function hasExplicitForeignKeyIndexes()
{ {
return $this->hasExplicitForeignKeyIndexes; return $this->hasExplicitForeignKeyIndexes;
} }
/** public function setExplicitForeignKeyIndexes(bool $flag) : void
* @param bool $flag
*
* @return void
*/
public function setExplicitForeignKeyIndexes($flag)
{ {
$this->hasExplicitForeignKeyIndexes = (bool) $flag; $this->hasExplicitForeignKeyIndexes = $flag;
} }
/** public function setMaxIdentifierLength(int $length) : void
* @param int $length
*
* @return void
*/
public function setMaxIdentifierLength($length)
{ {
$this->maxIdentifierLength = (int) $length; $this->maxIdentifierLength = $length;
} }
/** public function getMaxIdentifierLength() : int
* @return int
*/
public function getMaxIdentifierLength()
{ {
return $this->maxIdentifierLength; return $this->maxIdentifierLength;
} }
/** /**
* Gets the default namespace of schema objects. * Gets the default namespace of schema objects.
*
* @return string
*/ */
public function getName() public function getName() : ?string
{ {
return $this->name; return $this->name;
} }
/** /**
* Sets the default namespace name of schema objects. * Sets the default namespace name of schema objects.
*
* @param string $name The value to set.
*
* @return void
*/ */
public function setName($name) public function setName(string $name) : void
{ {
$this->name = $name; $this->name = $name;
} }
...@@ -83,19 +61,17 @@ class SchemaConfig ...@@ -83,19 +61,17 @@ class SchemaConfig
* Gets the default options that are passed to Table instances created with * Gets the default options that are passed to Table instances created with
* Schema#createTable(). * Schema#createTable().
* *
* @return mixed[] * @return array<string, mixed>
*/ */
public function getDefaultTableOptions() public function getDefaultTableOptions() : array
{ {
return $this->defaultTableOptions; return $this->defaultTableOptions;
} }
/** /**
* @param mixed[] $defaultTableOptions * @param array<string, mixed> $defaultTableOptions
*
* @return void
*/ */
public function setDefaultTableOptions(array $defaultTableOptions) public function setDefaultTableOptions(array $defaultTableOptions) : void
{ {
$this->defaultTableOptions = $defaultTableOptions; $this->defaultTableOptions = $defaultTableOptions;
} }
......
...@@ -18,58 +18,58 @@ class SchemaDiff ...@@ -18,58 +18,58 @@ class SchemaDiff
/** /**
* All added namespaces. * All added namespaces.
* *
* @var string[] * @var array<string, string>
*/ */
public $newNamespaces = []; public $newNamespaces = [];
/** /**
* All removed namespaces. * All removed namespaces.
* *
* @var string[] * @var array<string, string>
*/ */
public $removedNamespaces = []; public $removedNamespaces = [];
/** /**
* All added tables. * All added tables.
* *
* @var Table[] * @var array<string, Table>
*/ */
public $newTables = []; public $newTables = [];
/** /**
* All changed tables. * All changed tables.
* *
* @var TableDiff[] * @var array<string, TableDiff>
*/ */
public $changedTables = []; public $changedTables = [];
/** /**
* All removed tables. * All removed tables.
* *
* @var Table[] * @var array<string, Table>
*/ */
public $removedTables = []; public $removedTables = [];
/** @var Sequence[] */ /** @var array<int, Sequence> */
public $newSequences = []; public $newSequences = [];
/** @var Sequence[] */ /** @var array<int, Sequence> */
public $changedSequences = []; public $changedSequences = [];
/** @var Sequence[] */ /** @var array<int, Sequence> */
public $removedSequences = []; public $removedSequences = [];
/** @var ForeignKeyConstraint[] */ /** @var array<string|int, ForeignKeyConstraint> */
public $orphanedForeignKeys = []; public $orphanedForeignKeys = [];
/** /**
* Constructs an SchemaDiff object. * Constructs an SchemaDiff object.
* *
* @param Table[] $newTables * @param array<string, Table> $newTables
* @param TableDiff[] $changedTables * @param array<string, TableDiff> $changedTables
* @param Table[] $removedTables * @param array<string, Table> $removedTables
*/ */
public function __construct($newTables = [], $changedTables = [], $removedTables = [], ?Schema $fromSchema = null) public function __construct(array $newTables = [], array $changedTables = [], array $removedTables = [], ?Schema $fromSchema = null)
{ {
$this->newTables = $newTables; $this->newTables = $newTables;
$this->changedTables = $changedTables; $this->changedTables = $changedTables;
...@@ -86,27 +86,25 @@ class SchemaDiff ...@@ -86,27 +86,25 @@ class SchemaDiff
* *
* This way it is ensured that assets are deleted which might not be relevant to the metadata schema at all. * This way it is ensured that assets are deleted which might not be relevant to the metadata schema at all.
* *
* @return string[] * @return array<int, string>
*/ */
public function toSaveSql(AbstractPlatform $platform) public function toSaveSql(AbstractPlatform $platform) : array
{ {
return $this->_toSql($platform, true); return $this->_toSql($platform, true);
} }
/** /**
* @return string[] * @return array<int, string>
*/ */
public function toSql(AbstractPlatform $platform) public function toSql(AbstractPlatform $platform) : array
{ {
return $this->_toSql($platform, false); return $this->_toSql($platform, false);
} }
/** /**
* @param bool $saveMode * @return array<int, string>
*
* @return string[]
*/ */
protected function _toSql(AbstractPlatform $platform, $saveMode = false) protected function _toSql(AbstractPlatform $platform, bool $saveMode = false) : array
{ {
$sql = []; $sql = [];
......
...@@ -22,13 +22,7 @@ class Sequence extends AbstractAsset ...@@ -22,13 +22,7 @@ class Sequence extends AbstractAsset
/** @var int|null */ /** @var int|null */
protected $cache = null; protected $cache = null;
/** public function __construct(string $name, int $allocationSize = 1, int $initialValue = 1, ?int $cache = null)
* @param string $name
* @param int $allocationSize
* @param int $initialValue
* @param int|null $cache
*/
public function __construct($name, $allocationSize = 1, $initialValue = 1, $cache = null)
{ {
$this->_setName($name); $this->_setName($name);
$this->setAllocationSize($allocationSize); $this->setAllocationSize($allocationSize);
...@@ -36,60 +30,36 @@ class Sequence extends AbstractAsset ...@@ -36,60 +30,36 @@ class Sequence extends AbstractAsset
$this->cache = $cache; $this->cache = $cache;
} }
/** public function getAllocationSize() : int
* @return int
*/
public function getAllocationSize()
{ {
return $this->allocationSize; return $this->allocationSize;
} }
/** public function getInitialValue() : int
* @return int
*/
public function getInitialValue()
{ {
return $this->initialValue; return $this->initialValue;
} }
/** public function getCache() : ?int
* @return int|null
*/
public function getCache()
{ {
return $this->cache; return $this->cache;
} }
/** public function setAllocationSize(int $allocationSize) : self
* @param int $allocationSize
*
* @return \Doctrine\DBAL\Schema\Sequence
*/
public function setAllocationSize($allocationSize)
{ {
$this->allocationSize = (int) $allocationSize ?: 1; $this->allocationSize = $allocationSize;
return $this; return $this;
} }
/** public function setInitialValue(int $initialValue) : self
* @param int $initialValue
*
* @return \Doctrine\DBAL\Schema\Sequence
*/
public function setInitialValue($initialValue)
{ {
$this->initialValue = (int) $initialValue ?: 1; $this->initialValue = $initialValue;
return $this; return $this;
} }
/** public function setCache(int $cache) : self
* @param int $cache
*
* @return \Doctrine\DBAL\Schema\Sequence
*/
public function setCache($cache)
{ {
$this->cache = $cache; $this->cache = $cache;
...@@ -101,10 +71,8 @@ class Sequence extends AbstractAsset ...@@ -101,10 +71,8 @@ class Sequence extends AbstractAsset
* *
* This is used inside the comparator to not report sequences as missing, * This is used inside the comparator to not report sequences as missing,
* when the "from" schema implicitly creates the sequences. * when the "from" schema implicitly creates the sequences.
*
* @return bool
*/ */
public function isAutoIncrementsFor(Table $table) public function isAutoIncrementsFor(Table $table) : bool
{ {
$primaryKey = $table->getPrimaryKey(); $primaryKey = $table->getPrimaryKey();
...@@ -131,10 +99,7 @@ class Sequence extends AbstractAsset ...@@ -131,10 +99,7 @@ class Sequence extends AbstractAsset
return $tableSequenceName === $sequenceName; return $tableSequenceName === $sequenceName;
} }
/** public function visit(Visitor $visitor) : void
* @return void
*/
public function visit(Visitor $visitor)
{ {
$visitor->acceptSequence($this); $visitor->acceptSequence($this);
} }
......
...@@ -4,7 +4,6 @@ declare(strict_types=1); ...@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\StringType;
...@@ -16,6 +15,7 @@ use function array_reverse; ...@@ -16,6 +15,7 @@ use function array_reverse;
use function array_values; use function array_values;
use function count; use function count;
use function file_exists; use function file_exists;
use function is_string;
use function preg_match; use function preg_match;
use function preg_match_all; use function preg_match_all;
use function preg_quote; use function preg_quote;
...@@ -37,7 +37,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -37,7 +37,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dropDatabase($database) public function dropDatabase(string $database) : void
{ {
if (! file_exists($database)) { if (! file_exists($database)) {
return; return;
...@@ -49,7 +49,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -49,7 +49,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function createDatabase($database) public function createDatabase(string $database) : void
{ {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$driver = $params['driver']; $driver = $params['driver'];
...@@ -65,7 +65,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -65,7 +65,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function renameTable($name, $newName) public function renameTable(string $name, string $newName) : void
{ {
$tableDiff = new TableDiff($name); $tableDiff = new TableDiff($name);
$tableDiff->fromTable = $this->listTableDetails($name); $tableDiff->fromTable = $this->listTableDetails($name);
...@@ -76,9 +76,12 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -76,9 +76,12 @@ class SqliteSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function createForeignKey(ForeignKeyConstraint $foreignKey, $table) public function createForeignKey(ForeignKeyConstraint $foreignKey, $table) : void
{ {
$tableDiff = $this->getTableDiffForAlterForeignKey($table); $table = $this->ensureTable($table);
$tableDiff = $this->getTableDiffForAlterForeignKey($table);
$tableDiff->addedForeignKeys[] = $foreignKey; $tableDiff->addedForeignKeys[] = $foreignKey;
$this->alterTable($tableDiff); $this->alterTable($tableDiff);
...@@ -87,9 +90,12 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -87,9 +90,12 @@ class SqliteSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, $table) public function dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, $table) : void
{ {
$tableDiff = $this->getTableDiffForAlterForeignKey($table); $table = $this->ensureTable($table);
$tableDiff = $this->getTableDiffForAlterForeignKey($table);
$tableDiff->changedForeignKeys[] = $foreignKey; $tableDiff->changedForeignKeys[] = $foreignKey;
$this->alterTable($tableDiff); $this->alterTable($tableDiff);
...@@ -98,10 +104,17 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -98,10 +104,17 @@ class SqliteSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dropForeignKey($foreignKey, $table) public function dropForeignKey($foreignKey, $table) : void
{ {
$tableDiff = $this->getTableDiffForAlterForeignKey($table); $table = $this->ensureTable($table);
$tableDiff->removedForeignKeys[] = $foreignKey;
$tableDiff = $this->getTableDiffForAlterForeignKey($table);
if (is_string($foreignKey)) {
$tableDiff->removedForeignKeys[] = $table->getForeignKey($foreignKey);
} else {
$tableDiff->removedForeignKeys[] = $foreignKey;
}
$this->alterTable($tableDiff); $this->alterTable($tableDiff);
} }
...@@ -109,7 +122,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -109,7 +122,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function listTableForeignKeys($table, $database = null) public function listTableForeignKeys(string $table, ?string $database = null) : array
{ {
if ($database === null) { if ($database === null) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
...@@ -154,7 +167,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -154,7 +167,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableDefinition($table) protected function _getPortableTableDefinition(array $table) : string
{ {
return $table['name']; return $table['name'];
} }
...@@ -228,18 +241,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -228,18 +241,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
* *
* @deprecated * @deprecated
*/ */
protected function _getPortableTableIndexDefinition($tableIndex) protected function _getPortableTableColumnList(string $table, string $database, array $tableColumns) : array
{
return [
'name' => $tableIndex['name'],
'unique' => (bool) $tableIndex['unique'],
];
}
/**
* {@inheritdoc}
*/
protected function _getPortableTableColumnList($table, $database, $tableColumns)
{ {
$list = parent::_getPortableTableColumnList($table, $database, $tableColumns); $list = parent::_getPortableTableColumnList($table, $database, $tableColumns);
...@@ -297,7 +299,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -297,7 +299,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableColumnDefinition($tableColumn) protected function _getPortableTableColumnDefinition(array $tableColumn) : Column
{ {
preg_match('/^([^()]*)\\s*(\\(((\\d+)(,\\s*(\\d+))?)\\))?/', $tableColumn['type'], $matches); preg_match('/^([^()]*)\\s*(\\(((\\d+)(,\\s*(\\d+))?)\\))?/', $tableColumn['type'], $matches);
...@@ -359,7 +361,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -359,7 +361,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableViewDefinition($view) protected function _getPortableViewDefinition(array $view) : View
{ {
return new View($view['name'], $view['sql']); return new View($view['name'], $view['sql']);
} }
...@@ -367,7 +369,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -367,7 +369,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _getPortableTableForeignKeysList($tableForeignKeys) protected function _getPortableTableForeignKeysList(array $tableForeignKeys) : array
{ {
$list = []; $list = [];
foreach ($tableForeignKeys as $value) { foreach ($tableForeignKeys as $value) {
...@@ -415,31 +417,26 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -415,31 +417,26 @@ class SqliteSchemaManager extends AbstractSchemaManager
return $result; return $result;
} }
/** private function getTableDiffForAlterForeignKey(Table $table) : TableDiff
* @param Table|string $table
*
* @return TableDiff
*
* @throws DBALException
*/
private function getTableDiffForAlterForeignKey($table)
{ {
if (! $table instanceof Table) {
$tableDetails = $this->tryMethod('listTableDetails', $table);
if ($tableDetails === false) {
throw new DBALException(sprintf('Sqlite schema manager requires to modify foreign keys table definition "%s".', $table));
}
$table = $tableDetails;
}
$tableDiff = new TableDiff($table->getName()); $tableDiff = new TableDiff($table->getName());
$tableDiff->fromTable = $table; $tableDiff->fromTable = $table;
return $tableDiff; return $tableDiff;
} }
/**
* @param string|Table $table
*/
private function ensureTable($table) : Table
{
if (is_string($table)) {
$table = $this->listTableDetails($table);
}
return $table;
}
private function parseColumnCollationFromSQL(string $column, string $sql) : ?string private function parseColumnCollationFromSQL(string $column, string $sql) : ?string
{ {
$pattern = '{(?:\W' . preg_quote($column) . '\W|\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) $pattern = '{(?:\W' . preg_quote($column) . '\W|\W' . preg_quote($this->_platform->quoteSingleIdentifier($column))
...@@ -505,10 +502,7 @@ SQL ...@@ -505,10 +502,7 @@ SQL
) ?: null; ) ?: null;
} }
/** public function listTableDetails(string $tableName) : Table
* @param string $tableName
*/
public function listTableDetails($tableName) : Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
......
...@@ -21,9 +21,9 @@ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer ...@@ -21,9 +21,9 @@ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
} }
/** /**
* @param string[] $sql * @param array<int, string> $sql
*/ */
protected function processSqlSafely(array $sql) protected function processSqlSafely(array $sql) : void
{ {
foreach ($sql as $s) { foreach ($sql as $s) {
try { try {
...@@ -34,9 +34,9 @@ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer ...@@ -34,9 +34,9 @@ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
} }
/** /**
* @param string[] $sql * @param array<int, string> $sql
*/ */
protected function processSql(array $sql) protected function processSql(array $sql) : void
{ {
foreach ($sql as $s) { foreach ($sql as $s) {
$this->conn->exec($s); $this->conn->exec($s);
......
...@@ -15,60 +15,48 @@ interface SchemaSynchronizer ...@@ -15,60 +15,48 @@ interface SchemaSynchronizer
/** /**
* Gets the SQL statements that can be executed to create the schema. * Gets the SQL statements that can be executed to create the schema.
* *
* @return string[] * @return array<int, string>
*/ */
public function getCreateSchema(Schema $createSchema); public function getCreateSchema(Schema $createSchema) : array;
/** /**
* Gets the SQL Statements to update given schema with the underlying db. * Gets the SQL Statements to update given schema with the underlying db.
* *
* @param bool $noDrops * @return array<int, string>
*
* @return string[]
*/ */
public function getUpdateSchema(Schema $toSchema, $noDrops = false); public function getUpdateSchema(Schema $toSchema, bool $noDrops = false) : array;
/** /**
* Gets the SQL Statements to drop the given schema from underlying db. * Gets the SQL Statements to drop the given schema from underlying db.
* *
* @return string[] * @return string[]
*/ */
public function getDropSchema(Schema $dropSchema); public function getDropSchema(Schema $dropSchema) : array;
/** /**
* Gets the SQL statements to drop all schema assets from underlying db. * Gets the SQL statements to drop all schema assets from underlying db.
* *
* @return string[] * @return array<int, string>
*/ */
public function getDropAllSchema(); public function getDropAllSchema() : array;
/** /**
* Creates the Schema. * Creates the Schema.
*
* @return void
*/ */
public function createSchema(Schema $createSchema); public function createSchema(Schema $createSchema) : void;
/** /**
* Updates the Schema to new schema version. * Updates the Schema to new schema version.
*
* @param bool $noDrops
*
* @return void
*/ */
public function updateSchema(Schema $toSchema, $noDrops = false); public function updateSchema(Schema $toSchema, bool $noDrops = false) : void;
/** /**
* Drops the given database schema from the underlying db. * Drops the given database schema from the underlying db.
*
* @return void
*/ */
public function dropSchema(Schema $dropSchema); public function dropSchema(Schema $dropSchema) : void;
/** /**
* Drops all assets from the underlying db. * Drops all assets from the underlying db.
*
* @return void
*/ */
public function dropAllSchema(); public function dropAllSchema() : void;
} }
...@@ -28,7 +28,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer ...@@ -28,7 +28,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getCreateSchema(Schema $createSchema) public function getCreateSchema(Schema $createSchema) : array
{ {
return $createSchema->toSql($this->platform); return $createSchema->toSql($this->platform);
} }
...@@ -36,7 +36,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer ...@@ -36,7 +36,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getUpdateSchema(Schema $toSchema, $noDrops = false) public function getUpdateSchema(Schema $toSchema, bool $noDrops = false) : array
{ {
$comparator = new Comparator(); $comparator = new Comparator();
$sm = $this->conn->getSchemaManager(); $sm = $this->conn->getSchemaManager();
...@@ -54,7 +54,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer ...@@ -54,7 +54,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDropSchema(Schema $dropSchema) public function getDropSchema(Schema $dropSchema) : array
{ {
$visitor = new DropSchemaSqlCollector($this->platform); $visitor = new DropSchemaSqlCollector($this->platform);
$sm = $this->conn->getSchemaManager(); $sm = $this->conn->getSchemaManager();
...@@ -114,7 +114,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer ...@@ -114,7 +114,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDropAllSchema() public function getDropAllSchema() : array
{ {
$sm = $this->conn->getSchemaManager(); $sm = $this->conn->getSchemaManager();
$visitor = new DropSchemaSqlCollector($this->platform); $visitor = new DropSchemaSqlCollector($this->platform);
...@@ -128,7 +128,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer ...@@ -128,7 +128,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function createSchema(Schema $createSchema) public function createSchema(Schema $createSchema) : void
{ {
$this->processSql($this->getCreateSchema($createSchema)); $this->processSql($this->getCreateSchema($createSchema));
} }
...@@ -136,7 +136,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer ...@@ -136,7 +136,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function updateSchema(Schema $toSchema, $noDrops = false) public function updateSchema(Schema $toSchema, bool $noDrops = false) : void
{ {
$this->processSql($this->getUpdateSchema($toSchema, $noDrops)); $this->processSql($this->getUpdateSchema($toSchema, $noDrops));
} }
...@@ -144,7 +144,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer ...@@ -144,7 +144,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dropSchema(Schema $dropSchema) public function dropSchema(Schema $dropSchema) : void
{ {
$this->processSqlSafely($this->getDropSchema($dropSchema)); $this->processSqlSafely($this->getDropSchema($dropSchema));
} }
...@@ -152,7 +152,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer ...@@ -152,7 +152,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dropAllSchema() public function dropAllSchema() : void
{ {
$this->processSql($this->getDropAllSchema()); $this->processSql($this->getDropAllSchema());
} }
......
...@@ -59,17 +59,16 @@ class Table extends AbstractAsset ...@@ -59,17 +59,16 @@ class Table extends AbstractAsset
protected $_schemaConfig = null; protected $_schemaConfig = null;
/** /**
* @param string $tableName * @param array<Column> $columns
* @param Column[] $columns * @param array<Index> $indexes
* @param Index[] $indexes * @param array<UniqueConstraint> $uniqueConstraints
* @param UniqueConstraint[] $uniqueConstraints * @param array<ForeignKeyConstraint> $fkConstraints
* @param ForeignKeyConstraint[] $fkConstraints * @param array<string, mixed> $options
* @param mixed[] $options
* *
* @throws DBALException * @throws DBALException
*/ */
public function __construct( public function __construct(
$tableName, string $tableName,
array $columns = [], array $columns = [],
array $indexes = [], array $indexes = [],
array $uniqueConstraints = [], array $uniqueConstraints = [],
...@@ -101,10 +100,7 @@ class Table extends AbstractAsset ...@@ -101,10 +100,7 @@ class Table extends AbstractAsset
$this->_options = array_merge($this->_options, $options); $this->_options = array_merge($this->_options, $options);
} }
/** public function setSchemaConfig(SchemaConfig $schemaConfig) : void
* @return void
*/
public function setSchemaConfig(SchemaConfig $schemaConfig)
{ {
$this->_schemaConfig = $schemaConfig; $this->_schemaConfig = $schemaConfig;
} }
...@@ -112,12 +108,9 @@ class Table extends AbstractAsset ...@@ -112,12 +108,9 @@ class Table extends AbstractAsset
/** /**
* Sets the Primary Key. * Sets the Primary Key.
* *
* @param string[] $columnNames * @param array<int, string> $columnNames
* @param string|false $indexName
*
* @return self
*/ */
public function setPrimaryKey(array $columnNames, $indexName = false) public function setPrimaryKey(array $columnNames, ?string $indexName = null) : self
{ {
$this->_addIndex($this->_createIndex($columnNames, $indexName ?: 'primary', true, true)); $this->_addIndex($this->_createIndex($columnNames, $indexName ?: 'primary', true, true));
...@@ -130,14 +123,11 @@ class Table extends AbstractAsset ...@@ -130,14 +123,11 @@ class Table extends AbstractAsset
} }
/** /**
* @param mixed[] $columnNames * @param array<int, string> $columnNames
* @param string|null $indexName * @param array<int, string> $flags
* @param string[] $flags * @param array<string, mixed> $options
* @param mixed[] $options
*
* @return self
*/ */
public function addUniqueConstraint(array $columnNames, $indexName = null, array $flags = [], array $options = []) public function addUniqueConstraint(array $columnNames, ?string $indexName = null, array $flags = [], array $options = []) : self
{ {
if ($indexName === null) { if ($indexName === null) {
$indexName = $this->_generateIdentifierName( $indexName = $this->_generateIdentifierName(
...@@ -151,14 +141,11 @@ class Table extends AbstractAsset ...@@ -151,14 +141,11 @@ class Table extends AbstractAsset
} }
/** /**
* @param string[] $columnNames * @param array<int, string> $columnNames
* @param string|null $indexName * @param array<int, string> $flags
* @param string[] $flags * @param array<string, mixed> $options
* @param mixed[] $options
*
* @return self
*/ */
public function addIndex(array $columnNames, $indexName = null, array $flags = [], array $options = []) public function addIndex(array $columnNames, ?string $indexName = null, array $flags = [], array $options = []) : self
{ {
if ($indexName === null) { if ($indexName === null) {
$indexName = $this->_generateIdentifierName( $indexName = $this->_generateIdentifierName(
...@@ -173,10 +160,8 @@ class Table extends AbstractAsset ...@@ -173,10 +160,8 @@ class Table extends AbstractAsset
/** /**
* Drops the primary key from this table. * Drops the primary key from this table.
*
* @return void
*/ */
public function dropPrimaryKey() public function dropPrimaryKey() : void
{ {
$this->dropIndex($this->_primaryKeyName); $this->dropIndex($this->_primaryKeyName);
$this->_primaryKeyName = false; $this->_primaryKeyName = false;
...@@ -185,13 +170,9 @@ class Table extends AbstractAsset ...@@ -185,13 +170,9 @@ class Table extends AbstractAsset
/** /**
* Drops an index from this table. * Drops an index from this table.
* *
* @param string $indexName The index name.
*
* @return void
*
* @throws SchemaException If the index does not exist. * @throws SchemaException If the index does not exist.
*/ */
public function dropIndex($indexName) public function dropIndex(string $indexName) : void
{ {
$indexName = $this->normalizeIdentifier($indexName); $indexName = $this->normalizeIdentifier($indexName);
...@@ -203,13 +184,10 @@ class Table extends AbstractAsset ...@@ -203,13 +184,10 @@ class Table extends AbstractAsset
} }
/** /**
* @param string[] $columnNames * @param array<int, string> $columnNames
* @param string|null $indexName * @param array<string, mixed> $options
* @param mixed[] $options
*
* @return self
*/ */
public function addUniqueIndex(array $columnNames, $indexName = null, array $options = []) public function addUniqueIndex(array $columnNames, ?string $indexName = null, array $options = []) : self
{ {
if ($indexName === null) { if ($indexName === null) {
$indexName = $this->_generateIdentifierName( $indexName = $this->_generateIdentifierName(
...@@ -229,12 +207,10 @@ class Table extends AbstractAsset ...@@ -229,12 +207,10 @@ class Table extends AbstractAsset
* @param string|null $newIndexName The name of the index to rename to. * @param string|null $newIndexName The name of the index to rename to.
* If null is given, the index name will be auto-generated. * If null is given, the index name will be auto-generated.
* *
* @return self This table instance.
*
* @throws SchemaException If no index exists for the given current name * @throws SchemaException If no index exists for the given current name
* or if an index with the given new name already exists on this table. * or if an index with the given new name already exists on this table.
*/ */
public function renameIndex($oldIndexName, $newIndexName = null) public function renameIndex(string $oldIndexName, ?string $newIndexName = null) : self
{ {
$oldIndexName = $this->normalizeIdentifier($oldIndexName); $oldIndexName = $this->normalizeIdentifier($oldIndexName);
$normalizedNewIndexName = $this->normalizeIdentifier($newIndexName); $normalizedNewIndexName = $this->normalizeIdentifier($newIndexName);
...@@ -256,7 +232,7 @@ class Table extends AbstractAsset ...@@ -256,7 +232,7 @@ class Table extends AbstractAsset
if ($oldIndex->isPrimary()) { if ($oldIndex->isPrimary()) {
$this->dropPrimaryKey(); $this->dropPrimaryKey();
return $this->setPrimaryKey($oldIndex->getColumns(), $newIndexName ?? false); return $this->setPrimaryKey($oldIndex->getColumns(), $newIndexName ?? null);
} }
unset($this->_indexes[$oldIndexName]); unset($this->_indexes[$oldIndexName]);
...@@ -271,11 +247,9 @@ class Table extends AbstractAsset ...@@ -271,11 +247,9 @@ class Table extends AbstractAsset
/** /**
* Checks if an index begins in the order of the given columns. * Checks if an index begins in the order of the given columns.
* *
* @param string[] $columnNames * @param array<int, string> $columnNames
*
* @return bool
*/ */
public function columnsAreIndexed(array $columnNames) public function columnsAreIndexed(array $columnNames) : bool
{ {
foreach ($this->getIndexes() as $index) { foreach ($this->getIndexes() as $index) {
/** @var $index Index */ /** @var $index Index */
...@@ -288,13 +262,9 @@ class Table extends AbstractAsset ...@@ -288,13 +262,9 @@ class Table extends AbstractAsset
} }
/** /**
* @param string $columnName * @param array<string, mixed> $options
* @param string $typeName
* @param mixed[] $options
*
* @return Column
*/ */
public function addColumn($columnName, $typeName, array $options = []) public function addColumn(string $columnName, string $typeName, array $options = []) : Column
{ {
$column = new Column($columnName, Type::getType($typeName), $options); $column = new Column($columnName, Type::getType($typeName), $options);
...@@ -306,12 +276,9 @@ class Table extends AbstractAsset ...@@ -306,12 +276,9 @@ class Table extends AbstractAsset
/** /**
* Change Column Details. * Change Column Details.
* *
* @param string $columnName * @param array<string, mixed> $options
* @param mixed[] $options
*
* @return self
*/ */
public function changeColumn($columnName, array $options) public function changeColumn(string $columnName, array $options) : self
{ {
$column = $this->getColumn($columnName); $column = $this->getColumn($columnName);
...@@ -322,12 +289,8 @@ class Table extends AbstractAsset ...@@ -322,12 +289,8 @@ class Table extends AbstractAsset
/** /**
* Drops a Column from the Table. * Drops a Column from the Table.
*
* @param string $columnName
*
* @return self
*/ */
public function dropColumn($columnName) public function dropColumn(string $columnName) : self
{ {
$columnName = $this->normalizeIdentifier($columnName); $columnName = $this->normalizeIdentifier($columnName);
...@@ -341,15 +304,12 @@ class Table extends AbstractAsset ...@@ -341,15 +304,12 @@ class Table extends AbstractAsset
* *
* Name is inferred from the local columns. * Name is inferred from the local columns.
* *
* @param Table|string $foreignTable Table schema instance or table name * @param Table|string $foreignTable Table schema instance or table name
* @param string[] $localColumnNames * @param array<int, string> $localColumnNames
* @param string[] $foreignColumnNames * @param array<int, string> $foreignColumnNames
* @param mixed[] $options * @param array<string, mixed> $options
* @param string|null $name
*
* @return self
*/ */
public function addForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = [], $name = null) public function addForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = [], ?string $name = null) : self
{ {
if (! $name) { if (! $name) {
$name = $this->_generateIdentifierName( $name = $this->_generateIdentifierName(
...@@ -385,12 +345,9 @@ class Table extends AbstractAsset ...@@ -385,12 +345,9 @@ class Table extends AbstractAsset
} }
/** /**
* @param string $name * @param mixed $value
* @param mixed $value
*
* @return self
*/ */
public function addOption($name, $value) public function addOption(string $name, $value) : self
{ {
$this->_options[$name] = $value; $this->_options[$name] = $value;
...@@ -399,12 +356,8 @@ class Table extends AbstractAsset ...@@ -399,12 +356,8 @@ class Table extends AbstractAsset
/** /**
* Returns whether this table has a foreign key constraint with the given name. * Returns whether this table has a foreign key constraint with the given name.
*
* @param string $constraintName
*
* @return bool
*/ */
public function hasForeignKey($constraintName) public function hasForeignKey(string $constraintName) : bool
{ {
$constraintName = $this->normalizeIdentifier($constraintName); $constraintName = $this->normalizeIdentifier($constraintName);
...@@ -414,13 +367,9 @@ class Table extends AbstractAsset ...@@ -414,13 +367,9 @@ class Table extends AbstractAsset
/** /**
* Returns the foreign key constraint with the given name. * Returns the foreign key constraint with the given name.
* *
* @param string $constraintName The constraint name.
*
* @return ForeignKeyConstraint
*
* @throws SchemaException If the foreign key does not exist. * @throws SchemaException If the foreign key does not exist.
*/ */
public function getForeignKey($constraintName) public function getForeignKey(string $constraintName) : ForeignKeyConstraint
{ {
$constraintName = $this->normalizeIdentifier($constraintName); $constraintName = $this->normalizeIdentifier($constraintName);
...@@ -434,13 +383,9 @@ class Table extends AbstractAsset ...@@ -434,13 +383,9 @@ class Table extends AbstractAsset
/** /**
* Removes the foreign key constraint with the given name. * Removes the foreign key constraint with the given name.
* *
* @param string $constraintName The constraint name.
*
* @return void
*
* @throws SchemaException * @throws SchemaException
*/ */
public function removeForeignKey($constraintName) public function removeForeignKey(string $constraintName) : void
{ {
$constraintName = $this->normalizeIdentifier($constraintName); $constraintName = $this->normalizeIdentifier($constraintName);
...@@ -453,12 +398,8 @@ class Table extends AbstractAsset ...@@ -453,12 +398,8 @@ class Table extends AbstractAsset
/** /**
* Returns whether this table has a unique constraint with the given name. * Returns whether this table has a unique constraint with the given name.
*
* @param string $constraintName
*
* @return bool
*/ */
public function hasUniqueConstraint($constraintName) public function hasUniqueConstraint(string $constraintName) : bool
{ {
$constraintName = $this->normalizeIdentifier($constraintName); $constraintName = $this->normalizeIdentifier($constraintName);
...@@ -468,13 +409,9 @@ class Table extends AbstractAsset ...@@ -468,13 +409,9 @@ class Table extends AbstractAsset
/** /**
* Returns the unique constraint with the given name. * Returns the unique constraint with the given name.
* *
* @param string $constraintName The constraint name.
*
* @return UniqueConstraint
*
* @throws SchemaException If the foreign key does not exist. * @throws SchemaException If the foreign key does not exist.
*/ */
public function getUniqueConstraint($constraintName) public function getUniqueConstraint(string $constraintName) : UniqueConstraint
{ {
$constraintName = $this->normalizeIdentifier($constraintName); $constraintName = $this->normalizeIdentifier($constraintName);
...@@ -488,13 +425,9 @@ class Table extends AbstractAsset ...@@ -488,13 +425,9 @@ class Table extends AbstractAsset
/** /**
* Removes the unique constraint with the given name. * Removes the unique constraint with the given name.
* *
* @param string $constraintName The constraint name.
*
* @return void
*
* @throws SchemaException * @throws SchemaException
*/ */
public function removeUniqueConstraint($constraintName) public function removeUniqueConstraint(string $constraintName) : void
{ {
$constraintName = $this->normalizeIdentifier($constraintName); $constraintName = $this->normalizeIdentifier($constraintName);
...@@ -508,9 +441,9 @@ class Table extends AbstractAsset ...@@ -508,9 +441,9 @@ class Table extends AbstractAsset
/** /**
* Returns ordered list of columns (primary keys are first, then foreign keys, then the rest) * Returns ordered list of columns (primary keys are first, then foreign keys, then the rest)
* *
* @return Column[] * @return array<string, Column>
*/ */
public function getColumns() public function getColumns() : array
{ {
$columns = $this->_columns; $columns = $this->_columns;
$pkCols = []; $pkCols = [];
...@@ -538,12 +471,8 @@ class Table extends AbstractAsset ...@@ -538,12 +471,8 @@ class Table extends AbstractAsset
/** /**
* Returns whether this table has a Column with the given name. * Returns whether this table has a Column with the given name.
*
* @param string $columnName The column name.
*
* @return bool
*/ */
public function hasColumn($columnName) public function hasColumn(string $columnName) : bool
{ {
$columnName = $this->normalizeIdentifier($columnName); $columnName = $this->normalizeIdentifier($columnName);
...@@ -553,13 +482,9 @@ class Table extends AbstractAsset ...@@ -553,13 +482,9 @@ class Table extends AbstractAsset
/** /**
* Returns the Column with the given name. * Returns the Column with the given name.
* *
* @param string $columnName The column name.
*
* @return Column
*
* @throws SchemaException If the column does not exist. * @throws SchemaException If the column does not exist.
*/ */
public function getColumn($columnName) public function getColumn(string $columnName) : Column
{ {
$columnName = $this->normalizeIdentifier($columnName); $columnName = $this->normalizeIdentifier($columnName);
...@@ -572,10 +497,8 @@ class Table extends AbstractAsset ...@@ -572,10 +497,8 @@ class Table extends AbstractAsset
/** /**
* Returns the primary key. * Returns the primary key.
*
* @return Index|null The primary key, or null if this Table has no primary key.
*/ */
public function getPrimaryKey() public function getPrimaryKey() : ?Index
{ {
return $this->hasPrimaryKey() return $this->hasPrimaryKey()
? $this->getIndex($this->_primaryKeyName) ? $this->getIndex($this->_primaryKeyName)
...@@ -585,11 +508,11 @@ class Table extends AbstractAsset ...@@ -585,11 +508,11 @@ class Table extends AbstractAsset
/** /**
* Returns the primary key columns. * Returns the primary key columns.
* *
* @return string[] * @return array<int, string>
* *
* @throws DBALException * @throws DBALException
*/ */
public function getPrimaryKeyColumns() public function getPrimaryKeyColumns() : array
{ {
$primaryKey = $this->getPrimaryKey(); $primaryKey = $this->getPrimaryKey();
...@@ -602,22 +525,16 @@ class Table extends AbstractAsset ...@@ -602,22 +525,16 @@ class Table extends AbstractAsset
/** /**
* Returns whether this table has a primary key. * Returns whether this table has a primary key.
*
* @return bool
*/ */
public function hasPrimaryKey() public function hasPrimaryKey() : bool
{ {
return $this->_primaryKeyName && $this->hasIndex($this->_primaryKeyName); return $this->_primaryKeyName && $this->hasIndex($this->_primaryKeyName);
} }
/** /**
* Returns whether this table has an Index with the given name. * Returns whether this table has an Index with the given name.
*
* @param string $indexName The index name.
*
* @return bool
*/ */
public function hasIndex($indexName) public function hasIndex(string $indexName) : bool
{ {
$indexName = $this->normalizeIdentifier($indexName); $indexName = $this->normalizeIdentifier($indexName);
...@@ -627,13 +544,9 @@ class Table extends AbstractAsset ...@@ -627,13 +544,9 @@ class Table extends AbstractAsset
/** /**
* Returns the Index with the given name. * Returns the Index with the given name.
* *
* @param string $indexName The index name.
*
* @return Index
*
* @throws SchemaException If the index does not exist. * @throws SchemaException If the index does not exist.
*/ */
public function getIndex($indexName) public function getIndex(string $indexName) : Index
{ {
$indexName = $this->normalizeIdentifier($indexName); $indexName = $this->normalizeIdentifier($indexName);
...@@ -645,9 +558,9 @@ class Table extends AbstractAsset ...@@ -645,9 +558,9 @@ class Table extends AbstractAsset
} }
/** /**
* @return Index[] * @return array<string, Index>
*/ */
public function getIndexes() public function getIndexes() : array
{ {
return $this->_indexes; return $this->_indexes;
} }
...@@ -655,9 +568,9 @@ class Table extends AbstractAsset ...@@ -655,9 +568,9 @@ class Table extends AbstractAsset
/** /**
* Returns the unique constraints. * Returns the unique constraints.
* *
* @return UniqueConstraint[] * @return array<string, UniqueConstraint>
*/ */
public function getUniqueConstraints() public function getUniqueConstraints() : array
{ {
return $this->_uniqueConstraints; return $this->_uniqueConstraints;
} }
...@@ -665,45 +578,35 @@ class Table extends AbstractAsset ...@@ -665,45 +578,35 @@ class Table extends AbstractAsset
/** /**
* Returns the foreign key constraints. * Returns the foreign key constraints.
* *
* @return ForeignKeyConstraint[] * @return array<string, ForeignKeyConstraint>
*/ */
public function getForeignKeys() public function getForeignKeys()
{ {
return $this->_fkConstraints; return $this->_fkConstraints;
} }
/** public function hasOption(string $name) : bool
* @param string $name
*
* @return bool
*/
public function hasOption($name)
{ {
return isset($this->_options[$name]); return isset($this->_options[$name]);
} }
/** /**
* @param string $name
*
* @return mixed * @return mixed
*/ */
public function getOption($name) public function getOption(string $name)
{ {
return $this->_options[$name]; return $this->_options[$name];
} }
/** /**
* @return mixed[] * @return array<string, mixed>
*/ */
public function getOptions() public function getOptions() : array
{ {
return $this->_options; return $this->_options;
} }
/** public function visit(Visitor $visitor) : void
* @return void
*/
public function visit(Visitor $visitor)
{ {
$visitor->acceptTable($this); $visitor->acceptTable($this);
...@@ -741,10 +644,7 @@ class Table extends AbstractAsset ...@@ -741,10 +644,7 @@ class Table extends AbstractAsset
} }
} }
/** protected function _getMaxIdentifierLength() : int
* @return int
*/
protected function _getMaxIdentifierLength()
{ {
return $this->_schemaConfig instanceof SchemaConfig return $this->_schemaConfig instanceof SchemaConfig
? $this->_schemaConfig->getMaxIdentifierLength() ? $this->_schemaConfig->getMaxIdentifierLength()
...@@ -752,11 +652,9 @@ class Table extends AbstractAsset ...@@ -752,11 +652,9 @@ class Table extends AbstractAsset
} }
/** /**
* @return void
*
* @throws SchemaException * @throws SchemaException
*/ */
protected function _addColumn(Column $column) protected function _addColumn(Column $column) : void
{ {
$columnName = $column->getName(); $columnName = $column->getName();
$columnName = $this->normalizeIdentifier($columnName); $columnName = $this->normalizeIdentifier($columnName);
...@@ -771,11 +669,9 @@ class Table extends AbstractAsset ...@@ -771,11 +669,9 @@ class Table extends AbstractAsset
/** /**
* Adds an index to the table. * Adds an index to the table.
* *
* @return self
*
* @throws SchemaException * @throws SchemaException
*/ */
protected function _addIndex(Index $indexCandidate) protected function _addIndex(Index $indexCandidate) : self
{ {
$indexName = $indexCandidate->getName(); $indexName = $indexCandidate->getName();
$indexName = $this->normalizeIdentifier($indexName); $indexName = $this->normalizeIdentifier($indexName);
...@@ -808,10 +704,7 @@ class Table extends AbstractAsset ...@@ -808,10 +704,7 @@ class Table extends AbstractAsset
return $this; return $this;
} }
/** protected function _addUniqueConstraint(UniqueConstraint $constraint) : self
* @return self
*/
protected function _addUniqueConstraint(UniqueConstraint $constraint)
{ {
$name = strlen($constraint->getName()) $name = strlen($constraint->getName())
? $constraint->getName() ? $constraint->getName()
...@@ -847,10 +740,7 @@ class Table extends AbstractAsset ...@@ -847,10 +740,7 @@ class Table extends AbstractAsset
return $this; return $this;
} }
/** protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint) : self
* @return self
*/
protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint)
{ {
$constraint->setLocalTable($this); $constraint->setLocalTable($this);
...@@ -894,12 +784,8 @@ class Table extends AbstractAsset ...@@ -894,12 +784,8 @@ class Table extends AbstractAsset
* Normalizes a given identifier. * Normalizes a given identifier.
* *
* Trims quotes and lowercases the given identifier. * Trims quotes and lowercases the given identifier.
*
* @param string|null $identifier The identifier to normalize.
*
* @return string The normalized identifier.
*/ */
private function normalizeIdentifier($identifier) private function normalizeIdentifier(?string $identifier) : string
{ {
if ($identifier === null) { if ($identifier === null) {
return ''; return '';
...@@ -922,16 +808,13 @@ class Table extends AbstractAsset ...@@ -922,16 +808,13 @@ class Table extends AbstractAsset
} }
/** /**
* @param mixed[] $columns * @param array<string|int, string> $columns
* @param string $indexName * @param array<int, string> $flags
* @param mixed[] $flags * @param array<string, mixed> $options
* @param mixed[] $options
*
* @return UniqueConstraint
* *
* @throws SchemaException * @throws SchemaException
*/ */
private function _createUniqueConstraint(array $columns, $indexName, array $flags = [], array $options = []) private function _createUniqueConstraint(array $columns, string $indexName, array $flags = [], array $options = []) : UniqueConstraint
{ {
if (preg_match('(([^a-zA-Z0-9_]+))', $this->normalizeIdentifier($indexName))) { if (preg_match('(([^a-zA-Z0-9_]+))', $this->normalizeIdentifier($indexName))) {
throw IndexNameInvalid::new($indexName); throw IndexNameInvalid::new($indexName);
...@@ -953,18 +836,13 @@ class Table extends AbstractAsset ...@@ -953,18 +836,13 @@ class Table extends AbstractAsset
} }
/** /**
* @param mixed[] $columns * @param array<string|int, string> $columns
* @param string $indexName * @param array<int, string> $flags
* @param bool $isUnique * @param array<string, mixed> $options
* @param bool $isPrimary
* @param string[] $flags
* @param mixed[] $options
*
* @return Index
* *
* @throws SchemaException * @throws SchemaException
*/ */
private function _createIndex(array $columns, $indexName, $isUnique, $isPrimary, array $flags = [], array $options = []) private function _createIndex(array $columns, string $indexName, bool $isUnique, bool $isPrimary, array $flags = [], array $options = []) : Index
{ {
if (preg_match('(([^a-zA-Z0-9_]+))', $this->normalizeIdentifier($indexName))) { if (preg_match('(([^a-zA-Z0-9_]+))', $this->normalizeIdentifier($indexName))) {
throw IndexNameInvalid::new($indexName); throw IndexNameInvalid::new($indexName);
......
...@@ -14,83 +14,83 @@ class TableDiff ...@@ -14,83 +14,83 @@ class TableDiff
/** @var string */ /** @var string */
public $name = null; public $name = null;
/** @var string|false */ /** @var string|null */
public $newName = false; public $newName = null;
/** /**
* All added fields. * All added fields.
* *
* @var Column[] * @var array<string, Column>
*/ */
public $addedColumns; public $addedColumns;
/** /**
* All changed fields. * All changed fields.
* *
* @var ColumnDiff[] * @var array<string, ColumnDiff>
*/ */
public $changedColumns = []; public $changedColumns = [];
/** /**
* All removed fields. * All removed fields.
* *
* @var Column[] * @var array<string, Column>
*/ */
public $removedColumns = []; public $removedColumns = [];
/** /**
* Columns that are only renamed from key to column instance name. * Columns that are only renamed from key to column instance name.
* *
* @var Column[] * @var array<string, Column>
*/ */
public $renamedColumns = []; public $renamedColumns = [];
/** /**
* All added indexes. * All added indexes.
* *
* @var Index[] * @var array<string, Index>
*/ */
public $addedIndexes = []; public $addedIndexes = [];
/** /**
* All changed indexes. * All changed indexes.
* *
* @var Index[] * @var array<string, Index>
*/ */
public $changedIndexes = []; public $changedIndexes = [];
/** /**
* All removed indexes * All removed indexes
* *
* @var Index[] * @var array<string, Index>
*/ */
public $removedIndexes = []; public $removedIndexes = [];
/** /**
* Indexes that are only renamed but are identical otherwise. * Indexes that are only renamed but are identical otherwise.
* *
* @var Index[] * @var array<string, Index>
*/ */
public $renamedIndexes = []; public $renamedIndexes = [];
/** /**
* All added foreign key definitions * All added foreign key definitions
* *
* @var ForeignKeyConstraint[] * @var array<int, ForeignKeyConstraint>
*/ */
public $addedForeignKeys = []; public $addedForeignKeys = [];
/** /**
* All changed foreign keys * All changed foreign keys
* *
* @var ForeignKeyConstraint[] * @var array<int, ForeignKeyConstraint>
*/ */
public $changedForeignKeys = []; public $changedForeignKeys = [];
/** /**
* All removed foreign keys * All removed foreign keys
* *
* @var ForeignKeyConstraint[]|string[] * @var array<int, ForeignKeyConstraint>
*/ */
public $removedForeignKeys = []; public $removedForeignKeys = [];
...@@ -100,22 +100,21 @@ class TableDiff ...@@ -100,22 +100,21 @@ class TableDiff
/** /**
* Constructs an TableDiff object. * Constructs an TableDiff object.
* *
* @param string $tableName * @param array<string, Column> $addedColumns
* @param Column[] $addedColumns * @param array<string, ColumnDiff> $changedColumns
* @param ColumnDiff[] $changedColumns * @param array<string, Column> $removedColumns
* @param Column[] $removedColumns * @param array<string, Index> $addedIndexes
* @param Index[] $addedIndexes * @param array<string, Index> $changedIndexes
* @param Index[] $changedIndexes * @param array<string, Index> $removedIndexes
* @param Index[] $removedIndexes
*/ */
public function __construct( public function __construct(
$tableName, string $tableName,
$addedColumns = [], array $addedColumns = [],
$changedColumns = [], array $changedColumns = [],
$removedColumns = [], array $removedColumns = [],
$addedIndexes = [], array $addedIndexes = [],
$changedIndexes = [], array $changedIndexes = [],
$removedIndexes = [], array $removedIndexes = [],
?Table $fromTable = null ?Table $fromTable = null
) { ) {
$this->name = $tableName; $this->name = $tableName;
...@@ -130,23 +129,18 @@ class TableDiff ...@@ -130,23 +129,18 @@ class TableDiff
/** /**
* @param AbstractPlatform $platform The platform to use for retrieving this table diff's name. * @param AbstractPlatform $platform The platform to use for retrieving this table diff's name.
*
* @return Identifier
*/ */
public function getName(AbstractPlatform $platform) public function getName(AbstractPlatform $platform) : Identifier
{ {
return new Identifier( return new Identifier(
$this->fromTable instanceof Table ? $this->fromTable->getQuotedName($platform) : $this->name $this->fromTable instanceof Table ? $this->fromTable->getQuotedName($platform) : $this->name
); );
} }
/** public function getNewName() : ?Identifier
* @return Identifier|false
*/
public function getNewName()
{ {
if ($this->newName === false) { if ($this->newName === null) {
return false; return null;
} }
return new Identifier($this->newName); return new Identifier($this->newName);
......
...@@ -16,34 +16,31 @@ class UniqueConstraint extends AbstractAsset implements Constraint ...@@ -16,34 +16,31 @@ class UniqueConstraint extends AbstractAsset implements Constraint
{ {
/** /**
* Asset identifier instances of the column names the unique constraint is associated with. * Asset identifier instances of the column names the unique constraint is associated with.
* array($columnName => Identifier)
* *
* @var Identifier[] * @var array<string, Identifier>
*/ */
protected $columns = []; protected $columns = [];
/** /**
* Platform specific flags * Platform specific flags
* array($flagName => true)
* *
* @var true[] * @var array<string, true>
*/ */
protected $flags = []; protected $flags = [];
/** /**
* Platform specific options * Platform specific options
* *
* @var mixed[] * @var array<string, mixed>
*/ */
private $options = []; private $options = [];
/** /**
* @param string $indexName * @param array<string> $columns
* @param string[] $columns * @param array<string> $flags
* @param string[] $flags * @param array<string, mixed> $options
* @param mixed[] $options
*/ */
public function __construct($indexName, array $columns, array $flags = [], array $options = []) public function __construct(string $indexName, array $columns, array $flags = [], array $options = [])
{ {
$this->_setName($indexName); $this->_setName($indexName);
...@@ -61,7 +58,7 @@ class UniqueConstraint extends AbstractAsset implements Constraint ...@@ -61,7 +58,7 @@ class UniqueConstraint extends AbstractAsset implements Constraint
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getColumns() public function getColumns() : array
{ {
return array_keys($this->columns); return array_keys($this->columns);
} }
...@@ -69,7 +66,7 @@ class UniqueConstraint extends AbstractAsset implements Constraint ...@@ -69,7 +66,7 @@ class UniqueConstraint extends AbstractAsset implements Constraint
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getQuotedColumns(AbstractPlatform $platform) public function getQuotedColumns(AbstractPlatform $platform) : array
{ {
$columns = []; $columns = [];
...@@ -81,9 +78,9 @@ class UniqueConstraint extends AbstractAsset implements Constraint ...@@ -81,9 +78,9 @@ class UniqueConstraint extends AbstractAsset implements Constraint
} }
/** /**
* @return string[] * @return array<int, string>
*/ */
public function getUnquotedColumns() public function getUnquotedColumns() : array
{ {
return array_map([$this, 'trimQuotes'], $this->getColumns()); return array_map([$this, 'trimQuotes'], $this->getColumns());
} }
...@@ -91,9 +88,9 @@ class UniqueConstraint extends AbstractAsset implements Constraint ...@@ -91,9 +88,9 @@ class UniqueConstraint extends AbstractAsset implements Constraint
/** /**
* Returns platform specific flags for unique constraint. * Returns platform specific flags for unique constraint.
* *
* @return string[] * @return array<int, string>
*/ */
public function getFlags() public function getFlags() : array
{ {
return array_keys($this->flags); return array_keys($this->flags);
} }
...@@ -101,13 +98,9 @@ class UniqueConstraint extends AbstractAsset implements Constraint ...@@ -101,13 +98,9 @@ class UniqueConstraint extends AbstractAsset implements Constraint
/** /**
* Adds flag for a unique constraint that translates to platform specific handling. * Adds flag for a unique constraint that translates to platform specific handling.
* *
* @param string $flag
*
* @return self
*
* @example $uniqueConstraint->addFlag('CLUSTERED') * @example $uniqueConstraint->addFlag('CLUSTERED')
*/ */
public function addFlag($flag) public function addFlag(string $flag) : self
{ {
$this->flags[strtolower($flag)] = true; $this->flags[strtolower($flag)] = true;
...@@ -116,52 +109,37 @@ class UniqueConstraint extends AbstractAsset implements Constraint ...@@ -116,52 +109,37 @@ class UniqueConstraint extends AbstractAsset implements Constraint
/** /**
* Does this unique constraint have a specific flag? * Does this unique constraint have a specific flag?
*
* @param string $flag
*
* @return bool
*/ */
public function hasFlag($flag) public function hasFlag(string $flag) : bool
{ {
return isset($this->flags[strtolower($flag)]); return isset($this->flags[strtolower($flag)]);
} }
/** /**
* Removes a flag. * Removes a flag.
*
* @param string $flag
*
* @return void
*/ */
public function removeFlag($flag) public function removeFlag(string $flag) : void
{ {
unset($this->flags[strtolower($flag)]); unset($this->flags[strtolower($flag)]);
} }
/** public function hasOption(string $name) : bool
* @param string $name
*
* @return bool
*/
public function hasOption($name)
{ {
return isset($this->options[strtolower($name)]); return isset($this->options[strtolower($name)]);
} }
/** /**
* @param string $name
*
* @return mixed * @return mixed
*/ */
public function getOption($name) public function getOption(string $name)
{ {
return $this->options[strtolower($name)]; return $this->options[strtolower($name)];
} }
/** /**
* @return mixed[] * @return array<string, mixed>
*/ */
public function getOptions() public function getOptions() : array
{ {
return $this->options; return $this->options;
} }
......
...@@ -12,20 +12,13 @@ class View extends AbstractAsset ...@@ -12,20 +12,13 @@ class View extends AbstractAsset
/** @var string */ /** @var string */
private $sql; private $sql;
/** public function __construct(string $name, string $sql)
* @param string $name
* @param string $sql
*/
public function __construct($name, $sql)
{ {
$this->_setName($name); $this->_setName($name);
$this->sql = $sql; $this->sql = $sql;
} }
/** public function getSql() : string
* @return string
*/
public function getSql()
{ {
return $this->sql; return $this->sql;
} }
......
...@@ -16,34 +16,34 @@ use Doctrine\DBAL\Schema\Table; ...@@ -16,34 +16,34 @@ use Doctrine\DBAL\Schema\Table;
*/ */
class AbstractVisitor implements Visitor, NamespaceVisitor class AbstractVisitor implements Visitor, NamespaceVisitor
{ {
public function acceptSchema(Schema $schema) public function acceptSchema(Schema $schema) : void
{ {
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptNamespace($namespaceName) public function acceptNamespace(string $namespaceName) : void
{ {
} }
public function acceptTable(Table $table) public function acceptTable(Table $table) : void
{ {
} }
public function acceptColumn(Table $table, Column $column) public function acceptColumn(Table $table, Column $column) : void
{ {
} }
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void
{ {
} }
public function acceptIndex(Table $table, Index $index) public function acceptIndex(Table $table, Index $index) : void
{ {
} }
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence) : void
{ {
} }
} }
...@@ -12,16 +12,16 @@ use function array_merge; ...@@ -12,16 +12,16 @@ use function array_merge;
class CreateSchemaSqlCollector extends AbstractVisitor class CreateSchemaSqlCollector extends AbstractVisitor
{ {
/** @var string[] */ /** @var array<string> */
private $createNamespaceQueries = []; private $createNamespaceQueries = [];
/** @var string[] */ /** @var array<string> */
private $createTableQueries = []; private $createTableQueries = [];
/** @var string[] */ /** @var array<string> */
private $createSequenceQueries = []; private $createSequenceQueries = [];
/** @var string[] */ /** @var array<string> */
private $createFkConstraintQueries = []; private $createFkConstraintQueries = [];
/** @var AbstractPlatform */ /** @var AbstractPlatform */
...@@ -35,7 +35,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor ...@@ -35,7 +35,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptNamespace($namespaceName) public function acceptNamespace(string $namespaceName) : void
{ {
if (! $this->platform->supportsSchemas()) { if (! $this->platform->supportsSchemas()) {
return; return;
...@@ -47,7 +47,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor ...@@ -47,7 +47,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptTable(Table $table) public function acceptTable(Table $table) : void
{ {
$this->createTableQueries = array_merge($this->createTableQueries, $this->platform->getCreateTableSQL($table)); $this->createTableQueries = array_merge($this->createTableQueries, $this->platform->getCreateTableSQL($table));
} }
...@@ -55,7 +55,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor ...@@ -55,7 +55,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void
{ {
if (! $this->platform->supportsForeignKeyConstraints()) { if (! $this->platform->supportsForeignKeyConstraints()) {
return; return;
...@@ -67,15 +67,12 @@ class CreateSchemaSqlCollector extends AbstractVisitor ...@@ -67,15 +67,12 @@ class CreateSchemaSqlCollector extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence) : void
{ {
$this->createSequenceQueries[] = $this->platform->getCreateSequenceSQL($sequence); $this->createSequenceQueries[] = $this->platform->getCreateSequenceSQL($sequence);
} }
/** public function resetQueries() : void
* @return void
*/
public function resetQueries()
{ {
$this->createNamespaceQueries = []; $this->createNamespaceQueries = [];
$this->createTableQueries = []; $this->createTableQueries = [];
...@@ -86,9 +83,9 @@ class CreateSchemaSqlCollector extends AbstractVisitor ...@@ -86,9 +83,9 @@ class CreateSchemaSqlCollector extends AbstractVisitor
/** /**
* Gets all queries collected so far. * Gets all queries collected so far.
* *
* @return string[] * @return array<string>
*/ */
public function getQueries() public function getQueries() : array
{ {
return array_merge( return array_merge(
$this->createNamespaceQueries, $this->createNamespaceQueries,
......
...@@ -38,7 +38,7 @@ class DropSchemaSqlCollector extends AbstractVisitor ...@@ -38,7 +38,7 @@ class DropSchemaSqlCollector extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptTable(Table $table) public function acceptTable(Table $table) : void
{ {
$this->tables->attach($table); $this->tables->attach($table);
} }
...@@ -46,7 +46,7 @@ class DropSchemaSqlCollector extends AbstractVisitor ...@@ -46,7 +46,7 @@ class DropSchemaSqlCollector extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void
{ {
if (strlen($fkConstraint->getName()) === 0) { if (strlen($fkConstraint->getName()) === 0) {
throw NamedForeignKeyRequired::new($localTable, $fkConstraint); throw NamedForeignKeyRequired::new($localTable, $fkConstraint);
...@@ -58,15 +58,12 @@ class DropSchemaSqlCollector extends AbstractVisitor ...@@ -58,15 +58,12 @@ class DropSchemaSqlCollector extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence) : void
{ {
$this->sequences->attach($sequence); $this->sequences->attach($sequence);
} }
/** public function clearQueries() : void
* @return void
*/
public function clearQueries()
{ {
$this->constraints = new SplObjectStorage(); $this->constraints = new SplObjectStorage();
$this->sequences = new SplObjectStorage(); $this->sequences = new SplObjectStorage();
...@@ -74,9 +71,9 @@ class DropSchemaSqlCollector extends AbstractVisitor ...@@ -74,9 +71,9 @@ class DropSchemaSqlCollector extends AbstractVisitor
} }
/** /**
* @return string[] * @return array<int, string>
*/ */
public function getQueries() public function getQueries() : array
{ {
$sql = []; $sql = [];
......
...@@ -23,7 +23,7 @@ class Graphviz extends AbstractVisitor ...@@ -23,7 +23,7 @@ class Graphviz extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void
{ {
$this->output .= $this->createNodeRelation( $this->output .= $this->createNodeRelation(
$fkConstraint->getLocalTableName() . ':col' . current($fkConstraint->getLocalColumns()) . ':se', $fkConstraint->getLocalTableName() . ':col' . current($fkConstraint->getLocalColumns()) . ':se',
...@@ -39,7 +39,7 @@ class Graphviz extends AbstractVisitor ...@@ -39,7 +39,7 @@ class Graphviz extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptSchema(Schema $schema) public function acceptSchema(Schema $schema) : void
{ {
$this->output = 'digraph "' . $schema->getName() . '" {' . "\n"; $this->output = 'digraph "' . $schema->getName() . '" {' . "\n";
$this->output .= 'splines = true;' . "\n"; $this->output .= 'splines = true;' . "\n";
...@@ -52,7 +52,7 @@ class Graphviz extends AbstractVisitor ...@@ -52,7 +52,7 @@ class Graphviz extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptTable(Table $table) public function acceptTable(Table $table) : void
{ {
$this->output .= $this->createNode( $this->output .= $this->createNode(
$table->getName(), $table->getName(),
...@@ -63,10 +63,7 @@ class Graphviz extends AbstractVisitor ...@@ -63,10 +63,7 @@ class Graphviz extends AbstractVisitor
); );
} }
/** private function createTableLabel(Table $table) : string
* @return string
*/
private function createTableLabel(Table $table)
{ {
// Start the table // Start the table
$label = '<<TABLE CELLSPACING="0" BORDER="1" ALIGN="LEFT">'; $label = '<<TABLE CELLSPACING="0" BORDER="1" ALIGN="LEFT">';
...@@ -99,12 +96,9 @@ class Graphviz extends AbstractVisitor ...@@ -99,12 +96,9 @@ class Graphviz extends AbstractVisitor
} }
/** /**
* @param string $name * @param array<string, string> $options
* @param string[] $options
*
* @return string
*/ */
private function createNode($name, $options) private function createNode(string $name, array $options) : string
{ {
$node = $name . ' ['; $node = $name . ' [';
foreach ($options as $key => $value) { foreach ($options as $key => $value) {
...@@ -116,13 +110,9 @@ class Graphviz extends AbstractVisitor ...@@ -116,13 +110,9 @@ class Graphviz extends AbstractVisitor
} }
/** /**
* @param string $node1 * @param array<string, string> $options
* @param string $node2
* @param string[] $options
*
* @return string
*/ */
private function createNodeRelation($node1, $node2, $options) private function createNodeRelation(string $node1, string $node2, array $options) : string
{ {
$relation = $node1 . ' -> ' . $node2 . ' ['; $relation = $node1 . ' -> ' . $node2 . ' [';
foreach ($options as $key => $value) { foreach ($options as $key => $value) {
...@@ -135,10 +125,8 @@ class Graphviz extends AbstractVisitor ...@@ -135,10 +125,8 @@ class Graphviz extends AbstractVisitor
/** /**
* Get Graphviz Output * Get Graphviz Output
*
* @return string
*/ */
public function getOutput() public function getOutput() : string
{ {
return $this->output . '}'; return $this->output . '}';
} }
...@@ -150,12 +138,8 @@ class Graphviz extends AbstractVisitor ...@@ -150,12 +138,8 @@ class Graphviz extends AbstractVisitor
* and execute: * and execute:
* *
* neato -Tpng -o er.png er.dot * neato -Tpng -o er.png er.dot
*
* @param string $filename
*
* @return void
*/ */
public function write($filename) public function write(string $filename) : void
{ {
file_put_contents($filename, $this->getOutput()); file_put_contents($filename, $this->getOutput());
} }
......
...@@ -14,5 +14,5 @@ interface NamespaceVisitor ...@@ -14,5 +14,5 @@ interface NamespaceVisitor
* *
* @param string $namespaceName The schema namespace name to accept. * @param string $namespaceName The schema namespace name to accept.
*/ */
public function acceptNamespace($namespaceName); public function acceptNamespace(string $namespaceName) : void;
} }
...@@ -28,7 +28,7 @@ class RemoveNamespacedAssets extends AbstractVisitor ...@@ -28,7 +28,7 @@ class RemoveNamespacedAssets extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptSchema(Schema $schema) public function acceptSchema(Schema $schema) : void
{ {
$this->schema = $schema; $this->schema = $schema;
} }
...@@ -36,7 +36,7 @@ class RemoveNamespacedAssets extends AbstractVisitor ...@@ -36,7 +36,7 @@ class RemoveNamespacedAssets extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptTable(Table $table) public function acceptTable(Table $table) : void
{ {
if ($table->isInDefaultNamespace($this->schema->getName())) { if ($table->isInDefaultNamespace($this->schema->getName())) {
return; return;
...@@ -48,7 +48,7 @@ class RemoveNamespacedAssets extends AbstractVisitor ...@@ -48,7 +48,7 @@ class RemoveNamespacedAssets extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence) : void
{ {
if ($sequence->isInDefaultNamespace($this->schema->getName())) { if ($sequence->isInDefaultNamespace($this->schema->getName())) {
return; return;
...@@ -60,7 +60,7 @@ class RemoveNamespacedAssets extends AbstractVisitor ...@@ -60,7 +60,7 @@ class RemoveNamespacedAssets extends AbstractVisitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void
{ {
// The table may already be deleted in a previous // The table may already be deleted in a previous
// RemoveNamespacedAssets#acceptTable call. Removing Foreign keys that // RemoveNamespacedAssets#acceptTable call. Removing Foreign keys that
......
...@@ -16,33 +16,15 @@ use Doctrine\DBAL\Schema\Table; ...@@ -16,33 +16,15 @@ use Doctrine\DBAL\Schema\Table;
*/ */
interface Visitor interface Visitor
{ {
/** public function acceptSchema(Schema $schema) : void;
* @return void
*/ public function acceptTable(Table $table) : void;
public function acceptSchema(Schema $schema);
public function acceptColumn(Table $table, Column $column) : void;
/**
* @return void public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void;
*/
public function acceptTable(Table $table); public function acceptIndex(Table $table, Index $index) : void;
/** public function acceptSequence(Sequence $sequence) : void;
* @return void
*/
public function acceptColumn(Table $table, Column $column);
/**
* @return void
*/
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint);
/**
* @return void
*/
public function acceptIndex(Table $table, Index $index);
/**
* @return void
*/
public function acceptSequence(Sequence $sequence);
} }
...@@ -44,7 +44,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer ...@@ -44,7 +44,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getCreateSchema(Schema $createSchema) public function getCreateSchema(Schema $createSchema) : array
{ {
$sql = []; $sql = [];
...@@ -73,7 +73,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer ...@@ -73,7 +73,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getUpdateSchema(Schema $toSchema, $noDrops = false) public function getUpdateSchema(Schema $toSchema, bool $noDrops = false) : array
{ {
return $this->work($toSchema, static function ($synchronizer, $schema) use ($noDrops) { return $this->work($toSchema, static function ($synchronizer, $schema) use ($noDrops) {
return $synchronizer->getUpdateSchema($schema, $noDrops); return $synchronizer->getUpdateSchema($schema, $noDrops);
...@@ -83,7 +83,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer ...@@ -83,7 +83,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDropSchema(Schema $dropSchema) public function getDropSchema(Schema $dropSchema) : array
{ {
return $this->work($dropSchema, static function ($synchronizer, $schema) { return $this->work($dropSchema, static function ($synchronizer, $schema) {
return $synchronizer->getDropSchema($schema); return $synchronizer->getDropSchema($schema);
...@@ -93,7 +93,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer ...@@ -93,7 +93,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function createSchema(Schema $createSchema) public function createSchema(Schema $createSchema) : void
{ {
$this->processSql($this->getCreateSchema($createSchema)); $this->processSql($this->getCreateSchema($createSchema));
} }
...@@ -101,7 +101,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer ...@@ -101,7 +101,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function updateSchema(Schema $toSchema, $noDrops = false) public function updateSchema(Schema $toSchema, bool $noDrops = false) : void
{ {
$this->processSql($this->getUpdateSchema($toSchema, $noDrops)); $this->processSql($this->getUpdateSchema($toSchema, $noDrops));
} }
...@@ -109,7 +109,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer ...@@ -109,7 +109,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dropSchema(Schema $dropSchema) public function dropSchema(Schema $dropSchema) : void
{ {
$this->processSqlSafely($this->getDropSchema($dropSchema)); $this->processSqlSafely($this->getDropSchema($dropSchema));
} }
...@@ -117,7 +117,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer ...@@ -117,7 +117,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDropAllSchema() public function getDropAllSchema() : array
{ {
$this->shardManager->selectGlobal(); $this->shardManager->selectGlobal();
$globalSql = $this->synchronizer->getDropAllSchema(); $globalSql = $this->synchronizer->getDropAllSchema();
...@@ -150,7 +150,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer ...@@ -150,7 +150,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dropAllSchema() public function dropAllSchema() : void
{ {
$this->processSqlSafely($this->getDropAllSchema()); $this->processSqlSafely($this->getDropAllSchema());
} }
......
...@@ -68,7 +68,7 @@ class MultiTenantVisitor implements Visitor ...@@ -68,7 +68,7 @@ class MultiTenantVisitor implements Visitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptTable(Table $table) public function acceptTable(Table $table) : void
{ {
if (in_array($table->getName(), $this->excludedTables)) { if (in_array($table->getName(), $this->excludedTables)) {
return; return;
...@@ -117,35 +117,35 @@ class MultiTenantVisitor implements Visitor ...@@ -117,35 +117,35 @@ class MultiTenantVisitor implements Visitor
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptSchema(Schema $schema) public function acceptSchema(Schema $schema) : void
{ {
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptColumn(Table $table, Column $column) public function acceptColumn(Table $table, Column $column) : void
{ {
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void
{ {
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptIndex(Table $table, Index $index) public function acceptIndex(Table $table, Index $index) : void
{ {
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence) : void
{ {
} }
} }
...@@ -41,4 +41,9 @@ class DriverTest extends AbstractDriverTest ...@@ -41,4 +41,9 @@ class DriverTest extends AbstractDriverTest
{ {
return new Driver(); return new Driver();
} }
protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string
{
return '';
}
} }
...@@ -156,7 +156,7 @@ class NamedParametersTest extends DbalFunctionalTestCase ...@@ -156,7 +156,7 @@ class NamedParametersTest extends DbalFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
if ($this->connection->getSchemaManager()->tablesExist('ddc1372_foobar')) { if ($this->connection->getSchemaManager()->tableExists('ddc1372_foobar')) {
return; return;
} }
......
...@@ -39,7 +39,7 @@ class ComparatorTest extends DbalFunctionalTestCase ...@@ -39,7 +39,7 @@ class ComparatorTest extends DbalFunctionalTestCase
$onlineTable = $this->schemaManager->listTableDetails('default_value'); $onlineTable = $this->schemaManager->listTableDetails('default_value');
self::assertFalse($this->comparator->diffTable($table, $onlineTable)); self::assertNull($this->comparator->diffTable($table, $onlineTable));
} }
/** /**
......
...@@ -5,6 +5,8 @@ declare(strict_types=1); ...@@ -5,6 +5,8 @@ declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Functional\Schema; namespace Doctrine\Tests\DBAL\Functional\Schema;
use DateTime; use DateTime;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Exception\DatabaseRequired;
use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Comparator;
...@@ -13,6 +15,7 @@ use Doctrine\DBAL\Schema\Table; ...@@ -13,6 +15,7 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\Tests\TestUtil;
use Doctrine\Tests\Types\MySqlPointType; use Doctrine\Tests\Types\MySqlPointType;
class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
...@@ -72,7 +75,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -72,7 +75,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$comparator = new Comparator(); $comparator = new Comparator();
$diff = $comparator->diffTable($tableFetched, $table); $diff = $comparator->diffTable($tableFetched, $table);
self::assertFalse($diff, 'no changes expected.'); self::assertNull($diff, 'no changes expected.');
} }
public function testFulltextIndex() : void public function testFulltextIndex() : void
...@@ -363,7 +366,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -363,7 +366,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$comparator = new Comparator(); $comparator = new Comparator();
self::assertFalse( self::assertNull(
$comparator->diffTable($offlineTable, $onlineTable), $comparator->diffTable($offlineTable, $onlineTable),
'No differences should be detected with the offline vs online schema.' 'No differences should be detected with the offline vs online schema.'
); );
...@@ -442,7 +445,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -442,7 +445,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$comparator = new Comparator(); $comparator = new Comparator();
$diff = $comparator->diffTable($table, $onlineTable); $diff = $comparator->diffTable($table, $onlineTable);
self::assertFalse($diff, 'Tables should be identical with column defaults.'); self::assertNull($diff, 'Tables should be identical with column defaults.');
} }
public function testColumnDefaultsAreValid() : void public function testColumnDefaultsAreValid() : void
...@@ -517,7 +520,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -517,7 +520,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$comparator = new Comparator(); $comparator = new Comparator();
$diff = $comparator->diffTable($table, $onlineTable); $diff = $comparator->diffTable($table, $onlineTable);
self::assertFalse($diff, 'Tables should be identical with column defauts time and date.'); self::assertNull($diff, 'Tables should be identical with column defauts time and date.');
} }
public function testEnsureTableOptionsAreReflectedInMetadata() : void public function testEnsureTableOptionsAreReflectedInMetadata() : void
...@@ -569,4 +572,18 @@ SQL; ...@@ -569,4 +572,18 @@ SQL;
self::assertEquals([], $table->getOption('create_options')); self::assertEquals([], $table->getOption('create_options'));
} }
public function testListTableColumnsThrowsDatabaseRequired() : void
{
$params = TestUtil::getConnectionParams();
unset($params['dbname']);
$connection = DriverManager::getConnection($params);
$schemaManager = $connection->getSchemaManager();
self::expectException(DatabaseRequired::class);
self::expectExceptionMessage('A database is required for the method: Doctrine\DBAL\Schema\AbstractSchemaManager::listTableColumns');
$schemaManager->listTableColumns('users');
}
} }
...@@ -300,7 +300,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -300,7 +300,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$c = new Comparator(); $c = new Comparator();
$diff = $c->diffTable($table, $databaseTable); $diff = $c->diffTable($table, $databaseTable);
self::assertFalse($diff); self::assertNull($diff);
} }
public function testListTableWithBinary() : void public function testListTableWithBinary() : void
...@@ -339,7 +339,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -339,7 +339,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$comparator = new Schema\Comparator(); $comparator = new Schema\Comparator();
self::assertFalse($comparator->diffTable($offlineTable, $onlineTable)); self::assertNull($comparator->diffTable($offlineTable, $onlineTable));
} }
public function testListTablesExcludesViews() : void public function testListTablesExcludesViews() : void
...@@ -385,7 +385,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -385,7 +385,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$comparator = new Schema\Comparator(); $comparator = new Schema\Comparator();
self::assertFalse($comparator->diffTable($offlineTable, $onlineTable)); self::assertNull($comparator->diffTable($offlineTable, $onlineTable));
self::assertTrue($onlineTable->hasIndex('simple_partial_index')); self::assertTrue($onlineTable->hasIndex('simple_partial_index'));
self::assertTrue($onlineTable->getIndex('simple_partial_index')->hasOption('where')); self::assertTrue($onlineTable->getIndex('simple_partial_index')->hasOption('where'));
self::assertSame('(id IS NULL)', $onlineTable->getIndex('simple_partial_index')->getOption('where')); self::assertSame('(id IS NULL)', $onlineTable->getIndex('simple_partial_index')->getOption('where'));
......
...@@ -430,7 +430,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase ...@@ -430,7 +430,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$comparator = new Comparator(); $comparator = new Comparator();
$diff = $comparator->diffTable($offlineTable, $onlineTable); $diff = $comparator->diffTable($offlineTable, $onlineTable);
self::assertFalse($diff, 'No differences should be detected with the offline vs online schema.'); self::assertNull($diff, 'No differences should be detected with the offline vs online schema.');
} }
public function testListTableIndexes() : void public function testListTableIndexes() : void
...@@ -1317,7 +1317,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase ...@@ -1317,7 +1317,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$comparator = new Comparator(); $comparator = new Comparator();
$tableDiff = $comparator->diffTable($this->schemaManager->listTableDetails('json_test'), $table); $tableDiff = $comparator->diffTable($this->schemaManager->listTableDetails('json_test'), $table);
self::assertFalse($tableDiff); self::assertNull($tableDiff);
} }
/** /**
......
...@@ -237,7 +237,7 @@ SQL; ...@@ -237,7 +237,7 @@ SQL;
if ($expectedComparatorDiff) { if ($expectedComparatorDiff) {
self::assertEmpty($this->schemaManager->getDatabasePlatform()->getAlterTableSQL($diff)); self::assertEmpty($this->schemaManager->getDatabasePlatform()->getAlterTableSQL($diff));
} else { } else {
self::assertFalse($diff); self::assertNull($diff);
} }
} }
......
...@@ -20,7 +20,7 @@ class DBAL202Test extends DbalFunctionalTestCase ...@@ -20,7 +20,7 @@ class DBAL202Test extends DbalFunctionalTestCase
$this->markTestSkipped('OCI8 only test'); $this->markTestSkipped('OCI8 only test');
} }
if ($this->connection->getSchemaManager()->tablesExist('DBAL202')) { if ($this->connection->getSchemaManager()->tableExists('DBAL202')) {
$this->connection->exec('DELETE FROM DBAL202'); $this->connection->exec('DELETE FROM DBAL202');
} else { } else {
$table = new Table('DBAL202'); $table = new Table('DBAL202');
......
...@@ -37,6 +37,6 @@ class DBAL510Test extends DbalFunctionalTestCase ...@@ -37,6 +37,6 @@ class DBAL510Test extends DbalFunctionalTestCase
$comparator = new Comparator(); $comparator = new Comparator();
$diff = $comparator->diffTable($onlineTable, $table); $diff = $comparator->diffTable($onlineTable, $table);
self::assertFalse($diff); self::assertNull($diff);
} }
} }
...@@ -484,13 +484,11 @@ class ComparatorTest extends TestCase ...@@ -484,13 +484,11 @@ class ComparatorTest extends TestCase
$seq1 = new Sequence('foo', 1, 1); $seq1 = new Sequence('foo', 1, 1);
$seq2 = new Sequence('foo', 1, 2); $seq2 = new Sequence('foo', 1, 2);
$seq3 = new Sequence('foo', 2, 1); $seq3 = new Sequence('foo', 2, 1);
$seq4 = new Sequence('foo', '1', '1');
$c = new Comparator(); $c = new Comparator();
self::assertTrue($c->diffSequence($seq1, $seq2)); self::assertTrue($c->diffSequence($seq1, $seq2));
self::assertTrue($c->diffSequence($seq1, $seq3)); self::assertTrue($c->diffSequence($seq1, $seq3));
self::assertFalse($c->diffSequence($seq1, $seq4));
} }
public function testRemovedSequence() : void public function testRemovedSequence() : void
...@@ -653,7 +651,7 @@ class ComparatorTest extends TestCase ...@@ -653,7 +651,7 @@ class ComparatorTest extends TestCase
$c = new Comparator(); $c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB); $tableDiff = $c->diffTable($tableA, $tableB);
self::assertFalse($tableDiff); self::assertNull($tableDiff);
} }
public function testCompareIndexBasedOnPropertiesNotName() : void public function testCompareIndexBasedOnPropertiesNotName() : void
...@@ -690,7 +688,7 @@ class ComparatorTest extends TestCase ...@@ -690,7 +688,7 @@ class ComparatorTest extends TestCase
$c = new Comparator(); $c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB); $tableDiff = $c->diffTable($tableA, $tableB);
self::assertFalse($tableDiff); self::assertNull($tableDiff);
} }
public function testCompareForeignKeyRestrictNoActionAreTheSame() : void public function testCompareForeignKeyRestrictNoActionAreTheSame() : void
......
...@@ -58,7 +58,7 @@ class TableDiffTest extends TestCase ...@@ -58,7 +58,7 @@ class TableDiffTest extends TestCase
{ {
$tableDiff = new TableDiff('foo'); $tableDiff = new TableDiff('foo');
self::assertFalse($tableDiff->getNewName()); self::assertNull($tableDiff->getNewName());
$tableDiff->newName = 'bar'; $tableDiff->newName = 'bar';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment