Skip to content

Commit

Permalink
Merge pull request #4583 from morozov/issues/4510
Browse files Browse the repository at this point in the history
[GH-4510] Remove AbstractPlatform::getReservedKeywordsClass()
  • Loading branch information
morozov committed Apr 4, 2021
2 parents ac2763f + b62fe1b commit 461b3b7
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 172 deletions.
4 changes: 4 additions & 0 deletions 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.
Expand Down
6 changes: 0 additions & 6 deletions psalm.xml.dist
Expand Up @@ -54,11 +54,6 @@
See https://github.com/doctrine/dbal/pull/4317
-->
<file name="tests/Functional/LegacyAPITest.php"/>
<!--
This suppression should be removed in 4.0.x
See https://github.com/doctrine/dbal/issues/4510
-->
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getReservedKeywordsClass"/>
</errorLevel>
</DeprecatedMethod>
<DocblockTypeContradiction>
Expand Down Expand Up @@ -217,7 +212,6 @@
<UnsafeInstantiation>
<errorLevel type="suppress">
<!-- See https://github.com/doctrine/dbal/issues/4510 -->
<file name="src/Platforms/AbstractPlatform.php"/>
<file name="src/Tools/Console/Command/ReservedWordsCommand.php"/>
<!-- See https://github.com/doctrine/dbal/issues/4511 -->
<file name="src/DriverManager.php"/>
Expand Down
37 changes: 1 addition & 36 deletions src/Platforms/AbstractPlatform.php
Expand Up @@ -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;

Expand Down Expand Up @@ -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<KeywordList>
*/
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.
Expand Down
17 changes: 4 additions & 13 deletions src/Platforms/DB2Platform.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
17 changes: 4 additions & 13 deletions src/Platforms/MariaDb1027Platform.php
Expand Up @@ -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.
Expand All @@ -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
Expand Down
17 changes: 4 additions & 13 deletions src/Platforms/MySQL57Platform.php
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
17 changes: 4 additions & 13 deletions src/Platforms/MySQL80Platform.php
Expand Up @@ -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();
}
}
17 changes: 4 additions & 13 deletions src/Platforms/MySQLPlatform.php
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}

/**
Expand Down
17 changes: 4 additions & 13 deletions src/Platforms/OraclePlatform.php
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}

/**
Expand Down
16 changes: 3 additions & 13 deletions src/Platforms/PostgreSQL100Platform.php
Expand Up @@ -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
Expand Down
17 changes: 4 additions & 13 deletions src/Platforms/PostgreSQL94Platform.php
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}

/**
Expand Down

0 comments on commit 461b3b7

Please sign in to comment.