Skip to content

Commit 8ac3a91

Browse files
authored
Prevent duplicate path normalization (#4931)
1 parent f0fc378 commit 8ac3a91

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/File/FileFinder.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Symfony\Component\Finder\Finder;
66
use function array_filter;
7+
use function array_map;
78
use function array_unique;
89
use function array_values;
910
use function file_exists;
@@ -34,24 +35,27 @@ public function findFiles(array $paths): FileFinderResult
3435
$files = [];
3536
foreach ($paths as $path) {
3637
if (is_file($path)) {
37-
$files[] = $this->fileHelper->normalizePath($path);
38+
$files[] = $path;
3839
} elseif (!file_exists($path)) {
3940
throw new PathNotFoundException($path);
4041
} else {
4142
$finder = new Finder();
4243
$finder->followLinks();
4344
foreach ($finder->files()->name('*.{' . implode(',', $this->fileExtensions) . '}')->in($path) as $fileInfo) {
44-
$files[] = $this->fileHelper->normalizePath($fileInfo->getPathname());
45+
$files[] = $fileInfo->getPathname();
4546
$onlyFiles = false;
4647
}
4748
}
4849
}
4950

50-
$files = array_values(array_unique(array_filter($files, fn (string $file): bool => !$this->fileExcluder->isExcludedFromAnalysing($file))));
51+
$files = array_filter($files, fn (string $file): bool => !$this->fileExcluder->isExcludedFromAnalysing($file));
5152

5253
sort($files);
5354

54-
return new FileFinderResult($files, $onlyFiles);
55+
return new FileFinderResult(
56+
array_values(array_unique(array_map(fn (string $file): string => $this->fileHelper->normalizePath($file), $files))),
57+
$onlyFiles,
58+
);
5559
}
5660

5761
}

0 commit comments

Comments
 (0)