Skip to content

Commit

Permalink
[doctrineGH-3580] Several deprecation triggers.
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Mar 11, 2021
1 parent 9981c03 commit 9a32edf
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 database host from application config ' .
'or as a last resort from internal Connection::getParams() API.'
);

return $this->params['host'] ?? null;
}

Expand All @@ -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 database host from application config ' .
'or as a last resort from internal Connection::getParams() API.'
);

return $this->params['port'] ?? null;
}

Expand All @@ -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 database host from application config ' .
'or as a last resort from internal Connection::getParams() API.'
);

return $this->params['user'] ?? null;
}

Expand All @@ -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 database host from application config ' .
'or as a last resort from internal Connection::getParams() API.'
);

return $this->params['password'] ?? null;
}

Expand Down
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Driver\IBMDB2;

use Doctrine\DBAL\Driver\AbstractDB2Driver;
use Doctrine\Deprecations\Deprecation;

/**
* IBM DB2 Driver.
Expand Down Expand Up @@ -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';
}
}
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/Mysqli/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Exception;
use Doctrine\Deprecations\Deprecation;

class Driver extends AbstractMySQLDriver
{
Expand All @@ -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';
}
}
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/OCI8/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Exception;
use Doctrine\Deprecations\Deprecation;

use const OCI_NO_AUTO_COMMIT;

Expand Down Expand Up @@ -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';
}
}
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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';
}
}
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Driver\PDO;
use Doctrine\DBAL\Exception;
use Doctrine\Deprecations\Deprecation;
use PDOException;

/**
Expand Down Expand Up @@ -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';
}
}
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Driver\PDO;
use Doctrine\DBAL\Exception;
use Doctrine\Deprecations\Deprecation;
use PDOException;

/**
Expand Down Expand Up @@ -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';
}
}
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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';
}
}
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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';
}
}
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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';
}
}
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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';
}

Expand Down
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\DBAL\Driver\AbstractSQLServerDriver;
use Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception\PortWithoutHost;
use Doctrine\Deprecations\Deprecation;

/**
* Driver for ext/sqlsrv.
Expand Down Expand Up @@ -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';
}
}
22 changes: 22 additions & 0 deletions lib/Doctrine/DBAL/Event/ConnectionEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
}

Expand All @@ -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();
}
}
10 changes: 10 additions & 0 deletions lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down Expand Up @@ -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();
}
}
Loading

0 comments on commit 9a32edf

Please sign in to comment.