From 3761b2157cfea56436458a97510655c493b8aefe Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Wed, 27 Sep 2023 15:36:01 +0100 Subject: [PATCH 1/2] Unwrap one-liner --- .../FileLocator/LocateAllFilesByExtension.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ComposerRequireChecker/FileLocator/LocateAllFilesByExtension.php b/src/ComposerRequireChecker/FileLocator/LocateAllFilesByExtension.php index 1c1da9bd..09cf3aa4 100644 --- a/src/ComposerRequireChecker/FileLocator/LocateAllFilesByExtension.php +++ b/src/ComposerRequireChecker/FileLocator/LocateAllFilesByExtension.php @@ -79,14 +79,10 @@ private function prepareBlacklistPatterns(array|null $blacklistPaths): array $dirSep = preg_quote(DIRECTORY_SEPARATOR, '{}'); foreach ($blacklistPaths as &$path) { - $path = preg_replace( - '{' . $dirSep . '+}', - DIRECTORY_SEPARATOR, - preg_quote( - trim(str_replace('/', DIRECTORY_SEPARATOR, $path), DIRECTORY_SEPARATOR), - '{}', - ), - ); + $path = str_replace('/', DIRECTORY_SEPARATOR, $path); + $path = trim($path, DIRECTORY_SEPARATOR); + $path = preg_quote($path, '{}'); + $path = preg_replace('{' . $dirSep . '+}', DIRECTORY_SEPARATOR, $path); $path = str_replace('\\*\\*', '.+?', $path); $path = str_replace('\\*', '[^' . $dirSep . ']+?', $path); } From e2c7d31107f27735a2db308fe65cb73c6b5215ca Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Wed, 27 Sep 2023 15:36:25 +0100 Subject: [PATCH 2/2] Remove DIRECTORY_SEPARATOR replacement --- .../FileLocator/LocateAllFilesByExtension.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ComposerRequireChecker/FileLocator/LocateAllFilesByExtension.php b/src/ComposerRequireChecker/FileLocator/LocateAllFilesByExtension.php index 09cf3aa4..2757a132 100644 --- a/src/ComposerRequireChecker/FileLocator/LocateAllFilesByExtension.php +++ b/src/ComposerRequireChecker/FileLocator/LocateAllFilesByExtension.php @@ -12,7 +12,6 @@ use function implode; use function preg_match; use function preg_quote; -use function preg_replace; use function str_replace; use function trim; @@ -82,7 +81,6 @@ private function prepareBlacklistPatterns(array|null $blacklistPaths): array $path = str_replace('/', DIRECTORY_SEPARATOR, $path); $path = trim($path, DIRECTORY_SEPARATOR); $path = preg_quote($path, '{}'); - $path = preg_replace('{' . $dirSep . '+}', DIRECTORY_SEPARATOR, $path); $path = str_replace('\\*\\*', '.+?', $path); $path = str_replace('\\*', '[^' . $dirSep . ']+?', $path); }