diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index e0159a3e65c..86d66046eaa 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -258,6 +258,13 @@ public function getDatabase() */ public function getHost() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Connection::getHost() is deprecated, get the database server host from application config ' . + 'or as a last resort from internal Connection::getParams() API.' + ); + return $this->params['host'] ?? null; } @@ -270,6 +277,13 @@ public function getHost() */ public function getPort() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Connection::getPort() is deprecated, get the database server port from application config ' . + 'or as a last resort from internal Connection::getParams() API.' + ); + return $this->params['port'] ?? null; } @@ -282,6 +296,13 @@ public function getPort() */ public function getUsername() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Connection::getUsername() is deprecated, get the username from application config ' . + 'or as a last resort from internal Connection::getParams() API.' + ); + return $this->params['user'] ?? null; } @@ -294,6 +315,13 @@ public function getUsername() */ public function getPassword() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Connection::getPassword() is deprecated, get the password from application config ' . + 'or as a last resort from internal Connection::getParams() API.' + ); + return $this->params['password'] ?? null; } diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php index 056dbacd983..f4e50c9d4c6 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Driver\IBMDB2; use Doctrine\DBAL\Driver\AbstractDB2Driver; +use Doctrine\Deprecations\Deprecation; /** * IBM DB2 Driver. @@ -35,6 +36,12 @@ public function connect(array $params, $username = null, $password = null, array */ public function getName() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Driver::getName() is deprecated' + ); + return 'ibm_db2'; } } diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php b/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php index 9ac74f27d07..ca2df928902 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Driver\AbstractMySQLDriver; use Doctrine\DBAL\Exception; +use Doctrine\Deprecations\Deprecation; class Driver extends AbstractMySQLDriver { @@ -24,6 +25,12 @@ public function connect(array $params, $username = null, $password = null, array */ public function getName() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Driver::getName() is deprecated' + ); + return 'mysqli'; } } diff --git a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php index 5f7e3c0a9e8..c58ceaf8b54 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Driver\AbstractOracleDriver; use Doctrine\DBAL\Exception; +use Doctrine\Deprecations\Deprecation; use const OCI_NO_AUTO_COMMIT; @@ -50,6 +51,12 @@ protected function _constructDsn(array $params) */ public function getName() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Driver::getName() is deprecated' + ); + return 'oci8'; } } diff --git a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php b/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php index 0543d8786e7..875310ee848 100644 --- a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Driver\AbstractDB2Driver; use Doctrine\DBAL\Driver\PDO\Connection; +use Doctrine\Deprecations\Deprecation; /** * Driver for the PDO IBM extension. @@ -58,6 +59,12 @@ private function _constructPdoDsn(array $params) */ public function getName() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Driver::getName() is deprecated' + ); + return 'pdo_ibm'; } } diff --git a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php index 25eb2fbdb6f..70d56778d22 100644 --- a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\AbstractMySQLDriver; use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\Exception; +use Doctrine\Deprecations\Deprecation; use PDOException; /** @@ -73,6 +74,12 @@ protected function constructPdoDsn(array $params) */ public function getName() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Driver::getName() is deprecated' + ); + return 'pdo_mysql'; } } diff --git a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php index b8e0a96f44e..a84c67fb618 100644 --- a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\AbstractOracleDriver; use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\Exception; +use Doctrine\Deprecations\Deprecation; use PDOException; /** @@ -54,6 +55,12 @@ private function constructPdoDsn(array $params) */ public function getName() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Driver::getName() is deprecated' + ); + return 'pdo_oracle'; } } diff --git a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php index 83076aa8c06..bbdf23fdc2f 100644 --- a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\Exception; +use Doctrine\Deprecations\Deprecation; use PDOException; use function defined; @@ -116,6 +117,12 @@ private function _constructPdoDsn(array $params) */ public function getName() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Driver::getName() is deprecated' + ); + return 'pdo_pgsql'; } } diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php index fc2b881ffce..efced0c0093 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\Deprecations\Deprecation; use PDOException; use function array_merge; @@ -81,6 +82,12 @@ protected function _constructPdoDsn(array $params) */ public function getName() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Driver::getName() is deprecated' + ); + return 'pdo_sqlite'; } } diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php index d8f22505561..8784582eb37 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\AbstractSQLServerDriver; use Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception\PortWithoutHost; use Doctrine\DBAL\Driver\PDO; +use Doctrine\Deprecations\Deprecation; use function is_int; use function sprintf; @@ -95,6 +96,12 @@ private function getConnectionOptionsDsn(array $connectionOptions): string */ public function getName() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Driver::getName() is deprecated' + ); + return 'pdo_sqlsrv'; } } diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php index 81d88232dca..98d5f3f302f 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver; use Doctrine\DBAL\Exception; +use Doctrine\Deprecations\Deprecation; use function array_keys; use function array_map; @@ -46,6 +47,12 @@ public function connect(array $params, $username = null, $password = null, array */ public function getName() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Driver::getName() is deprecated' + ); + return 'sqlanywhere'; } diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php b/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php index a57128d9dd8..959dbcae1bd 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Driver\AbstractSQLServerDriver; use Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception\PortWithoutHost; +use Doctrine\Deprecations\Deprecation; /** * Driver for ext/sqlsrv. @@ -57,6 +58,12 @@ public function connect(array $params, $username = null, $password = null, array */ public function getName() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Driver::getName() is deprecated' + ); + return 'sqlsrv'; } } diff --git a/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php b/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php index 0b6ffbb9ded..35fadc40b54 100644 --- a/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php +++ b/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\Deprecations\Deprecation; /** * Event Arguments used when a Driver connection is established inside {@link Connection}. @@ -36,6 +37,13 @@ public function getConnection() */ public function getDriver() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'ConnectionEventArgs::getDriver() is deprecated, ' . + 'use ConnectionEventArgs::getConnection()->getDriver() instead.' + ); + return $this->connection->getDriver(); } @@ -46,6 +54,13 @@ public function getDriver() */ public function getDatabasePlatform() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'ConnectionEventArgs::getDatabasePlatform() is deprecated, ' . + 'use ConnectionEventArgs::getConnection()->getDatabasePlatform() instead.' + ); + return $this->connection->getDatabasePlatform(); } @@ -56,6 +71,13 @@ public function getDatabasePlatform() */ public function getSchemaManager() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'ConnectionEventArgs::getSchemaManager() is deprecated, ' . + 'use ConnectionEventArgs::getConnection()->getSchemaManager() instead.' + ); + return $this->connection->getSchemaManager(); } } diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php index 30a1a9ca78a..e61a48d064c 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\Deprecations\Deprecation; use function array_merge; use function func_get_args; @@ -67,6 +68,15 @@ public function getPlatform() */ public function addSql($sql) { + if (is_array($sql)) { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'Passing multiple SQL statements as an array to SchemaAlterTableAddColumnEventaArrgs::addSql() ' . + 'is deprecated. Pass each statement as an individual argument instead.' + ); + } + $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args()); return $this; diff --git a/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php index 7c962a928f4..4264e4b972e 100644 --- a/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; +use Doctrine\Deprecations\Deprecation; /** * Event Arguments used when the portable column definition is generated inside {@link AbstractPlatform}. @@ -103,6 +104,13 @@ public function getConnection() */ public function getDatabasePlatform() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'SchemaColumnDefinitionEventArgs::getDatabasePlatform() is deprecated, ' . + 'use SchemaColumnDefinitionEventArgs::getConnection()->getDatabasePlatform() instead.' + ); + return $this->connection->getDatabasePlatform(); } } diff --git a/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php index 055a19a7c27..868243c8069 100644 --- a/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Index; +use Doctrine\Deprecations\Deprecation; /** * Event Arguments used when the portable index definition is generated inside {@link AbstractSchemaManager}. @@ -83,10 +84,19 @@ public function getConnection() } /** + * @deprecated Use SchemaIndexDefinitionEventArgs::getConnection() and Connection::getDatabasePlatform() instead. + * * @return AbstractPlatform */ public function getDatabasePlatform() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'SchemaIndexDefinitionEventArgs::getDatabasePlatform() is deprecated, ' . + 'use SchemaIndexDefinitionEventArgs::getConnection()->getDatabasePlatform() instead.' + ); + return $this->connection->getDatabasePlatform(); } } diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index df037f070e4..2cad11a86e5 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Events; use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\Deprecations\Deprecation; use Throwable; use function array_filter; @@ -20,6 +21,7 @@ use function count; use function func_get_args; use function is_callable; +use function is_string; use function preg_match; use function str_replace; use function strtolower; @@ -197,6 +199,15 @@ public function listTableIndexes($table) */ public function tablesExist($names) { + if (is_string($names)) { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/issues/3580', + 'The usage of a string $tableNames in AbstractSchemaManager::tablesExist is deprecated. ' . + 'Pass a one-element array instead.' + ); + } + $names = array_map('strtolower', (array) $names); return count($names) === count(array_intersect($names, array_map('strtolower', $this->listTableNames())));