Skip to content

Commit d04d0d6

Browse files
authored
Merge pull request #4755 from morozov/deprecate-platform-get-name
Deprecate AbstractPlatform::getName()
2 parents 0453eef + 4b174ad commit d04d0d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3645
-3531
lines changed

UPGRADE.md

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ awareness about deprecated code.
88

99
# Upgrade to 3.2
1010

11+
## Deprecated `AbstractPlatform::getName()`
12+
13+
Relying on the name of the platform is discouraged. To identify the platform, use its class name.
14+
15+
## Deprecated versioned platform classes that represent the lowest supported version:
16+
17+
1. `PostgreSQL94Platform` and `PostgreSQL94Keywords`. Use `PostgreSQLPlatform` and `PostgreSQLKeywords` instead.
18+
2. `SQLServer2012Platform` and `SQLServer2012Keywords`. Use `SQLServerPlatform` and `SQLServerKeywords` instead.
19+
1120
## Deprecated schema comparison APIs that don't account for the current database connection and the database platform
1221

1322
1. Instantiation of the `Comparator` class outside the DBAL is deprecated. Use `SchemaManager::createComparator()`

docs/en/reference/platforms.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ Oracle
5050
Microsoft SQL Server
5151
^^^^^^^^^^^^^^^^^^^^
5252

53-
- ``SQLServer2012Platform`` for version 2012 and above.
53+
- ``SQLServerPlatform`` for version 2012 and above.
5454

5555
PostgreSQL
5656
^^^^^^^^^^
5757

58-
- ``PostgreSQL94Platform`` for version 9.4 and above.
58+
- ``PostgreSQLPlatform`` for version 9.4 and above.
5959
- ``PostgreSQL100Platform`` for version 10.0 and above.
6060

6161
SQLite

phpstan.neon.dist

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ parameters:
8383
-
8484
message: '~^Only numeric types are allowed in -, int<1, max>\|false given on the left side\.~'
8585
paths:
86-
- %currentWorkingDirectory%/src/Platforms/SQLServer2012Platform.php
86+
- %currentWorkingDirectory%/src/Platforms/SQLServerPlatform.php
8787

8888
# Unlike Psalm, PHPStan doesn't understand the shape of the parse_str() return value
8989
-
@@ -95,7 +95,7 @@ parameters:
9595
-
9696
message: '~^Only numeric types are allowed in pre\-decrement, int\<1, max\>\|false given\.$~'
9797
paths:
98-
- %currentWorkingDirectory%/src/Platforms/SQLServer2012Platform.php
98+
- %currentWorkingDirectory%/src/Platforms/SQLServerPlatform.php
9999

100100
# https://github.com/phpstan/phpstan-phpunit/issues/83
101101
-

psalm.xml.dist

+8-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@
6161
-->
6262
<referencedClass name="Doctrine\DBAL\Driver\ServerInfoAwareConnection"/>
6363
<referencedClass name="Doctrine\DBAL\VersionAwarePlatformDriver"/>
64+
<!--
65+
TODO: remove in 4.0.0
66+
-->
67+
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\PostgreSQL94Keywords"/>
68+
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords"/>
69+
<referencedClass name="Doctrine\DBAL\Platforms\PostgreSQL94Platform"/>
70+
<referencedClass name="Doctrine\DBAL\Platforms\SQLServer2012Platform"/>
6471
</errorLevel>
6572
</DeprecatedClass>
6673
<DeprecatedInterface>
@@ -177,7 +184,7 @@
177184
<file name="src/DriverManager.php"/>
178185
<file name="src/Platforms/AbstractPlatform.php"/>
179186
<file name="src/Platforms/MySQLPlatform.php"/>
180-
<file name="src/Platforms/SQLServer2012Platform.php"/>
187+
<file name="src/Platforms/SQLServerPlatform.php"/>
181188
<file name="src/Platforms/SqlitePlatform.php"/>
182189
<file name="src/Schema/Column.php"/>
183190
<!--

src/Platforms/AbstractPlatform.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ abstract public function getBlobTypeDeclarationSQL(array $column);
337337
/**
338338
* Gets the name of the platform.
339339
*
340+
* @deprecated Identify platforms by their class.
341+
*
340342
* @return string
341343
*/
342344
abstract public function getName();
@@ -3690,7 +3692,7 @@ protected function doModifyLimitQuery($query, $limit, $offset)
36903692
*/
36913693
public function supportsLimitOffset()
36923694
{
3693-
Deprecation::trigger(
3695+
Deprecation::triggerIfCalledFromOutside(
36943696
'doctrine/dbal',
36953697
'https://github.com/doctrine/dbal/pulls/4724',
36963698
'AbstractPlatform::supportsViews() is deprecated.'

src/Platforms/DB2Platform.php

+6
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ public function getClobTypeDeclarationSQL(array $column)
135135
*/
136136
public function getName()
137137
{
138+
Deprecation::triggerIfCalledFromOutside(
139+
'doctrine/dbal',
140+
'https://github.com/doctrine/dbal/issues/4749',
141+
'DB2Platform::getName() is deprecated. Identify platforms by their class.'
142+
);
143+
138144
return 'db2';
139145
}
140146

src/Platforms/Keywords/PostgreSQL94Keywords.php

+3-116
Original file line numberDiff line numberDiff line change
@@ -4,122 +4,9 @@
44

55
/**
66
* PostgreSQL 9.4 reserved keywords list.
7+
*
8+
* @deprecated Use {@link PostgreSQLKeywords} instead.
79
*/
8-
class PostgreSQL94Keywords extends KeywordList
10+
class PostgreSQL94Keywords extends PostgreSQLKeywords
911
{
10-
/**
11-
* {@inheritdoc}
12-
*/
13-
public function getName()
14-
{
15-
return 'PostgreSQL';
16-
}
17-
18-
/**
19-
* {@inheritdoc}
20-
*/
21-
protected function getKeywords()
22-
{
23-
return [
24-
'ALL',
25-
'ANALYSE',
26-
'ANALYZE',
27-
'AND',
28-
'ANY',
29-
'ARRAY',
30-
'AS',
31-
'ASC',
32-
'ASYMMETRIC',
33-
'AUTHORIZATION',
34-
'BINARY',
35-
'BOTH',
36-
'CASE',
37-
'CAST',
38-
'CHECK',
39-
'COLLATE',
40-
'COLLATION',
41-
'COLUMN',
42-
'CONCURRENTLY',
43-
'CONSTRAINT',
44-
'CREATE',
45-
'CROSS',
46-
'CURRENT_CATALOG',
47-
'CURRENT_DATE',
48-
'CURRENT_ROLE',
49-
'CURRENT_SCHEMA',
50-
'CURRENT_TIME',
51-
'CURRENT_TIMESTAMP',
52-
'CURRENT_USER',
53-
'DEFAULT',
54-
'DEFERRABLE',
55-
'DESC',
56-
'DISTINCT',
57-
'DO',
58-
'ELSE',
59-
'END',
60-
'EXCEPT',
61-
'FALSE',
62-
'FETCH',
63-
'FOR',
64-
'FOREIGN',
65-
'FREEZE',
66-
'FROM',
67-
'FULL',
68-
'GRANT',
69-
'GROUP',
70-
'HAVING',
71-
'ILIKE',
72-
'IN',
73-
'INITIALLY',
74-
'INNER',
75-
'INTERSECT',
76-
'INTO',
77-
'IS',
78-
'ISNULL',
79-
'JOIN',
80-
'LATERAL',
81-
'LEADING',
82-
'LEFT',
83-
'LIKE',
84-
'LIMIT',
85-
'LOCALTIME',
86-
'LOCALTIMESTAMP',
87-
'NATURAL',
88-
'NOT',
89-
'NOTNULL',
90-
'NULL',
91-
'OFFSET',
92-
'ON',
93-
'ONLY',
94-
'OR',
95-
'ORDER',
96-
'OUTER',
97-
'OVERLAPS',
98-
'PLACING',
99-
'PRIMARY',
100-
'REFERENCES',
101-
'RETURNING',
102-
'RIGHT',
103-
'SELECT',
104-
'SESSION_USER',
105-
'SIMILAR',
106-
'SOME',
107-
'SYMMETRIC',
108-
'TABLE',
109-
'THEN',
110-
'TO',
111-
'TRAILING',
112-
'TRUE',
113-
'UNION',
114-
'UNIQUE',
115-
'USER',
116-
'USING',
117-
'VARIADIC',
118-
'VERBOSE',
119-
'WHEN',
120-
'WHERE',
121-
'WINDOW',
122-
'WITH',
123-
];
124-
}
12512
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?php
2+
3+
namespace Doctrine\DBAL\Platforms\Keywords;
4+
5+
/**
6+
* Reserved keywords list corresponding to the PostgreSQL database platform of the oldest supported version.
7+
*/
8+
class PostgreSQLKeywords extends KeywordList
9+
{
10+
/**
11+
* {@inheritdoc}
12+
*/
13+
public function getName()
14+
{
15+
return 'PostgreSQL';
16+
}
17+
18+
/**
19+
* {@inheritdoc}
20+
*/
21+
protected function getKeywords()
22+
{
23+
return [
24+
'ALL',
25+
'ANALYSE',
26+
'ANALYZE',
27+
'AND',
28+
'ANY',
29+
'ARRAY',
30+
'AS',
31+
'ASC',
32+
'ASYMMETRIC',
33+
'AUTHORIZATION',
34+
'BINARY',
35+
'BOTH',
36+
'CASE',
37+
'CAST',
38+
'CHECK',
39+
'COLLATE',
40+
'COLLATION',
41+
'COLUMN',
42+
'CONCURRENTLY',
43+
'CONSTRAINT',
44+
'CREATE',
45+
'CROSS',
46+
'CURRENT_CATALOG',
47+
'CURRENT_DATE',
48+
'CURRENT_ROLE',
49+
'CURRENT_SCHEMA',
50+
'CURRENT_TIME',
51+
'CURRENT_TIMESTAMP',
52+
'CURRENT_USER',
53+
'DEFAULT',
54+
'DEFERRABLE',
55+
'DESC',
56+
'DISTINCT',
57+
'DO',
58+
'ELSE',
59+
'END',
60+
'EXCEPT',
61+
'FALSE',
62+
'FETCH',
63+
'FOR',
64+
'FOREIGN',
65+
'FREEZE',
66+
'FROM',
67+
'FULL',
68+
'GRANT',
69+
'GROUP',
70+
'HAVING',
71+
'ILIKE',
72+
'IN',
73+
'INITIALLY',
74+
'INNER',
75+
'INTERSECT',
76+
'INTO',
77+
'IS',
78+
'ISNULL',
79+
'JOIN',
80+
'LATERAL',
81+
'LEADING',
82+
'LEFT',
83+
'LIKE',
84+
'LIMIT',
85+
'LOCALTIME',
86+
'LOCALTIMESTAMP',
87+
'NATURAL',
88+
'NOT',
89+
'NOTNULL',
90+
'NULL',
91+
'OFFSET',
92+
'ON',
93+
'ONLY',
94+
'OR',
95+
'ORDER',
96+
'OUTER',
97+
'OVERLAPS',
98+
'PLACING',
99+
'PRIMARY',
100+
'REFERENCES',
101+
'RETURNING',
102+
'RIGHT',
103+
'SELECT',
104+
'SESSION_USER',
105+
'SIMILAR',
106+
'SOME',
107+
'SYMMETRIC',
108+
'TABLE',
109+
'THEN',
110+
'TO',
111+
'TRAILING',
112+
'TRUE',
113+
'UNION',
114+
'UNIQUE',
115+
'USER',
116+
'USING',
117+
'VARIADIC',
118+
'VERBOSE',
119+
'WHEN',
120+
'WHERE',
121+
'WINDOW',
122+
'WITH',
123+
];
124+
}
125+
}

0 commit comments

Comments
 (0)