Skip to content

Commit 493310f

Browse files
committed
Use strings to represent wildcard characters
A string is made of characters, an array might contain anything.
1 parent a9e5e5a commit 493310f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lib/Doctrine/DBAL/Platforms/AbstractPlatform.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
use Doctrine\DBAL\Types;
4444
use Doctrine\DBAL\Types\Type;
4545
use function addcslashes;
46-
use function implode;
4746
use function preg_quote;
4847
use function preg_replace;
4948
use function sprintf;
@@ -3596,7 +3595,7 @@ public function getStringLiteralQuoteCharacter()
35963595
final public function escapeStringForLike(string $inputString, string $escapeChar) : string
35973596
{
35983597
return preg_replace(
3599-
'~([' . preg_quote(implode('', $this->getLikeWildcardCharacters()) . $escapeChar, '~') . '])~u',
3598+
'~([' . preg_quote($this->getLikeWildcardCharacters() . $escapeChar, '~') . '])~u',
36003599
addcslashes($escapeChar, '\\') . '$1',
36013600
$inputString
36023601
);
@@ -3607,6 +3606,6 @@ final public function escapeStringForLike(string $inputString, string $escapeCha
36073606
*/
36083607
protected function getLikeWildcardCharacters() : array
36093608
{
3610-
return ['%', '_'];
3609+
return '%_';
36113610
}
36123611
}

lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ protected function getReservedKeywordsClass()
122122
*/
123123
protected function getLikeWildcardCharacters() : array
124124
{
125-
return array_merge(parent::getLikeWildcardCharacters(), ['[', ']', '^']);
125+
return parent::getLikeWildcardCharacters() . '[]^';
126126
}
127127
}

0 commit comments

Comments
 (0)