diff --git a/src/FileSystem/SourceFileCollector.php b/src/FileSystem/SourceFileCollector.php index 8b35337213..970af5f9b7 100644 --- a/src/FileSystem/SourceFileCollector.php +++ b/src/FileSystem/SourceFileCollector.php @@ -59,17 +59,12 @@ public function collectFiles( return []; } - $finder = Finder::create() - ->exclude($excludeDirectories) + return Finder::create() ->in($sourceDirectories) + ->exclude($excludeDirectories) + ->notPath($excludeDirectories) ->files() ->name('*.php') ; - - foreach ($excludeDirectories as $excludeDirectory) { - $finder->notPath($excludeDirectory); - } - - return $finder; } } diff --git a/tests/phpunit/FileSystem/SourceFileCollectorTest.php b/tests/phpunit/FileSystem/SourceFileCollectorTest.php index 5ccd1d4210..920470ffa3 100644 --- a/tests/phpunit/FileSystem/SourceFileCollectorTest.php +++ b/tests/phpunit/FileSystem/SourceFileCollectorTest.php @@ -151,6 +151,17 @@ public function sourceFilesProvider(): iterable 'case1/sub-dir/b.php', ], ]; + + yield 'one directory, no filter, one common excludes and one file exclude' => [ + [self::FIXTURES . '/case0'], + [ + 'sub-dir', + 'a.php', + ], + [ + 'case0/outside-symlink.php', + ], + ]; } /**