Skip to content

Commit 5ebfe8b

Browse files
authored
Merge pull request #6607 from morozov/deprecate-keyword-lists
Deprecate reserved keyword lists
2 parents e68422d + 4882bc6 commit 5ebfe8b

24 files changed

+180
-2
lines changed

UPGRADE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ awareness about deprecated code.
88

99
# Upgrade to 4.3
1010

11+
## Deprecated Reserved Keyword Lists
12+
13+
The use of DBAL as the source for platform-specific reserved keyword lists has been deprecated. The following components
14+
have been deprecated:
15+
16+
1. The `KeywordList` class and all its subclasses.
17+
2. The methods `AbstractPlatform::createReservedKeywordsList()` and `::getReservedKeywordsList()`.
18+
3. The `AbstractPlatform::$_keywords` property.
19+
20+
Please refer to the official documentation provided by the respective database vendor for up-to-date information on
21+
reserved keywords.
22+
23+
Additionally, the `MySQL84Platform` class has been deprecated. Use the `MySQLPlatform` class instead.
24+
1125
## Deprecated relying on the current implementation of the database object name parser
1226

1327
The current object name parser implicitly quotes identifiers in the following cases:

psalm.xml.dist

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@
5252
<referencedClass name="Doctrine\DBAL\Platforms\MariaDB1052Platform" />
5353
<referencedClass name="Doctrine\DBAL\Platforms\MySQL80Platform" />
5454
<referencedClass name="Doctrine\DBAL\Platforms\PostgreSQL120Platform" />
55+
56+
<!--
57+
https://github.com/doctrine/dbal/pull/6607
58+
TODO: remove in 5.0.0
59+
-->
60+
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\KeywordList" />
61+
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\DB2Keywords" />
62+
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\MariaDBKeywords" />
63+
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\MySQLKeywords" />
64+
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\MySQL84Keywords" />
65+
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords" />
66+
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\OracleKeywords" />
67+
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords" />
68+
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords" />
69+
<referencedClass name="Doctrine\DBAL\Platforms\MySQL84Platform" />
5570
</errorLevel>
5671
</DeprecatedClass>
5772
<DeprecatedMethod>
@@ -80,8 +95,24 @@
8095
TODO: remove in 5.0.0
8196
-->
8297
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::quoteIdentifier" />
98+
99+
<!--
100+
https://github.com/doctrine/dbal/pull/6607
101+
TODO: remove in 5.0.0
102+
-->
103+
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::createReservedKeywordsList" />
104+
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getReservedKeywordsList" />
83105
</errorLevel>
84106
</DeprecatedMethod>
107+
<DeprecatedProperty>
108+
<errorLevel type="suppress">
109+
<!--
110+
https://github.com/doctrine/dbal/pull/6607
111+
TODO: remove in 5.0.0
112+
-->
113+
<referencedProperty name="Doctrine\DBAL\Platforms\AbstractPlatform::$_keywords" />
114+
</errorLevel>
115+
</DeprecatedProperty>
85116
<DocblockTypeContradiction>
86117
<errorLevel type="suppress">
87118
<!--

src/Platforms/AbstractMySQLPlatform.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Doctrine\DBAL\SQL\Builder\SelectSQLBuilder;
1919
use Doctrine\DBAL\TransactionIsolationLevel;
2020
use Doctrine\DBAL\Types\Types;
21+
use Doctrine\Deprecations\Deprecation;
2122

2223
use function array_map;
2324
use function array_merge;
@@ -763,8 +764,16 @@ protected function initializeDoctrineTypeMappings(): void
763764
];
764765
}
765766

767+
/** @deprecated */
766768
protected function createReservedKeywordsList(): KeywordList
767769
{
770+
Deprecation::triggerIfCalledFromOutside(
771+
'doctrine/dbal',
772+
'https://github.com/doctrine/dbal/pull/6607',
773+
'%s is deprecated.',
774+
__METHOD__,
775+
);
776+
768777
return new MySQLKeywords();
769778
}
770779

src/Platforms/AbstractPlatform.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ abstract class AbstractPlatform
8484

8585
/**
8686
* Holds the KeywordList instance for the current platform.
87+
*
88+
* @deprecated
8789
*/
8890
protected ?KeywordList $_keywords = null;
8991

@@ -2170,15 +2172,26 @@ public function rollbackSavePoint(string $savepoint): string
21702172

21712173
/**
21722174
* Returns the keyword list instance of this platform.
2175+
*
2176+
* @deprecated
21732177
*/
21742178
final public function getReservedKeywordsList(): KeywordList
21752179
{
2180+
Deprecation::triggerIfCalledFromOutside(
2181+
'doctrine/dbal',
2182+
'https://github.com/doctrine/dbal/pull/6607',
2183+
'%s is deprecated.',
2184+
__METHOD__,
2185+
);
2186+
21762187
// Store the instance so it doesn't need to be generated on every request.
21772188
return $this->_keywords ??= $this->createReservedKeywordsList();
21782189
}
21792190

21802191
/**
21812192
* Creates an instance of the reserved keyword list of this platform.
2193+
*
2194+
* @deprecated
21822195
*/
21832196
abstract protected function createReservedKeywordsList(): KeywordList;
21842197

src/Platforms/DB2Platform.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Doctrine\DBAL\TransactionIsolationLevel;
1919
use Doctrine\DBAL\Types\DateTimeType;
2020
use Doctrine\DBAL\Types\Types;
21+
use Doctrine\Deprecations\Deprecation;
2122

2223
use function array_merge;
2324
use function count;
@@ -591,8 +592,16 @@ public function supportsSavepoints(): bool
591592
return false;
592593
}
593594

595+
/** @deprecated */
594596
protected function createReservedKeywordsList(): KeywordList
595597
{
598+
Deprecation::triggerIfCalledFromOutside(
599+
'doctrine/dbal',
600+
'https://github.com/doctrine/dbal/pull/6607',
601+
'%s is deprecated.',
602+
__METHOD__,
603+
);
604+
596605
return new DB2Keywords();
597606
}
598607

src/Platforms/Keywords/DB2Keywords.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
/**
88
* DB2 Keywords.
9+
*
10+
* @deprecated
911
*/
1012
class DB2Keywords extends KeywordList
1113
{

src/Platforms/Keywords/KeywordList.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,32 @@
44

55
namespace Doctrine\DBAL\Platforms\Keywords;
66

7+
use Doctrine\Deprecations\Deprecation;
8+
79
use function array_flip;
810
use function array_map;
911
use function strtoupper;
1012

1113
/**
1214
* Abstract interface for a SQL reserved keyword dictionary.
15+
*
16+
* @deprecated
1317
*/
1418
abstract class KeywordList
1519
{
1620
/** @var string[]|null */
1721
private ?array $keywords = null;
1822

23+
public function __construct()
24+
{
25+
Deprecation::triggerIfCalledFromOutside(
26+
'doctrine/dbal',
27+
'https://github.com/doctrine/dbal/pull/6607',
28+
'%s is deprecated.',
29+
static::class,
30+
);
31+
}
32+
1933
/**
2034
* Checks if the given word is a keyword of this dialect/vendor platform.
2135
*/

src/Platforms/Keywords/MariaDBKeywords.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Doctrine\DBAL\Platforms\Keywords;
66

7+
/** @deprecated */
78
class MariaDBKeywords extends MySQLKeywords
89
{
910
/**

src/Platforms/Keywords/MySQL80Keywords.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* MySQL 8.0 reserved keywords list.
1111
*
12-
* @deprecated This class will be removed once support for MySQL 5.7 is dropped.
12+
* @deprecated
1313
*/
1414
class MySQL80Keywords extends MySQLKeywords
1515
{

src/Platforms/Keywords/MySQL84Keywords.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
/**
1111
* MySQL 8.4 reserved keywords list.
12+
*
13+
* @deprecated
1214
*/
1315
class MySQL84Keywords extends MySQL80Keywords
1416
{

src/Platforms/Keywords/MySQLKeywords.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
/**
88
* MySQL Keywordlist.
9+
*
10+
* @deprecated
911
*/
1012
class MySQLKeywords extends KeywordList
1113
{

src/Platforms/Keywords/OracleKeywords.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
/**
88
* Oracle Keywordlist.
9+
*
10+
* @deprecated
911
*/
1012
class OracleKeywords extends KeywordList
1113
{

src/Platforms/Keywords/PostgreSQLKeywords.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
/**
88
* Reserved keywords list corresponding to the PostgreSQL database platform of the oldest supported version.
9+
*
10+
* @deprecated
911
*/
1012
class PostgreSQLKeywords extends KeywordList
1113
{

src/Platforms/Keywords/SQLServerKeywords.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
/**
88
* Reserved keywords list corresponding to the Microsoft SQL Server database platform of the oldest supported version.
9+
*
10+
* @deprecated
911
*/
1012
class SQLServerKeywords extends KeywordList
1113
{

src/Platforms/Keywords/SQLiteKeywords.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
/**
88
* SQLite Keywordlist.
9+
*
10+
* @deprecated
911
*/
1012
class SQLiteKeywords extends KeywordList
1113
{

src/Platforms/MariaDBPlatform.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
1010
use Doctrine\DBAL\Schema\TableDiff;
1111
use Doctrine\DBAL\Types\JsonType;
12+
use Doctrine\Deprecations\Deprecation;
1213

1314
use function array_diff_key;
1415
use function array_merge;
@@ -158,8 +159,16 @@ public function getColumnDeclarationSQL(string $name, array $column): string
158159
return parent::getColumnDeclarationSQL($name, $column);
159160
}
160161

162+
/** @deprecated */
161163
protected function createReservedKeywordsList(): KeywordList
162164
{
165+
Deprecation::triggerIfCalledFromOutside(
166+
'doctrine/dbal',
167+
'https://github.com/doctrine/dbal/pull/6607',
168+
'%s is deprecated.',
169+
__METHOD__,
170+
);
171+
163172
return new MariaDBKeywords();
164173
}
165174
}

src/Platforms/MySQL80Platform.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\DBAL\Platforms\Keywords\KeywordList;
88
use Doctrine\DBAL\Platforms\Keywords\MySQL80Keywords;
99
use Doctrine\DBAL\SQL\Builder\SelectSQLBuilder;
10+
use Doctrine\Deprecations\Deprecation;
1011

1112
/**
1213
* Provides the behavior, features and SQL dialect of the MySQL 8.0 database platform.
@@ -17,6 +18,13 @@ class MySQL80Platform extends MySQLPlatform
1718
{
1819
protected function createReservedKeywordsList(): KeywordList
1920
{
21+
Deprecation::triggerIfCalledFromOutside(
22+
'doctrine/dbal',
23+
'https://github.com/doctrine/dbal/pull/6607',
24+
'%s is deprecated.',
25+
__METHOD__,
26+
);
27+
2028
return new MySQL80Keywords();
2129
}
2230

src/Platforms/MySQL84Platform.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@
66

77
use Doctrine\DBAL\Platforms\Keywords\KeywordList;
88
use Doctrine\DBAL\Platforms\Keywords\MySQL84Keywords;
9+
use Doctrine\Deprecations\Deprecation;
910

1011
/**
1112
* Provides the behavior, features and SQL dialect of the MySQL 8.4 database platform.
13+
*
14+
* @deprecated Please use {@link MySQLPlatform} instead.
1215
*/
1316
class MySQL84Platform extends MySQL80Platform
1417
{
18+
/** @deprecated */
1519
protected function createReservedKeywordsList(): KeywordList
1620
{
21+
Deprecation::triggerIfCalledFromOutside(
22+
'doctrine/dbal',
23+
'https://github.com/doctrine/dbal/pull/6607',
24+
'%s is deprecated.',
25+
__METHOD__,
26+
);
27+
1728
return new MySQL84Keywords();
1829
}
1930
}

src/Platforms/MySQLPlatform.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Doctrine\DBAL\Schema\Index;
1010
use Doctrine\DBAL\Types\BlobType;
1111
use Doctrine\DBAL\Types\TextType;
12+
use Doctrine\Deprecations\Deprecation;
1213

1314
/**
1415
* Provides the behavior, features and SQL dialect of the Oracle MySQL database platform
@@ -42,8 +43,16 @@ protected function getRenameIndexSQL(string $oldIndexName, Index $index, string
4243
return ['ALTER TABLE ' . $tableName . ' RENAME INDEX ' . $oldIndexName . ' TO ' . $index->getQuotedName($this)];
4344
}
4445

46+
/** @deprecated */
4547
protected function createReservedKeywordsList(): KeywordList
4648
{
49+
Deprecation::triggerIfCalledFromOutside(
50+
'doctrine/dbal',
51+
'https://github.com/doctrine/dbal/pull/6607',
52+
'%s is deprecated.',
53+
__METHOD__,
54+
);
55+
4756
return new MySQLKeywords();
4857
}
4958
}

src/Platforms/OraclePlatform.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Doctrine\DBAL\TransactionIsolationLevel;
1818
use Doctrine\DBAL\Types\BinaryType;
1919
use Doctrine\DBAL\Types\Types;
20+
use Doctrine\Deprecations\Deprecation;
2021
use InvalidArgumentException;
2122

2223
use function array_merge;
@@ -785,8 +786,16 @@ public function releaseSavePoint(string $savepoint): string
785786
return '';
786787
}
787788

789+
/** @deprecated */
788790
protected function createReservedKeywordsList(): KeywordList
789791
{
792+
Deprecation::triggerIfCalledFromOutside(
793+
'doctrine/dbal',
794+
'https://github.com/doctrine/dbal/pull/6607',
795+
'%s is deprecated.',
796+
__METHOD__,
797+
);
798+
790799
return new OracleKeywords();
791800
}
792801

0 commit comments

Comments
 (0)