Added an assertion for the preg_replace() result

parent 51a95ca6
...@@ -3141,11 +3141,15 @@ abstract class AbstractPlatform ...@@ -3141,11 +3141,15 @@ abstract class AbstractPlatform
*/ */
final public function escapeStringForLike(string $inputString, string $escapeChar) : string final public function escapeStringForLike(string $inputString, string $escapeChar) : string
{ {
return preg_replace( $sql = preg_replace(
'~([' . preg_quote($this->getLikeWildcardCharacters() . $escapeChar, '~') . '])~u', '~([' . preg_quote($this->getLikeWildcardCharacters() . $escapeChar, '~') . '])~u',
addcslashes($escapeChar, '\\') . '$1', addcslashes($escapeChar, '\\') . '$1',
$inputString $inputString
); );
assert(is_string($sql));
return $sql;
} }
protected function getLikeWildcardCharacters() : string protected function getLikeWildcardCharacters() : string
......
...@@ -19,9 +19,6 @@ parameters: ...@@ -19,9 +19,6 @@ parameters:
# https://github.com/phpstan/phpstan/issues/1847 # https://github.com/phpstan/phpstan/issues/1847
- '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int|string> given\.\z~' - '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int|string> given\.\z~'
# PHPStan is too strict about preg_replace(): https://phpstan.org/r/993dc99f-0d43-4b51-868b-d01f982c1463
- '~^Method Doctrine\\DBAL\\Platforms\\AbstractPlatform::escapeStringForLike\(\) should return string but returns string\|null\.\z~'
# legacy remnants from doctrine/common # legacy remnants from doctrine/common
- '~^Class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy) not found\.\z~' - '~^Class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy) not found\.\z~'
- '~^.+ on an unknown class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy)\.\z~' - '~^.+ on an unknown class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy)\.\z~'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment