Skip to content

Commit fddd873

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

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/Doctrine/DBAL/Platforms/AbstractPlatform.php

Lines changed: 3 additions & 4 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
);
@@ -3605,8 +3604,8 @@ final public function escapeStringForLike(string $inputString, string $escapeCha
36053604
/**
36063605
* @return string[]
36073606
*/
3608-
protected function getLikeWildcardCharacters() : array
3607+
protected function getLikeWildcardCharacters() : string
36093608
{
3610-
return ['%', '_'];
3609+
return '%_';
36113610
}
36123611
}

lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ protected function getReservedKeywordsClass()
120120
/**
121121
* {@inheritDoc}
122122
*/
123-
protected function getLikeWildcardCharacters() : array
123+
protected function getLikeWildcardCharacters() : string
124124
{
125-
return array_merge(parent::getLikeWildcardCharacters(), ['[', ']', '^']);
125+
return parent::getLikeWildcardCharacters() . '[]^';
126126
}
127127
}

0 commit comments

Comments
 (0)