Skip to content

Commit a56e4c1

Browse files
authored
Merge pull request #6594 from morozov/remove-quote-identifier
Remove AbstractPlatform::quoteIdentifier()
2 parents 2a8db3b + a6bf54a commit a56e4c1

9 files changed

+11
-96
lines changed

UPGRADE.md

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

99
# Upgrade to 5.0
1010

11+
## BC BREAK: Removed `AbstractPlatform::quoteIdentifier()` and `Connection::quoteIdentifier()`
12+
13+
The `AbstractPlatform::quoteIdentifier()` and `Connection::quoteIdentifier()` methods have been removed.
14+
1115
## BC BREAK: Removed `Table::removeForeignKey()` and `::removeUniqueConstraint()`
1216

1317
The `Table::removeForeignKey()` and `::removeUniqueConstraint()` have been removed.

psalm.xml.dist

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@
5555

5656
<!-- TODO for PHPUnit 11 -->
5757
<referencedMethod name="PHPUnit\Framework\TestCase::iniSet"/>
58-
59-
<!--
60-
https://github.com/doctrine/dbal/pull/6590
61-
TODO: remove in 5.0.0
62-
-->
63-
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::quoteIdentifier" />
6458
</errorLevel>
6559
</DeprecatedMethod>
6660
<DocblockTypeContradiction>

src/Connection.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -534,34 +534,6 @@ private function extractTypeValues(array $columns, array $types): array
534534
return $typeValues;
535535
}
536536

537-
/**
538-
* Quotes a string so it can be safely used as a table or column name, even if
539-
* it is a reserved name.
540-
*
541-
* Delimiting style depends on the underlying database platform that is being used.
542-
*
543-
* NOTE: Just because you CAN use quoted identifiers does not mean
544-
* you SHOULD use them. In general, they end up causing way more
545-
* problems than they solve.
546-
*
547-
* @deprecated Use {@link quoteSingleIdentifier()} individually for each part of a qualified name instead.
548-
*
549-
* @param string $identifier The identifier to be quoted.
550-
*
551-
* @return string The quoted identifier.
552-
*/
553-
public function quoteIdentifier(string $identifier): string
554-
{
555-
Deprecation::trigger(
556-
'doctrine/dbal',
557-
'https://github.com/doctrine/dbal/pull/6590',
558-
'Use quoteSingleIdentifier() individually for each part of a qualified name instead.',
559-
__METHOD__,
560-
);
561-
562-
return $this->getDatabasePlatform()->quoteIdentifier($identifier);
563-
}
564-
565537
/**
566538
* Quotes a string so that it can be safely used as an identifier in SQL.
567539
*

src/Platforms/AbstractMySQLPlatform.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ protected function doModifyLimitQuery(string $query, ?int $limit, int $offset):
5959
return $query;
6060
}
6161

62-
public function quoteSingleIdentifier(string $str): string
62+
public function quoteSingleIdentifier(string $identifier): string
6363
{
64-
return '`' . str_replace('`', '``', $str) . '`';
64+
return '`' . str_replace('`', '``', $identifier) . '`';
6565
}
6666

6767
public function getRegexpExpression(): string

src/Platforms/AbstractPlatform.php

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
use Doctrine\DBAL\Types;
3737
use Doctrine\DBAL\Types\Exception\TypeNotFound;
3838
use Doctrine\DBAL\Types\Type;
39-
use Doctrine\Deprecations\Deprecation;
4039

4140
use function addcslashes;
4241
use function array_map;
@@ -45,7 +44,6 @@
4544
use function array_values;
4645
use function assert;
4746
use function count;
48-
use function explode;
4947
use function implode;
5048
use function in_array;
5149
use function is_array;
@@ -58,7 +56,6 @@
5856
use function preg_quote;
5957
use function preg_replace;
6058
use function sprintf;
61-
use function str_contains;
6259
use function str_replace;
6360
use function strlen;
6461
use function strtolower;
@@ -1177,48 +1174,11 @@ public function getDropSchemaSQL(string $schemaName): string
11771174
}
11781175

11791176
/**
1180-
* Quotes a string so that it can be safely used as a table or column name,
1181-
* even if it is a reserved word of the platform. This also detects identifier
1182-
* chains separated by dot and quotes them independently.
1183-
*
1184-
* NOTE: Just because you CAN use quoted identifiers doesn't mean
1185-
* you SHOULD use them. In general, they end up causing way more
1186-
* problems than they solve.
1187-
*
1188-
* @deprecated Use {@link quoteSingleIdentifier()} individually for each part of a qualified name instead.
1189-
*
1190-
* @param string $identifier The identifier name to be quoted.
1191-
*
1192-
* @return string The quoted identifier string.
1193-
*/
1194-
public function quoteIdentifier(string $identifier): string
1195-
{
1196-
Deprecation::trigger(
1197-
'doctrine/dbal',
1198-
'https://github.com/doctrine/dbal/pull/6590',
1199-
'Use quoteSingleIdentifier() individually for each part of a qualified name instead.',
1200-
__METHOD__,
1201-
);
1202-
1203-
if (str_contains($identifier, '.')) {
1204-
$parts = array_map($this->quoteSingleIdentifier(...), explode('.', $identifier));
1205-
1206-
return implode('.', $parts);
1207-
}
1208-
1209-
return $this->quoteSingleIdentifier($identifier);
1210-
}
1211-
1212-
/**
1213-
* Quotes a single identifier (no dot chain separation).
1214-
*
1215-
* @param string $str The identifier name to be quoted.
1216-
*
1217-
* @return string The quoted identifier string.
1177+
* Quotes a string so that it can be safely used as an identifier in SQL.
12181178
*/
1219-
public function quoteSingleIdentifier(string $str): string
1179+
public function quoteSingleIdentifier(string $identifier): string
12201180
{
1221-
return '"' . str_replace('"', '""', $str) . '"';
1181+
return '"' . str_replace('"', '""', $identifier) . '"';
12221182
}
12231183

12241184
/**

src/Platforms/SQLServerPlatform.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,9 +1132,9 @@ protected function createReservedKeywordsList(): KeywordList
11321132
return new SQLServerKeywords();
11331133
}
11341134

1135-
public function quoteSingleIdentifier(string $str): string
1135+
public function quoteSingleIdentifier(string $identifier): string
11361136
{
1137-
return '[' . str_replace(']', ']]', $str) . ']';
1137+
return '[' . str_replace(']', ']]', $identifier) . ']';
11381138
}
11391139

11401140
public function getTruncateTableSQL(string $tableName, bool $cascade = false): string

tests/Platforms/AbstractMySQLPlatformTestCase.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,6 @@ public function testGetCreateTableSQLWithColumnCollation(): void
681681
);
682682
}
683683

684-
public function testQuoteIdentifier(): void
685-
{
686-
self::assertEquals('`test`.`test`', $this->platform->quoteIdentifier('test.test'));
687-
}
688-
689684
protected function createComparator(): Comparator
690685
{
691686
return new MySQL\Comparator(

tests/Platforms/AbstractPlatformTestCase.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ protected function createComparator(): Comparator
4444
return new Comparator($this->platform, new ComparatorConfig());
4545
}
4646

47-
public function testQuoteIdentifier(): void
48-
{
49-
self::assertEquals('"test"."test"', $this->platform->quoteIdentifier('test.test'));
50-
}
51-
5247
#[DataProvider('getReturnsForeignKeyReferentialActionSQL')]
5348
public function testReturnsForeignKeyReferentialActionSQL(string $action, string $expectedSQL): void
5449
{

tests/Platforms/SQLServerPlatformTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,6 @@ public function testModifyLimitSubquerySimple(): void
553553
);
554554
}
555555

556-
public function testQuoteIdentifier(): void
557-
{
558-
self::assertEquals('[test].[test]', $this->platform->quoteIdentifier('test.test'));
559-
}
560-
561556
public function testCreateClusteredIndex(): void
562557
{
563558
$idx = new Index('idx', ['id']);

0 commit comments

Comments
 (0)