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

Deprecate AbstractPlatform::getReservedKeywordsClass() #4547

Merged
merged 1 commit into from
Mar 17, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Upgrade to 3.1

## Deprecated `AbstractPlatform::getReservedKeywordsClass()`

Instead of implementing `getReservedKeywordsClass()`, `AbstractPlatform` subclasses should implement
`createReservedKeywordsList()`.

## Deprecated `$driverOptions` argument of `PDO\Statement::bindParam()` and `PDO\SQLSrv\Statement::bindParam()`

The usage of the `$driverOptions` argument of `PDO\Statement::bindParam()` and `PDO\SQLSrv\Statement::bindParam()` is deprecated.
Expand Down
4 changes: 4 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
See https://github.com/doctrine/dbal/pull/4317
-->
<file name="tests/Functional/LegacyAPITest.php"/>
<!--
This suppression should be removed in 4.0.0.
-->
<file name="src/Platforms/AbstractPlatform.php"/>
<!--
This suppression should be removed in 4.0.x
See https://github.com/doctrine/dbal/pull/3865
Expand Down
22 changes: 17 additions & 5 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -3480,25 +3480,37 @@ public function rollbackSavePoint($savepoint)
final public function getReservedKeywordsList()
{
// Check for an existing instantiation of the keywords class.
if ($this->_keywords !== null) {
return $this->_keywords;
if ($this->_keywords === null) {
// Store the instance so it doesn't need to be generated on every request.
$this->_keywords = $this->createReservedKeywordsList();
}

return $this->_keywords;
}

/**
* 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 Exception::notSupported(__METHOD__);
}

// Store the instance so it doesn't need to be generated on every request.
$this->_keywords = $keywords;

return $keywords;
}

/**
* Returns the class name of the reserved keywords list.
*
* @deprecated Implement {@link createReservedKeywordsList()} instead.
*
* @return string
*
* @throws Exception If not supported on this platform.
Expand Down
2 changes: 2 additions & 0 deletions src/Platforms/DB2Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,8 @@ public function supportsSavepoints()

/**
* {@inheritDoc}
*
* @deprecated Implement {@link createReservedKeywordsList()} instead.
*/
protected function getReservedKeywordsClass()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Platforms/MariaDb1027Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public function getJsonTypeDeclarationSQL(array $column): string
return 'LONGTEXT';
}

/**
* @deprecated Implement {@link createReservedKeywordsList()} instead.
*/
protected function getReservedKeywordsClass(): string
{
return Keywords\MariaDb102Keywords::class;
Expand Down
2 changes: 2 additions & 0 deletions src/Platforms/MySQL57Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName)

/**
* {@inheritdoc}
*
* @deprecated Implement {@link createReservedKeywordsList()} instead.
*/
protected function getReservedKeywordsClass()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Platforms/MySQL80Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class MySQL80Platform extends MySQL57Platform
{
/**
* {@inheritdoc}
*
* @deprecated Implement {@link createReservedKeywordsList()} instead.
*/
protected function getReservedKeywordsClass()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Platforms/MySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,8 @@ public function getBinaryMaxLength()

/**
* {@inheritDoc}
*
* @deprecated Implement {@link createReservedKeywordsList()} instead.
*/
protected function getReservedKeywordsClass()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Platforms/OraclePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,8 @@ public function releaseSavePoint($savepoint)

/**
* {@inheritDoc}
*
* @deprecated Implement {@link createReservedKeywordsList()} instead.
*/
protected function getReservedKeywordsClass()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Platforms/PostgreSQL100Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*/
class PostgreSQL100Platform extends PostgreSQL94Platform
{
/**
* @deprecated Implement {@link createReservedKeywordsList()} instead.
*/
protected function getReservedKeywordsClass(): string
{
return PostgreSQL100Keywords::class;
Expand Down
2 changes: 2 additions & 0 deletions src/Platforms/PostgreSQL94Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,8 @@ public function hasNativeJsonType()

/**
* {@inheritDoc}
*
* @deprecated Implement {@link createReservedKeywordsList()} instead.
*/
protected function getReservedKeywordsClass()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Platforms/SQLServer2012Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,8 @@ public function getForUpdateSQL()

/**
* {@inheritDoc}
*
* @deprecated Implement {@link createReservedKeywordsList()} instead.
*/
protected function getReservedKeywordsClass()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,8 @@ protected function initializeDoctrineTypeMappings()

/**
* {@inheritDoc}
*
* @deprecated Implement {@link createReservedKeywordsList()} instead.
*/
protected function getReservedKeywordsClass()
{
Expand Down