diff --git a/UPGRADE.md b/UPGRADE.md index 1b63111865b..6fe14f09d88 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,11 @@ # Upgrade to 3.0 +## BC BREAK: Changes in the `Doctrine\DBAL\Event` API + +- `SchemaAlterTableAddColumnEventArgs::addSql()` and the same method in other `SchemaEventArgs`-based classes no longer accept an array of SQL statements. They accept a variadic string. +- `ConnectionEventArgs::getDriver()`, `::getDatabasePlatform()` and `::getSchemaManager()` methods have been removed. The connection information can be obtained from the connection which is available via `::getConnection()`. +- `SchemaColumnDefinitionEventArgs::getDatabasePlatform()` and `SchemaIndexDefinitionEventArgs::getDatabasePlatform()` have been removed for the same reason as above. + ## BC BREAK: Changes in the `Doctrine\DBAL\Connection` API - The following methods have been removed as leaking internal implementation details: `::getHost()`, `::getPort()`, `::getUsername()`, `::getPassword()`. diff --git a/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php b/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php index 8c40a3bfae3..38d0b26f537 100644 --- a/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php +++ b/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php @@ -6,9 +6,6 @@ use Doctrine\Common\EventArgs; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver; -use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\DBAL\Schema\AbstractSchemaManager; /** * Event Arguments used when a Driver connection is established inside Doctrine\DBAL\Connection. @@ -23,35 +20,8 @@ public function __construct(Connection $connection) $this->connection = $connection; } - /** - * @return Connection - */ - public function getConnection() + public function getConnection() : Connection { return $this->connection; } - - /** - * @return Driver - */ - public function getDriver() - { - return $this->connection->getDriver(); - } - - /** - * @return AbstractPlatform - */ - public function getDatabasePlatform() - { - return $this->connection->getDatabasePlatform(); - } - - /** - * @return AbstractSchemaManager - */ - public function getSchemaManager() - { - return $this->connection->getSchemaManager(); - } } diff --git a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php index 413f9c6df16..fcd2e01f977 100644 --- a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php +++ b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php @@ -25,7 +25,7 @@ */ class OracleSessionInit implements EventSubscriber { - /** @var string[] */ + /** @var array */ protected $_defaultSessionVars = [ 'NLS_TIME_FORMAT' => 'HH24:MI:SS', 'NLS_DATE_FORMAT' => 'YYYY-MM-DD HH24:MI:SS', @@ -35,17 +35,14 @@ class OracleSessionInit implements EventSubscriber ]; /** - * @param string[] $oracleSessionVars + * @param array $oracleSessionVars */ public function __construct(array $oracleSessionVars = []) { $this->_defaultSessionVars = array_merge($this->_defaultSessionVars, $oracleSessionVars); } - /** - * @return void - */ - public function postConnect(ConnectionEventArgs $args) + public function postConnect(ConnectionEventArgs $args) : void { if (! count($this->_defaultSessionVars)) { return; @@ -67,7 +64,7 @@ public function postConnect(ConnectionEventArgs $args) /** * {@inheritdoc} */ - public function getSubscribedEvents() + public function getSubscribedEvents() : array { return [Events::postConnect]; } diff --git a/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php b/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php index 629e0f43cd8..e1eee9840ef 100644 --- a/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php +++ b/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php @@ -16,18 +16,12 @@ class SQLSessionInit implements EventSubscriber /** @var string */ protected $sql; - /** - * @param string $sql - */ - public function __construct($sql) + public function __construct(string $sql) { $this->sql = $sql; } - /** - * @return void - */ - public function postConnect(ConnectionEventArgs $args) + public function postConnect(ConnectionEventArgs $args) : void { $conn = $args->getConnection(); $conn->exec($this->sql); @@ -36,7 +30,7 @@ public function postConnect(ConnectionEventArgs $args) /** * {@inheritdoc} */ - public function getSubscribedEvents() + public function getSubscribedEvents() : array { return [Events::postConnect]; } diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php index 9799e9b4e59..8d12d74cc48 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php @@ -8,7 +8,6 @@ use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; use function array_merge; -use function is_array; /** * Event Arguments used when SQL queries for adding table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -24,7 +23,7 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs /** @var AbstractPlatform */ private $platform; - /** @var string[] */ + /** @var array */ private $sql = []; public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform) @@ -34,50 +33,35 @@ public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatfo $this->platform = $platform; } - /** - * @return Column - */ - public function getColumn() + public function getColumn() : Column { return $this->column; } - /** - * @return TableDiff - */ - public function getTableDiff() + public function getTableDiff() : TableDiff { return $this->tableDiff; } - /** - * @return AbstractPlatform - */ - public function getPlatform() + public function getPlatform() : AbstractPlatform { return $this->platform; } /** - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - if (is_array($sql)) { - $this->sql = array_merge($this->sql, $sql); - } else { - $this->sql[] = $sql; - } + $this->sql = array_merge($this->sql, $sql); return $this; } /** - * @return string[] + * @return array */ - public function getSql() + public function getSql() : array { return $this->sql; } diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php index 33f2fac5fe9..cc3019d4faf 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php @@ -8,7 +8,6 @@ use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\TableDiff; use function array_merge; -use function is_array; /** * Event Arguments used when SQL queries for changing table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -24,7 +23,7 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs /** @var AbstractPlatform */ private $platform; - /** @var string[] */ + /** @var array */ private $sql = []; public function __construct(ColumnDiff $columnDiff, TableDiff $tableDiff, AbstractPlatform $platform) @@ -34,50 +33,35 @@ public function __construct(ColumnDiff $columnDiff, TableDiff $tableDiff, Abstra $this->platform = $platform; } - /** - * @return ColumnDiff - */ - public function getColumnDiff() + public function getColumnDiff() : ColumnDiff { return $this->columnDiff; } - /** - * @return TableDiff - */ - public function getTableDiff() + public function getTableDiff() : TableDiff { return $this->tableDiff; } - /** - * @return AbstractPlatform - */ - public function getPlatform() + public function getPlatform() : AbstractPlatform { return $this->platform; } /** - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - if (is_array($sql)) { - $this->sql = array_merge($this->sql, $sql); - } else { - $this->sql[] = $sql; - } + $this->sql = array_merge($this->sql, $sql); return $this; } /** - * @return string[] + * @return array */ - public function getSql() + public function getSql() : array { return $this->sql; } diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php index 35258004fb9..910b4827232 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php @@ -7,7 +7,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\TableDiff; use function array_merge; -use function is_array; /** * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\*Platform. @@ -20,7 +19,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs /** @var AbstractPlatform */ private $platform; - /** @var string[] */ + /** @var array */ private $sql = []; public function __construct(TableDiff $tableDiff, AbstractPlatform $platform) @@ -29,42 +28,30 @@ public function __construct(TableDiff $tableDiff, AbstractPlatform $platform) $this->platform = $platform; } - /** - * @return TableDiff - */ - public function getTableDiff() + public function getTableDiff() : TableDiff { return $this->tableDiff; } - /** - * @return AbstractPlatform - */ - public function getPlatform() + public function getPlatform() : AbstractPlatform { return $this->platform; } /** - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - if (is_array($sql)) { - $this->sql = array_merge($this->sql, $sql); - } else { - $this->sql[] = $sql; - } + $this->sql = array_merge($this->sql, $sql); return $this; } /** - * @return string[] + * @return array */ - public function getSql() + public function getSql() : array { return $this->sql; } diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php index 80daf00fe07..06dd5641b74 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php @@ -8,7 +8,6 @@ use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; use function array_merge; -use function is_array; /** * Event Arguments used when SQL queries for removing table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -24,7 +23,7 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs /** @var AbstractPlatform */ private $platform; - /** @var string[] */ + /** @var array */ private $sql = []; public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform) @@ -34,50 +33,35 @@ public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatfo $this->platform = $platform; } - /** - * @return Column - */ - public function getColumn() + public function getColumn() : Column { return $this->column; } - /** - * @return TableDiff - */ - public function getTableDiff() + public function getTableDiff() : TableDiff { return $this->tableDiff; } - /** - * @return AbstractPlatform - */ - public function getPlatform() + public function getPlatform() : AbstractPlatform { return $this->platform; } /** - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - if (is_array($sql)) { - $this->sql = array_merge($this->sql, $sql); - } else { - $this->sql[] = $sql; - } + $this->sql = array_merge($this->sql, $sql); return $this; } /** - * @return string[] + * @return array */ - public function getSql() + public function getSql() : array { return $this->sql; } diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php index 49f7615c76e..8f9059b119a 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php @@ -8,7 +8,6 @@ use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; use function array_merge; -use function is_array; /** * Event Arguments used when SQL queries for renaming table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -27,13 +26,10 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs /** @var AbstractPlatform */ private $platform; - /** @var string[] */ + /** @var array */ private $sql = []; - /** - * @param string $oldColumnName - */ - public function __construct($oldColumnName, Column $column, TableDiff $tableDiff, AbstractPlatform $platform) + public function __construct(string $oldColumnName, Column $column, TableDiff $tableDiff, AbstractPlatform $platform) { $this->oldColumnName = $oldColumnName; $this->column = $column; @@ -41,58 +37,40 @@ public function __construct($oldColumnName, Column $column, TableDiff $tableDiff $this->platform = $platform; } - /** - * @return string - */ - public function getOldColumnName() + public function getOldColumnName() : string { return $this->oldColumnName; } - /** - * @return Column - */ - public function getColumn() + public function getColumn() : Column { return $this->column; } - /** - * @return TableDiff - */ - public function getTableDiff() + public function getTableDiff() : TableDiff { return $this->tableDiff; } - /** - * @return AbstractPlatform - */ - public function getPlatform() + public function getPlatform() : AbstractPlatform { return $this->platform; } /** - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - if (is_array($sql)) { - $this->sql = array_merge($this->sql, $sql); - } else { - $this->sql[] = $sql; - } + $this->sql = array_merge($this->sql, $sql); return $this; } /** - * @return string[] + * @return array */ - public function getSql() + public function getSql() : array { return $this->sql; } diff --git a/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php index 9e51b1038f0..36041797458 100644 --- a/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php @@ -5,7 +5,6 @@ namespace Doctrine\DBAL\Event; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; /** @@ -14,12 +13,12 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs { /** @var Column|null */ - private $column = null; + private $column; /** * Raw column data as fetched from the database. * - * @var mixed[] + * @var array */ private $tableColumn; @@ -33,11 +32,9 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs private $connection; /** - * @param mixed[] $tableColumn - * @param string $table - * @param string $database + * @param array $tableColumn */ - public function __construct(array $tableColumn, $table, $database, Connection $connection) + public function __construct(array $tableColumn, string $table, string $database, Connection $connection) { $this->tableColumn = $tableColumn; $this->table = $table; @@ -49,60 +46,40 @@ public function __construct(array $tableColumn, $table, $database, Connection $c * Allows to clear the column which means the column will be excluded from * tables column list. * - * @return \Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs + * @return $this */ - public function setColumn(?Column $column = null) + public function setColumn(?Column $column) : self { $this->column = $column; return $this; } - /** - * @return Column|null - */ - public function getColumn() + public function getColumn() : ?Column { return $this->column; } /** - * @return mixed[] + * @return array */ - public function getTableColumn() + public function getTableColumn() : array { return $this->tableColumn; } - /** - * @return string - */ - public function getTable() + public function getTable() : string { return $this->table; } - /** - * @return string - */ - public function getDatabase() + public function getDatabase() : string { return $this->database; } - /** - * @return Connection - */ - public function getConnection() + public function getConnection() : Connection { return $this->connection; } - - /** - * @return AbstractPlatform - */ - public function getDatabasePlatform() - { - return $this->connection->getDatabasePlatform(); - } } diff --git a/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php index f4e70e0ff89..038da6a0a68 100644 --- a/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php @@ -7,7 +7,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Table; -use function is_array; +use function array_merge; /** * Event Arguments used when SQL queries for creating table columns are generated inside Doctrine\DBAL\Platform\AbstractPlatform. @@ -33,44 +33,27 @@ public function __construct(Column $column, Table $table, AbstractPlatform $plat $this->platform = $platform; } - /** - * @return Column - */ - public function getColumn() + public function getColumn() : Column { return $this->column; } - /** - * @return Table - */ - public function getTable() + public function getTable() : Table { return $this->table; } - /** - * @return AbstractPlatform - */ - public function getPlatform() + public function getPlatform() : AbstractPlatform { return $this->platform; } /** - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - if (is_array($sql)) { - foreach ($sql as $query) { - $this->sql[] = $query; - } - } else { - $this->sql[] = $sql; - } + $this->sql = array_merge($this->sql, $sql); return $this; } @@ -78,7 +61,7 @@ public function addSql($sql) /** * @return array */ - public function getSql() + public function getSql() : array { return $this->sql; } diff --git a/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php index 5046add54c3..b59f3470acb 100644 --- a/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php @@ -6,7 +6,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Table; -use function is_array; +use function array_merge; /** * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform. @@ -16,21 +16,21 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs /** @var Table */ private $table; - /** @var mixed[][] */ + /** @var array> */ private $columns; - /** @var mixed[] */ + /** @var array */ private $options; /** @var AbstractPlatform */ private $platform; - /** @var string[] */ + /** @var array */ private $sql = []; /** - * @param mixed[][] $columns - * @param mixed[] $options + * @param array> $columns + * @param array $options */ public function __construct(Table $table, array $columns, array $options, AbstractPlatform $platform) { @@ -40,52 +40,38 @@ public function __construct(Table $table, array $columns, array $options, Abstra $this->platform = $platform; } - /** - * @return Table - */ - public function getTable() + public function getTable() : Table { return $this->table; } /** - * @return mixed[][] + * @return array> */ - public function getColumns() + public function getColumns() : array { return $this->columns; } /** - * @return mixed[] + * @return array */ - public function getOptions() + public function getOptions() : array { return $this->options; } - /** - * @return AbstractPlatform - */ - public function getPlatform() + public function getPlatform() : AbstractPlatform { return $this->platform; } /** - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaCreateTableEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - if (is_array($sql)) { - foreach ($sql as $query) { - $this->sql[] = $query; - } - } else { - $this->sql[] = $sql; - } + $this->sql = array_merge($this->sql, $sql); return $this; } @@ -93,7 +79,7 @@ public function addSql($sql) /** * @return array */ - public function getSql() + public function getSql() : array { return $this->sql; } diff --git a/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php index 9d21bd35e0e..73fe78201cd 100644 --- a/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php @@ -41,30 +41,22 @@ public function getTable() return $this->table; } - /** - * @return AbstractPlatform - */ - public function getPlatform() + public function getPlatform() : AbstractPlatform { return $this->platform; } /** - * @param string $sql - * - * @return \Doctrine\DBAL\Event\SchemaDropTableEventArgs + * @return $this */ - public function setSql($sql) + public function setSql(string $sql) : self { $this->sql = $sql; return $this; } - /** - * @return string|null - */ - public function getSql() + public function getSql() : ?string { return $this->sql; } diff --git a/lib/Doctrine/DBAL/Event/SchemaEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaEventArgs.php index a5c152872b8..4b15c80e444 100644 --- a/lib/Doctrine/DBAL/Event/SchemaEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaEventArgs.php @@ -15,19 +15,16 @@ class SchemaEventArgs extends EventArgs private $preventDefault = false; /** - * @return \Doctrine\DBAL\Event\SchemaEventArgs + * @return $this */ - public function preventDefault() + public function preventDefault() : self { $this->preventDefault = true; return $this; } - /** - * @return bool - */ - public function isDefaultPrevented() + public function isDefaultPrevented() : bool { return $this->preventDefault; } diff --git a/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php index bfbd8cfe619..c39e1f3b2ea 100644 --- a/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php @@ -5,7 +5,6 @@ namespace Doctrine\DBAL\Event; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Index; /** @@ -14,12 +13,12 @@ class SchemaIndexDefinitionEventArgs extends SchemaEventArgs { /** @var Index|null */ - private $index = null; + private $index; /** * Raw index data as fetched from the database. * - * @var mixed[] + * @var array */ private $tableIndex; @@ -30,10 +29,9 @@ class SchemaIndexDefinitionEventArgs extends SchemaEventArgs private $connection; /** - * @param mixed[] $tableIndex - * @param string $table + * @param array $tableIndex */ - public function __construct(array $tableIndex, $table, Connection $connection) + public function __construct(array $tableIndex, string $table, Connection $connection) { $this->tableIndex = $tableIndex; $this->table = $table; @@ -43,52 +41,35 @@ public function __construct(array $tableIndex, $table, Connection $connection) /** * Allows to clear the index which means the index will be excluded from tables index list. * - * @return SchemaIndexDefinitionEventArgs + * @return $this */ - public function setIndex(?Index $index = null) + public function setIndex(?Index $index) : self { $this->index = $index; return $this; } - /** - * @return Index|null - */ - public function getIndex() + public function getIndex() : ?Index { return $this->index; } /** - * @return mixed[] + * @return array */ - public function getTableIndex() + public function getTableIndex() : array { return $this->tableIndex; } - /** - * @return string - */ - public function getTable() + public function getTable() : string { return $this->table; } - /** - * @return Connection - */ - public function getConnection() + public function getConnection() : Connection { return $this->connection; } - - /** - * @return AbstractPlatform - */ - public function getDatabasePlatform() - { - return $this->connection->getDatabasePlatform(); - } } diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index 8444ee2d17c..a2869911532 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -1345,7 +1345,10 @@ public function getCreateTableSQL(Table $table, int $createFlags = self::CREATE_ $columnData['primary'] = true; } - $columns[$columnData['name']] = $columnData; + $columnName = $columnData['name']; + assert(is_string($columnName)); + + $columns[$columnName] = $columnData; } if ($this->_eventManager !== null && $this->_eventManager->hasListeners(Events::onSchemaCreateTable)) {