Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger runtime deprecations for previously deprecated APIs #4568

Merged
merged 5 commits into from Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Connection.php
Expand Up @@ -21,6 +21,7 @@
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\SQL\Parser;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;
use Throwable;
use Traversable;

Expand Down Expand Up @@ -69,7 +70,7 @@ class Connection
protected $_eventManager;

/**
* @deprecated Use {@link getExpressionBuilder()} instead.
* @deprecated Use {@link createExpressionBuilder()} instead.
*
* @var ExpressionBuilder
*/
Expand Down Expand Up @@ -296,6 +297,13 @@ public function createExpressionBuilder(): ExpressionBuilder
*/
public function getExpressionBuilder()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4515',
'Connection::getExpressionBuilder() is deprecated,'
. ' use Connection::createExpressionBuilder() instead.'
);

return $this->_expr;
}

Expand Down Expand Up @@ -1544,6 +1552,12 @@ public function createSchemaManager(): AbstractSchemaManager
*/
public function getSchemaManager()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4515',
'Connection::getSchemaManager() is deprecated, use Connection::createSchemaManager() instead.'
);

if ($this->_schemaManager === null) {
$this->_schemaManager = $this->createSchemaManager();
}
Expand Down
11 changes: 11 additions & 0 deletions src/Driver/PDO/SQLSrv/Statement.php
Expand Up @@ -6,8 +6,11 @@
use Doctrine\DBAL\Driver\Result;
use Doctrine\DBAL\Driver\Statement as StatementInterface;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;
use PDO;

use function func_num_args;

final class Statement implements StatementInterface
{
/** @var PDOStatement */
Expand All @@ -32,6 +35,14 @@ public function __construct(PDOStatement $statement)
*/
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null, $driverOptions = null)
{
if (func_num_args() > 4) {
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4533',
'The $driverOptions argument of Statement::bindParam() is deprecated.'
);
}

switch ($type) {
case ParameterType::LARGE_OBJECT:
case ParameterType::BINARY:
Expand Down
10 changes: 10 additions & 0 deletions src/Driver/PDO/Statement.php
Expand Up @@ -7,12 +7,14 @@
use Doctrine\DBAL\Driver\Result as ResultInterface;
use Doctrine\DBAL\Driver\Statement as StatementInterface;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;
use PDO;
use PDOException;
use PDOStatement;

use function array_slice;
use function func_get_args;
use function func_num_args;

final class Statement implements StatementInterface
{
Expand Down Expand Up @@ -64,6 +66,14 @@ public function bindValue($param, $value, $type = ParameterType::STRING)
*/
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null, $driverOptions = null)
{
if (func_num_args() > 4) {
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4533',
'The $driverOptions argument of Statement::bindParam() is deprecated.'
);
}

$type = $this->convertParamType($type);

try {
Expand Down
14 changes: 14 additions & 0 deletions src/Platforms/AbstractPlatform.php
Expand Up @@ -2758,6 +2758,13 @@ public function getListDatabasesSQL()
*/
public function getListNamespacesSQL()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'AbstractPlatform::getListNamespacesSQL() is deprecated,'
. ' use AbstractSchemaManager::listSchemaNames() instead.'
);

throw Exception::notSupported(__METHOD__);
}

Expand Down Expand Up @@ -3529,6 +3536,13 @@ protected function createReservedKeywordsList(): KeywordList
*/
protected function getReservedKeywordsClass()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'AbstractPlatform::getReservedKeywordsClass() is deprecated,'
. ' use AbstractPlatform::createReservedKeywordsList() instead.'
);

throw Exception::notSupported(__METHOD__);
}

Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/DB2Platform.php
Expand Up @@ -9,6 +9,7 @@
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\Deprecation;

use function array_merge;
use function count;
Expand Down Expand Up @@ -901,6 +902,13 @@ public function supportsSavepoints()
*/
protected function getReservedKeywordsClass()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'DB2Platform::getReservedKeywordsClass() is deprecated,'
. ' use DB2Platform::createReservedKeywordsList() instead.'
);

return Keywords\DB2Keywords::class;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/MariaDb1027Platform.php
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\Deprecation;

/**
* Provides the behavior, features and SQL dialect of the MariaDB 10.2 (10.2.7 GA) database platform.
Expand All @@ -26,6 +27,13 @@ public function getJsonTypeDeclarationSQL(array $column): string
*/
protected function getReservedKeywordsClass(): string
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'MariaDb1027Platform::getReservedKeywordsClass() is deprecated,'
. ' use MariaDb1027Platform::createReservedKeywordsList() instead.'
);

return Keywords\MariaDb102Keywords::class;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/MySQL57Platform.php
Expand Up @@ -6,6 +6,7 @@
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\SQL\Parser;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\Deprecation;

/**
* Provides the behavior, features and SQL dialect of the MySQL 5.7 (5.7.9 GA) database platform.
Expand Down Expand Up @@ -64,6 +65,13 @@ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName)
*/
protected function getReservedKeywordsClass()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'MySQL57Platform::getReservedKeywordsClass() is deprecated,'
. ' use MySQL57Platform::createReservedKeywordsList() instead.'
);

return Keywords\MySQL57Keywords::class;
}

Expand Down
9 changes: 9 additions & 0 deletions src/Platforms/MySQL80Platform.php
Expand Up @@ -2,6 +2,8 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\Deprecations\Deprecation;

/**
* Provides the behavior, features and SQL dialect of the MySQL 8.0 (8.0 GA) database platform.
*/
Expand All @@ -14,6 +16,13 @@ class MySQL80Platform extends MySQL57Platform
*/
protected function getReservedKeywordsClass()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'MySQL80Platform::getReservedKeywordsClass() is deprecated,'
. ' use MySQL80Platform::createReservedKeywordsList() instead.'
);

return Keywords\MySQL80Keywords::class;
}
}
8 changes: 8 additions & 0 deletions src/Platforms/MySQLPlatform.php
Expand Up @@ -11,6 +11,7 @@
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\TextType;
use Doctrine\Deprecations\Deprecation;
use InvalidArgumentException;

use function array_diff_key;
Expand Down Expand Up @@ -1110,6 +1111,13 @@ public function getBinaryMaxLength()
*/
protected function getReservedKeywordsClass()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'MySQLPlatform::getReservedKeywordsClass() is deprecated,'
. ' use MySQLPlatform::createReservedKeywordsList() instead.'
);

return Keywords\MySQLKeywords::class;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/OraclePlatform.php
Expand Up @@ -11,6 +11,7 @@
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\BinaryType;
use Doctrine\Deprecations\Deprecation;
use InvalidArgumentException;

use function array_merge;
Expand Down Expand Up @@ -1165,6 +1166,13 @@ public function releaseSavePoint($savepoint)
*/
protected function getReservedKeywordsClass()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'OraclePlatform::getReservedKeywordsClass() is deprecated,'
. ' use OraclePlatform::createReservedKeywordsList() instead.'
);

return Keywords\OracleKeywords::class;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/PostgreSQL100Platform.php
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords;
use Doctrine\Deprecations\Deprecation;

/**
* Provides the behavior, features and SQL dialect of the PostgreSQL 10.0 database platform.
Expand All @@ -16,6 +17,13 @@ class PostgreSQL100Platform extends PostgreSQL94Platform
*/
protected function getReservedKeywordsClass(): string
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'PostgreSQL100Platform::getReservedKeywordsClass() is deprecated,'
. ' use PostgreSQL100Platform::createReservedKeywordsList() instead.'
);

return PostgreSQL100Keywords::class;
}

Expand Down
15 changes: 15 additions & 0 deletions src/Platforms/PostgreSQL94Platform.php
Expand Up @@ -14,6 +14,7 @@
use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;
use UnexpectedValueException;

use function array_diff;
Expand Down Expand Up @@ -232,6 +233,13 @@ public function getListDatabasesSQL()
*/
public function getListNamespacesSQL()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'PostgreSQL94Platform::getListNamespacesSQL() is deprecated,'
. ' use PostgreSQLSchemaManager::listSchemaNames() instead.'
);

return "SELECT schema_name AS nspname
FROM information_schema.schemata
WHERE schema_name NOT LIKE 'pg\_%'
Expand Down Expand Up @@ -1181,6 +1189,13 @@ public function hasNativeJsonType()
*/
protected function getReservedKeywordsClass()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'PostgreSQL94Platform::getReservedKeywordsClass() is deprecated,'
. ' use PostgreSQL94Platform::createReservedKeywordsList() instead.'
);

return Keywords\PostgreSQL94Keywords::class;
}

Expand Down
15 changes: 15 additions & 0 deletions src/Platforms/SQLServer2012Platform.php
Expand Up @@ -12,6 +12,7 @@
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\Deprecations\Deprecation;
use InvalidArgumentException;

use function array_merge;
Expand Down Expand Up @@ -1165,6 +1166,13 @@ public function getListDatabasesSQL()
*/
public function getListNamespacesSQL()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'SQLServer2012Platform::getListNamespacesSQL() is deprecated,'
. ' use SQLServerSchemaManager::listSchemaNames() instead.'
);

return "SELECT name FROM sys.schemas WHERE name NOT IN('guest', 'INFORMATION_SCHEMA', 'sys')";
}

Expand Down Expand Up @@ -1561,6 +1569,13 @@ public function getForUpdateSQL()
*/
protected function getReservedKeywordsClass()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'QLServer2012Platform::getReservedKeywordsClass() is deprecated,'
. ' use QLServer2012Platform::createReservedKeywordsList() instead.'
);

return Keywords\SQLServer2012Keywords::class;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/SqlitePlatform.php
Expand Up @@ -11,6 +11,7 @@
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types;
use Doctrine\Deprecations\Deprecation;

use function array_merge;
use function array_unique;
Expand Down Expand Up @@ -689,6 +690,13 @@ protected function initializeDoctrineTypeMappings()
*/
protected function getReservedKeywordsClass()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'SqlitePlatform::getReservedKeywordsClass() is deprecated,'
. ' use SqlitePlatform::createReservedKeywordsList() instead.'
);

return Keywords\SQLiteKeywords::class;
}

Expand Down