From b62fe1b451a7977f868b3ed6163b344e8c43486b Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 1 Apr 2021 19:23:49 -0700 Subject: [PATCH] [GH-4510] Remove AbstractPlatform::getReservedKeywordsClass() --- UPGRADE.md | 4 +++ psalm.xml.dist | 6 ---- src/Platforms/AbstractPlatform.php | 37 +------------------------ src/Platforms/DB2Platform.php | 17 +++--------- src/Platforms/MariaDb1027Platform.php | 17 +++--------- src/Platforms/MySQL57Platform.php | 17 +++--------- src/Platforms/MySQL80Platform.php | 17 +++--------- src/Platforms/MySQLPlatform.php | 17 +++--------- src/Platforms/OraclePlatform.php | 17 +++--------- src/Platforms/PostgreSQL100Platform.php | 16 ++--------- src/Platforms/PostgreSQL94Platform.php | 17 +++--------- src/Platforms/SQLServer2012Platform.php | 17 +++--------- src/Platforms/SqlitePlatform.php | 17 +++--------- 13 files changed, 44 insertions(+), 172 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index ffd27c19dc2..56fd9f39179 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 4.0 +## Removed `AbstractPlatform::getReservedKeywordsClass()` + +Instead of implementing `AbstractPlatform::getReservedKeywordsClass()`, platforms must implement `AbstractPlatform::createReservedKeywordsList()`. The latter has been made abstract. + ## `PostgreSQLSchemaManager` methods have been made protected. `PostgreSQLSchemaManager::getExistingSchemaSearchPaths()` and `::determineExistingSchemaSearchPaths()` have been made protected. diff --git a/psalm.xml.dist b/psalm.xml.dist index dcd79ac15a8..95e3a1cfd42 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -54,11 +54,6 @@ See https://github.com/doctrine/dbal/pull/4317 --> - - @@ -217,7 +212,6 @@ - diff --git a/src/Platforms/AbstractPlatform.php b/src/Platforms/AbstractPlatform.php index 9e262b3f4ac..ae96bb3d8b9 100644 --- a/src/Platforms/AbstractPlatform.php +++ b/src/Platforms/AbstractPlatform.php @@ -36,7 +36,6 @@ use Doctrine\DBAL\Types; use Doctrine\DBAL\Types\Exception\TypeNotFound; use Doctrine\DBAL\Types\Type; -use Doctrine\Deprecations\Deprecation; use InvalidArgumentException; use UnexpectedValueException; @@ -3108,42 +3107,8 @@ final public function getReservedKeywordsList(): KeywordList /** * Creates an instance of the reserved keyword list of this platform. - * - * This method will become @abstract in DBAL 4.0.0. - * - * @throws Exception - */ - protected function createReservedKeywordsList(): KeywordList - { - $class = $this->getReservedKeywordsClass(); - $keywords = new $class(); - if (! $keywords instanceof KeywordList) { - throw NotSupported::new(__METHOD__); - } - - return $keywords; - } - - /** - * Returns the class name of the reserved keywords list. - * - * @deprecated Implement {@link createReservedKeywordsList()} instead. - * - * @throws Exception If not supported on this platform. - * - * @psalm-return class-string */ - protected function getReservedKeywordsClass(): string - { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/issues/4510', - 'AbstractPlatform::getReservedKeywordsClass() is deprecated,' - . ' use AbstractPlatform::createReservedKeywordsList() instead.' - ); - - throw NotSupported::new(__METHOD__); - } + abstract protected function createReservedKeywordsList(): KeywordList; /** * Quotes a literal string. diff --git a/src/Platforms/DB2Platform.php b/src/Platforms/DB2Platform.php index 2da2b1c585e..ff1e420b6da 100644 --- a/src/Platforms/DB2Platform.php +++ b/src/Platforms/DB2Platform.php @@ -5,13 +5,14 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\DBAL\Platforms\Exception\NotSupported; +use Doctrine\DBAL\Platforms\Keywords\DB2Keywords; +use Doctrine\DBAL\Platforms\Keywords\KeywordList; use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\Identifier; use Doctrine\DBAL\Schema\Index; 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; @@ -752,19 +753,9 @@ public function supportsSavepoints(): bool return false; } - /** - * @deprecated Implement {@link createReservedKeywordsList()} instead. - */ - protected function getReservedKeywordsClass(): string + protected function createReservedKeywordsList(): KeywordList { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/issues/4510', - 'DB2Platform::getReservedKeywordsClass() is deprecated,' - . ' use DB2Platform::createReservedKeywordsList() instead.' - ); - - return Keywords\DB2Keywords::class; + return new DB2Keywords(); } public function getListTableCommentsSQL(string $table): string diff --git a/src/Platforms/MariaDb1027Platform.php b/src/Platforms/MariaDb1027Platform.php index 550a9f6bcda..87dd069c12c 100644 --- a/src/Platforms/MariaDb1027Platform.php +++ b/src/Platforms/MariaDb1027Platform.php @@ -4,8 +4,9 @@ namespace Doctrine\DBAL\Platforms; +use Doctrine\DBAL\Platforms\Keywords\KeywordList; +use Doctrine\DBAL\Platforms\Keywords\MariaDb102Keywords; 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. @@ -24,19 +25,9 @@ public function getJsonTypeDeclarationSQL(array $column): string return 'LONGTEXT'; } - /** - * @deprecated Implement {@link createReservedKeywordsList()} instead. - */ - protected function getReservedKeywordsClass(): string + protected function createReservedKeywordsList(): KeywordList { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/issues/4510', - 'MariaDb1027Platform::getReservedKeywordsClass() is deprecated,' - . ' use MariaDb1027Platform::createReservedKeywordsList() instead.' - ); - - return Keywords\MariaDb102Keywords::class; + return new MariaDb102Keywords(); } protected function initializeDoctrineTypeMappings(): void diff --git a/src/Platforms/MySQL57Platform.php b/src/Platforms/MySQL57Platform.php index c3e667011dc..a0256a0e1c5 100644 --- a/src/Platforms/MySQL57Platform.php +++ b/src/Platforms/MySQL57Platform.php @@ -4,11 +4,12 @@ namespace Doctrine\DBAL\Platforms; +use Doctrine\DBAL\Platforms\Keywords\KeywordList; +use Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords; use Doctrine\DBAL\Schema\Index; 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. @@ -57,19 +58,9 @@ protected function getRenameIndexSQL(string $oldIndexName, Index $index, string return ['ALTER TABLE ' . $tableName . ' RENAME INDEX ' . $oldIndexName . ' TO ' . $index->getQuotedName($this)]; } - /** - * @deprecated Implement {@link createReservedKeywordsList()} instead. - */ - protected function getReservedKeywordsClass(): string + protected function createReservedKeywordsList(): KeywordList { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/issues/4510', - 'MySQL57Platform::getReservedKeywordsClass() is deprecated,' - . ' use MySQL57Platform::createReservedKeywordsList() instead.' - ); - - return Keywords\MySQL57Keywords::class; + return new MySQL57Keywords(); } protected function initializeDoctrineTypeMappings(): void diff --git a/src/Platforms/MySQL80Platform.php b/src/Platforms/MySQL80Platform.php index a6b4b2c37dc..39da98f1d57 100644 --- a/src/Platforms/MySQL80Platform.php +++ b/src/Platforms/MySQL80Platform.php @@ -4,25 +4,16 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\Deprecations\Deprecation; +use Doctrine\DBAL\Platforms\Keywords\KeywordList; +use Doctrine\DBAL\Platforms\Keywords\MySQL80Keywords; /** * Provides the behavior, features and SQL dialect of the MySQL 8.0 (8.0 GA) database platform. */ class MySQL80Platform extends MySQL57Platform { - /** - * @deprecated Implement {@link createReservedKeywordsList()} instead. - */ - protected function getReservedKeywordsClass(): string + protected function createReservedKeywordsList(): KeywordList { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/issues/4510', - 'MySQL80Platform::getReservedKeywordsClass() is deprecated,' - . ' use MySQL80Platform::createReservedKeywordsList() instead.' - ); - - return Keywords\MySQL80Keywords::class; + return new MySQL80Keywords(); } } diff --git a/src/Platforms/MySQLPlatform.php b/src/Platforms/MySQLPlatform.php index 5667cf6a19e..b983c6177a4 100644 --- a/src/Platforms/MySQLPlatform.php +++ b/src/Platforms/MySQLPlatform.php @@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Platforms\Keywords\KeywordList; +use Doctrine\DBAL\Platforms\Keywords\MySQLKeywords; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Identifier; use Doctrine\DBAL\Schema\Index; @@ -13,7 +15,6 @@ 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; @@ -967,19 +968,9 @@ protected function initializeDoctrineTypeMappings(): void ]; } - /** - * @deprecated Implement {@link createReservedKeywordsList()} instead. - */ - protected function getReservedKeywordsClass(): string + protected function createReservedKeywordsList(): KeywordList { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/issues/4510', - 'MySQLPlatform::getReservedKeywordsClass() is deprecated,' - . ' use MySQLPlatform::createReservedKeywordsList() instead.' - ); - - return Keywords\MySQLKeywords::class; + return new MySQLKeywords(); } /** diff --git a/src/Platforms/OraclePlatform.php b/src/Platforms/OraclePlatform.php index 40cbfc0d9df..1fa5c92d66f 100644 --- a/src/Platforms/OraclePlatform.php +++ b/src/Platforms/OraclePlatform.php @@ -6,6 +6,8 @@ use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\ColumnLengthRequired; +use Doctrine\DBAL\Platforms\Keywords\KeywordList; +use Doctrine\DBAL\Platforms\Keywords\OracleKeywords; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Identifier; use Doctrine\DBAL\Schema\Index; @@ -14,7 +16,6 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\BinaryType; -use Doctrine\Deprecations\Deprecation; use InvalidArgumentException; use function array_merge; @@ -1027,19 +1028,9 @@ public function releaseSavePoint(string $savepoint): string return ''; } - /** - * @deprecated Implement {@link createReservedKeywordsList()} instead. - */ - protected function getReservedKeywordsClass(): string + protected function createReservedKeywordsList(): KeywordList { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/issues/4510', - 'OraclePlatform::getReservedKeywordsClass() is deprecated,' - . ' use OraclePlatform::createReservedKeywordsList() instead.' - ); - - return Keywords\OracleKeywords::class; + return new OracleKeywords(); } /** diff --git a/src/Platforms/PostgreSQL100Platform.php b/src/Platforms/PostgreSQL100Platform.php index 31d3ebd69e1..8072820fec2 100644 --- a/src/Platforms/PostgreSQL100Platform.php +++ b/src/Platforms/PostgreSQL100Platform.php @@ -4,27 +4,17 @@ namespace Doctrine\DBAL\Platforms; +use Doctrine\DBAL\Platforms\Keywords\KeywordList; use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords; -use Doctrine\Deprecations\Deprecation; /** * Provides the behavior, features and SQL dialect of the PostgreSQL 10.0 database platform. */ class PostgreSQL100Platform extends PostgreSQL94Platform { - /** - * @deprecated Implement {@link createReservedKeywordsList()} instead. - */ - protected function getReservedKeywordsClass(): string + protected function createReservedKeywordsList(): KeywordList { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/issues/4510', - 'PostgreSQL100Platform::getReservedKeywordsClass() is deprecated,' - . ' use PostgreSQL100Platform::createReservedKeywordsList() instead.' - ); - - return PostgreSQL100Keywords::class; + return new PostgreSQL100Keywords(); } public function getListSequencesSQL(string $database): string diff --git a/src/Platforms/PostgreSQL94Platform.php b/src/Platforms/PostgreSQL94Platform.php index 592bae551e7..07d40681b1a 100644 --- a/src/Platforms/PostgreSQL94Platform.php +++ b/src/Platforms/PostgreSQL94Platform.php @@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Platforms; +use Doctrine\DBAL\Platforms\Keywords\KeywordList; +use Doctrine\DBAL\Platforms\Keywords\PostgreSQL94Keywords; use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Identifier; @@ -15,7 +17,6 @@ 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; @@ -993,19 +994,9 @@ public function hasNativeJsonType(): bool return true; } - /** - * @deprecated Implement {@link createReservedKeywordsList()} instead. - */ - protected function getReservedKeywordsClass(): string + protected function createReservedKeywordsList(): KeywordList { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/issues/4510', - 'PostgreSQL94Platform::getReservedKeywordsClass() is deprecated,' - . ' use PostgreSQL94Platform::createReservedKeywordsList() instead.' - ); - - return Keywords\PostgreSQL94Keywords::class; + return new PostgreSQL94Keywords(); } /** diff --git a/src/Platforms/SQLServer2012Platform.php b/src/Platforms/SQLServer2012Platform.php index 22fcda1b9d3..f2b009f72f1 100644 --- a/src/Platforms/SQLServer2012Platform.php +++ b/src/Platforms/SQLServer2012Platform.php @@ -7,6 +7,8 @@ use Doctrine\DBAL\Exception\ColumnLengthRequired; use Doctrine\DBAL\Exception\InvalidLockMode; use Doctrine\DBAL\LockMode; +use Doctrine\DBAL\Platforms\Keywords\KeywordList; +use Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\ForeignKeyConstraint; @@ -15,7 +17,6 @@ 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; @@ -1374,19 +1375,9 @@ public function getForUpdateSQL(): string return ' '; } - /** - * @deprecated Implement {@link createReservedKeywordsList()} instead. - */ - protected function getReservedKeywordsClass(): string + protected function createReservedKeywordsList(): KeywordList { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/issues/4510', - 'QLServer2012Platform::getReservedKeywordsClass() is deprecated,' - . ' use QLServer2012Platform::createReservedKeywordsList() instead.' - ); - - return Keywords\SQLServer2012Keywords::class; + return new SQLServer2012Keywords(); } public function quoteSingleIdentifier(string $str): string diff --git a/src/Platforms/SqlitePlatform.php b/src/Platforms/SqlitePlatform.php index f72b77d6ce1..d088763a421 100644 --- a/src/Platforms/SqlitePlatform.php +++ b/src/Platforms/SqlitePlatform.php @@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Platforms\Keywords\KeywordList; +use Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords; use Doctrine\DBAL\Schema\Constraint; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Identifier; @@ -13,7 +15,6 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types; -use Doctrine\Deprecations\Deprecation; use InvalidArgumentException; use function array_merge; @@ -587,19 +588,9 @@ protected function initializeDoctrineTypeMappings(): void ]; } - /** - * @deprecated Implement {@link createReservedKeywordsList()} instead. - */ - protected function getReservedKeywordsClass(): string + protected function createReservedKeywordsList(): KeywordList { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/issues/4510', - 'SqlitePlatform::getReservedKeywordsClass() is deprecated,' - . ' use SqlitePlatform::createReservedKeywordsList() instead.' - ); - - return Keywords\SQLiteKeywords::class; + return new SQLiteKeywords(); } /**