Skip to content

Commit 9a39c1f

Browse files
authored
Merge pull request #1477 from staabm/simple
Simplify `FileIteratorSourceLocator`, prevent stat calls on paths that aren't PHP files
2 parents 0101c76 + a537c0f commit 9a39c1f

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/SourceLocator/Type/FileIteratorSourceLocator.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
use function array_map;
1919
use function array_values;
2020
use function iterator_to_array;
21-
use function pathinfo;
22-
23-
use const PATHINFO_EXTENSION;
2421

2522
/**
2623
* This source locator loads all php files from \FileSystemIterator
@@ -56,13 +53,11 @@ private function getAggregatedSourceLocator(): AggregateSourceLocator
5653
return $this->aggregateSourceLocator
5754
?? $this->aggregateSourceLocator = new AggregateSourceLocator(array_values(array_filter(array_map(
5855
function (SplFileInfo $item): SingleFileSourceLocator|null {
59-
$realPath = $item->getRealPath();
60-
61-
if (! ($item->isFile() && pathinfo($realPath, PATHINFO_EXTENSION) === 'php')) {
56+
if (! ($item->isFile() && $item->getExtension() === 'php')) {
6257
return null;
6358
}
6459

65-
return new SingleFileSourceLocator($realPath, $this->astLocator);
60+
return new SingleFileSourceLocator($item->getRealPath(), $this->astLocator);
6661
},
6762
iterator_to_array($this->fileSystemIterator),
6863
))));

0 commit comments

Comments
 (0)