Use str_starts_with, str_ends_with and str_contains instead of strpos (#5485)

This commit is contained in:
Alexey
2022-12-31 16:02:23 +03:00
committed by GitHub
parent 0d31b25fba
commit 172ce659b8
14 changed files with 35 additions and 35 deletions

View File

@@ -48,9 +48,9 @@ use function rmdir;
use function rtrim;
use function scandir;
use function str_replace;
use function str_starts_with;
use function stream_get_contents;
use function strlen;
use function strpos;
use function uksort;
use function unlink;
use const DIRECTORY_SEPARATOR;
@@ -172,7 +172,7 @@ final class Filesystem{
//this should probably never have integer keys, but it's safer than making PHPStan ignore it
foreach(Utils::stringifyKeys(self::$cleanedPaths) as $cleanPath => $replacement){
$cleanPath = rtrim(str_replace([DIRECTORY_SEPARATOR, "phar://"], ["/", ""], $cleanPath), "/");
if(strpos($result, $cleanPath) === 0){
if(str_starts_with($result, $cleanPath)){
$result = ltrim(str_replace($cleanPath, $replacement, $result), "/");
}
}