Skip to content

Commit 2aebb6f

Browse files
committed
Remove quoteIdentifierInFragment from Platform, no remaining callers
Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
1 parent 88e384d commit 2aebb6f

File tree

3 files changed

+0
-83
lines changed

3 files changed

+0
-83
lines changed

src/Adapter/Platform/AbstractPlatform.php

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
use function addcslashes;
1313
use function array_map;
14-
use function ctype_alpha;
1514
use function implode;
16-
use function preg_replace;
1715
use function str_replace;
1816

1917
/**
@@ -28,55 +26,9 @@ abstract class AbstractPlatform implements PlatformInterface
2826

2927
protected bool $quoteIdentifiers = true;
3028

31-
/** SQL keywords that must not be quoted in identifier fragments */
32-
protected const KEYWORDS_PATTERN = 'AS|AND|OR|BETWEEN';
33-
3429
/** @var array<string, string> */
3530
private array $identifierCache = [];
3631

37-
/**
38-
* {@inheritDoc}
39-
*
40-
* @param string[] $additionalSafeWords
41-
*/
42-
#[Override]
43-
public function quoteIdentifierInFragment(string $identifier, array $additionalSafeWords = []): string
44-
{
45-
if (! $this->quoteIdentifiers) {
46-
return $identifier;
47-
}
48-
49-
$cacheKey = $identifier;
50-
$pattern = self::KEYWORDS_PATTERN;
51-
52-
if ($additionalSafeWords !== []) {
53-
$extra = [];
54-
foreach ($additionalSafeWords as $word) {
55-
if (ctype_alpha($word)) {
56-
$extra[] = $word;
57-
}
58-
}
59-
if ($extra !== []) {
60-
$extraPattern = implode('|', $extra);
61-
$pattern .= '|' . $extraPattern;
62-
$cacheKey .= "\0" . $extraPattern;
63-
}
64-
}
65-
66-
if (isset($this->identifierCache[$cacheKey])) {
67-
return $this->identifierCache[$cacheKey];
68-
}
69-
70-
/** @var string $result */
71-
$result = preg_replace(
72-
'/\b(?!(?:' . $pattern . ')\b)([a-zA-Z_]\w*+)(?!\s*\()/i',
73-
$this->quoteIdentifier[0] . '$1' . $this->quoteIdentifier[1],
74-
$identifier
75-
);
76-
77-
return $this->identifierCache[$cacheKey] = $result;
78-
}
79-
8032
/**
8133
* {@inheritDoc}
8234
*/

src/Adapter/Platform/PlatformInterface.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,4 @@ public function quoteValueList(array|string $valueList): string;
6868
* Get identifier separator
6969
*/
7070
public function getIdentifierSeparator(): string;
71-
72-
/**
73-
* Quote identifier in fragment
74-
*/
75-
public function quoteIdentifierInFragment(string $identifier, array $additionalSafeWords = []): string;
7671
}

test/unit/Adapter/Platform/Sql92Test.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#[CoversMethod(Sql92::class, 'quoteTrustedValue')]
2020
#[CoversMethod(Sql92::class, 'quoteValueList')]
2121
#[CoversMethod(Sql92::class, 'getIdentifierSeparator')]
22-
#[CoversMethod(Sql92::class, 'quoteIdentifierInFragment')]
2322
final class Sql92Test extends TestCase
2423
{
2524
protected Sql92 $platform;
@@ -109,33 +108,4 @@ public function testGetIdentifierSeparator(): void
109108
self::assertEquals('.', $this->platform->getIdentifierSeparator());
110109
}
111110

112-
public function testQuoteIdentifierInFragment(): void
113-
{
114-
self::assertEquals('"foo"."bar"', $this->platform->quoteIdentifierInFragment('foo.bar'));
115-
self::assertEquals('"foo" as "bar"', $this->platform->quoteIdentifierInFragment('foo as bar'));
116-
117-
// single char words
118-
self::assertEquals(
119-
'("foo"."bar" = "boo"."baz")',
120-
$this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', ['(', ')', '='])
121-
);
122-
123-
// case insensitive safe words
124-
self::assertEquals(
125-
'("foo"."bar" = "boo"."baz") AND ("foo"."baz" = "boo"."baz")',
126-
$this->platform->quoteIdentifierInFragment(
127-
'(foo.bar = boo.baz) AND (foo.baz = boo.baz)',
128-
['(', ')', '=', 'and']
129-
)
130-
);
131-
132-
// case insensitive safe words in field
133-
self::assertEquals(
134-
'("foo"."bar" = "boo".baz) AND ("foo".baz = "boo".baz)',
135-
$this->platform->quoteIdentifierInFragment(
136-
'(foo.bar = boo.baz) AND (foo.baz = boo.baz)',
137-
['(', ')', '=', 'and', 'bAz']
138-
)
139-
);
140-
}
141111
}

0 commit comments

Comments
 (0)