Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/File/FileFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Symfony\Component\Finder\Finder;
use function array_filter;
use function array_map;
use function array_unique;
use function array_values;
use function file_exists;
Expand Down Expand Up @@ -34,24 +35,27 @@ public function findFiles(array $paths): FileFinderResult
$files = [];
foreach ($paths as $path) {
if (is_file($path)) {
$files[] = $this->fileHelper->normalizePath($path);
$files[] = $path;
} elseif (!file_exists($path)) {
throw new PathNotFoundException($path);
} else {
$finder = new Finder();
$finder->followLinks();
foreach ($finder->files()->name('*.{' . implode(',', $this->fileExtensions) . '}')->in($path) as $fileInfo) {
$files[] = $this->fileHelper->normalizePath($fileInfo->getPathname());
$files[] = $fileInfo->getPathname();
$onlyFiles = false;
}
}
}

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

Copy link
Contributor Author

@staabm staabm Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isExcludedFromAnalysing is already normalizing (so doesn't require a normalized $files arg), therefore lets normalize only after filtering to reduce the duplicate work

sort($files);

return new FileFinderResult($files, $onlyFiles);
return new FileFinderResult(
array_values(array_unique(array_map(fn (string $file): string => $this->fileHelper->normalizePath($file), $files))),
$onlyFiles,
);
}

}
Loading