From 9a98459461c01c13f43ce027cc1e7893981ee9c2 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 30 May 2019 07:52:13 -0700 Subject: [PATCH] Enforced parameter and return value types in event-related classes --- UPGRADE.md | 6 +++ .../DBAL/Event/ConnectionEventArgs.php | 38 +------------- .../Event/Listeners/OracleSessionInit.php | 11 ++--- .../DBAL/Event/Listeners/SQLSessionInit.php | 12 ++--- .../SchemaAlterTableAddColumnEventArgs.php | 33 ++++--------- .../SchemaAlterTableChangeColumnEventArgs.php | 33 ++++--------- .../DBAL/Event/SchemaAlterTableEventArgs.php | 28 +++-------- .../SchemaAlterTableRemoveColumnEventArgs.php | 33 ++++--------- .../SchemaAlterTableRenameColumnEventArgs.php | 43 +++++----------- .../Event/SchemaColumnDefinitionEventArgs.php | 49 +++++-------------- .../SchemaCreateTableColumnEventArgs.php | 29 +++-------- .../DBAL/Event/SchemaCreateTableEventArgs.php | 42 ++++++---------- .../DBAL/Event/SchemaDropTableEventArgs.php | 16 ++---- lib/Doctrine/DBAL/Event/SchemaEventArgs.php | 9 ++-- .../Event/SchemaIndexDefinitionEventArgs.php | 41 +++++----------- .../DBAL/Platforms/AbstractPlatform.php | 5 +- 16 files changed, 116 insertions(+), 312 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 8590bbe3c3e..e795f69786c 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 85a70d3c017..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,41 +20,8 @@ public function __construct(Connection $connection) $this->connection = $connection; } - /** - * @return Connection - */ - public function getConnection() + public function getConnection() : Connection { return $this->connection; } - - /** - * @deprecated Use ConnectionEventArgs::getConnection() and Connection::getDriver() instead. - * - * @return Driver - */ - public function getDriver() - { - return $this->connection->getDriver(); - } - - /** - * @deprecated Use ConnectionEventArgs::getConnection() and Connection::getDatabasePlatform() instead. - * - * @return AbstractPlatform - */ - public function getDatabasePlatform() - { - return $this->connection->getDatabasePlatform(); - } - - /** - * @deprecated Use ConnectionEventArgs::getConnection() and Connection::getSchemaManager() instead. - * - * @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 240f752bf4a..8d12d74cc48 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php @@ -8,8 +8,6 @@ use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; use function array_merge; -use function func_get_args; -use function is_array; /** * Event Arguments used when SQL queries for adding table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -25,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) @@ -35,48 +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; } /** - * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead. - * - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args()); + $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 e1c061f0f70..cc3019d4faf 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php @@ -8,8 +8,6 @@ use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\TableDiff; use function array_merge; -use function func_get_args; -use function is_array; /** * Event Arguments used when SQL queries for changing table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -25,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) @@ -35,48 +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; } /** - * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead. - * - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args()); + $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 af6ce4f15cb..910b4827232 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php @@ -7,8 +7,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\TableDiff; use function array_merge; -use function func_get_args; -use function is_array; /** * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\*Platform. @@ -21,7 +19,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs /** @var AbstractPlatform */ private $platform; - /** @var string[] */ + /** @var array */ private $sql = []; public function __construct(TableDiff $tableDiff, AbstractPlatform $platform) @@ -30,40 +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; } /** - * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead. - * - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args()); + $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 8f8cd826d82..06dd5641b74 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php @@ -8,8 +8,6 @@ use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; use function array_merge; -use function func_get_args; -use function is_array; /** * Event Arguments used when SQL queries for removing table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -25,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) @@ -35,48 +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; } /** - * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead. - * - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args()); + $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 68d91985c45..8f9059b119a 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php @@ -8,8 +8,6 @@ use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; use function array_merge; -use function func_get_args; -use function is_array; /** * Event Arguments used when SQL queries for renaming table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -28,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; @@ -42,56 +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; } /** - * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead. - * - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args()); + $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 4ad7d0a3696..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,62 +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; } - - /** - * @deprecated Use SchemaColumnDefinitionEventArgs::getConnection() and Connection::getDatabasePlatform() instead. - * - * @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 7a37e5fa82b..038da6a0a68 100644 --- a/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php @@ -8,8 +8,6 @@ use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Table; use function array_merge; -use function func_get_args; -use function is_array; /** * Event Arguments used when SQL queries for creating table columns are generated inside Doctrine\DBAL\Platform\AbstractPlatform. @@ -35,40 +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; } /** - * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead. - * - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args()); + $this->sql = array_merge($this->sql, $sql); return $this; } @@ -76,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 699bfefeb6f..b59f3470acb 100644 --- a/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php @@ -7,8 +7,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Table; use function array_merge; -use function func_get_args; -use function is_array; /** * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform. @@ -18,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) { @@ -42,48 +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; } /** - * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead. - * - * @param string|string[] $sql - * - * @return \Doctrine\DBAL\Event\SchemaCreateTableEventArgs + * @return $this */ - public function addSql($sql) + public function addSql(string ...$sql) : self { - $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args()); + $this->sql = array_merge($this->sql, $sql); return $this; } @@ -91,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 f188220b100..6d34e8e8ad0 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)) {