diff --git a/src/File/FileExcluder.php b/src/File/FileExcluder.php index 9e6266fc291..22dbe7c0579 100644 --- a/src/File/FileExcluder.php +++ b/src/File/FileExcluder.php @@ -7,9 +7,9 @@ use function in_array; use function is_dir; use function is_file; -use function preg_match; use function str_starts_with; use function strlen; +use function strpbrk; use function substr; use const DIRECTORY_SEPARATOR; use const FNM_CASEFOLD; @@ -118,7 +118,7 @@ public static function isAbsolutePath(string $path): bool public static function isFnmatchPattern(string $path): bool { - return preg_match('~[*?[\]]~', $path) > 0; + return strpbrk($path, '*?[]') !== false; } } diff --git a/src/Type/Php/LtrimFunctionReturnTypeExtension.php b/src/Type/Php/LtrimFunctionReturnTypeExtension.php index 9cf4b23cf64..1fcf768cd0e 100644 --- a/src/Type/Php/LtrimFunctionReturnTypeExtension.php +++ b/src/Type/Php/LtrimFunctionReturnTypeExtension.php @@ -18,7 +18,7 @@ use PHPStan\Type\TypeCombinator; use function count; use function ltrim; -use function preg_match; +use function strpbrk; #[AutowiredService] final class LtrimFunctionReturnTypeExtension implements DynamicFunctionReturnTypeExtension @@ -72,7 +72,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection, } } elseif ($trimConstantString->getValue() === '\\' && $string->isClassString()->yes()) { $result[] = new ClassStringType(); - } elseif (preg_match('/\d/', $trimConstantString->getValue()) === 0 && $string->isNumericString()->yes()) { + } elseif (strpbrk($trimConstantString->getValue(), '0123456789') === false && $string->isNumericString()->yes()) { $result[] = new IntersectionType([new StringType(), new AccessoryNumericStringType()]); } else { return $defaultType; diff --git a/src/Type/Php/TrimFunctionDynamicReturnTypeExtension.php b/src/Type/Php/TrimFunctionDynamicReturnTypeExtension.php index 4a88a6616f0..6627b418f0a 100644 --- a/src/Type/Php/TrimFunctionDynamicReturnTypeExtension.php +++ b/src/Type/Php/TrimFunctionDynamicReturnTypeExtension.php @@ -17,8 +17,8 @@ use PHPStan\Type\TypeCombinator; use function count; use function in_array; -use function preg_match; use function rtrim; +use function strpbrk; use function trim; #[AutowiredService] @@ -77,7 +77,7 @@ public function getTypeFromFunctionCall( true, ); } - } elseif (preg_match('/\d/', $trimConstantString->getValue()) === 0 && $stringType->isNumericString()->yes()) { + } elseif (strpbrk($trimConstantString->getValue(), '0123456789') === false && $stringType->isNumericString()->yes()) { $result[] = new IntersectionType([new StringType(), new AccessoryNumericStringType()]); } else { return $defaultType;