diff --git a/src/File/FileExcluder.php b/src/File/FileExcluder.php index e9df089e50..9e6266fc29 100644 --- a/src/File/FileExcluder.php +++ b/src/File/FileExcluder.php @@ -29,7 +29,7 @@ final class FileExcluder /** * Files to exclude from analysing * - * @var string[] + * @var array */ private array $literalAnalyseFilesExcludes = []; @@ -63,7 +63,7 @@ public function __construct( $this->fnmatchAnalyseExcludes[] = $normalized; } else { if (is_file($normalized)) { - $this->literalAnalyseFilesExcludes[] = $normalized; + $this->literalAnalyseFilesExcludes[$normalized] = true; } elseif (is_dir($normalized)) { if (!$trailingDirSeparator) { $normalized .= DIRECTORY_SEPARATOR; @@ -86,16 +86,14 @@ public function isExcludedFromAnalysing(string $file): bool { $file = $this->fileHelper->normalizePath($file); + if (isset($this->literalAnalyseFilesExcludes[$file])) { + return true; + } foreach ($this->literalAnalyseDirectoryExcludes as $exclude) { if (str_starts_with($file, $exclude)) { return true; } } - foreach ($this->literalAnalyseFilesExcludes as $exclude) { - if ($file === $exclude) { - return true; - } - } foreach ($this->fnmatchAnalyseExcludes as $exclude) { if (fnmatch($exclude, $file, $this->fnmatchFlags)) { return true;