From 7b114ef2386464cea4c4e14edb382970da1e678d Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 7 Jul 2025 01:34:57 +0900 Subject: [PATCH 1/2] Use str_starts_with() instead of strpos() --- src/Testing/TypeInferenceTestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Testing/TypeInferenceTestCase.php b/src/Testing/TypeInferenceTestCase.php index 1793d7b1ec..4ff7d99a1a 100644 --- a/src/Testing/TypeInferenceTestCase.php +++ b/src/Testing/TypeInferenceTestCase.php @@ -41,8 +41,8 @@ use function is_string; use function preg_match; use function sprintf; +use function str_starts_with; use function stripos; -use function strpos; use function strtolower; use function version_compare; use const PHP_VERSION; @@ -424,7 +424,7 @@ private static function isFileLintSkipped(string $file): bool } // ignore shebang line - if (strpos($firstLine, '#!') === 0) { + if (str_starts_with($firstLine, '#!')) { $firstLine = fgets($f); if ($firstLine === false) { return false; From f68017560cd3303fe8ec1c0ab32cac62622d8b3f Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 7 Jul 2025 01:38:05 +0900 Subject: [PATCH 2/2] Avoid duplicating the same strpos() function call --- src/Rules/ClassForbiddenNameCheck.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Rules/ClassForbiddenNameCheck.php b/src/Rules/ClassForbiddenNameCheck.php index 217c42443b..70249cc666 100644 --- a/src/Rules/ClassForbiddenNameCheck.php +++ b/src/Rules/ClassForbiddenNameCheck.php @@ -59,11 +59,12 @@ public function checkClassNames(array $pairs): array $projectName = $project; $withoutPrefixClassName = substr($className, strlen($prefix)); - if (strpos($withoutPrefixClassName, '\\') === false) { + $pos = strpos($withoutPrefixClassName, '\\'); + if ($pos === false) { continue; } - $withoutPrefixClassName = substr($withoutPrefixClassName, strpos($withoutPrefixClassName, '\\')); + $withoutPrefixClassName = substr($withoutPrefixClassName, $pos); } if ($projectName === null) {