|
20 | 20 | use PHPStan\DependencyInjection\InvalidIgnoredErrorPatternsException; |
21 | 21 | use PHPStan\DependencyInjection\LoaderFactory; |
22 | 22 | use PHPStan\ExtensionInstaller\GeneratedConfig; |
| 23 | +use PHPStan\File\FileExcluder; |
23 | 24 | use PHPStan\File\FileFinder; |
24 | 25 | use PHPStan\File\FileHelper; |
| 26 | +use PHPStan\PhpDoc\StubFilesProvider; |
25 | 27 | use PHPStan\ShouldNotHappenException; |
26 | 28 | use ReflectionClass; |
27 | 29 | use Symfony\Component\Console\Input\InputInterface; |
28 | 30 | use Symfony\Component\Console\Output\ConsoleOutputInterface; |
29 | 31 | use Symfony\Component\Console\Output\OutputInterface; |
30 | 32 | use Throwable; |
| 33 | +use function array_filter; |
31 | 34 | use function array_key_exists; |
32 | 35 | use function array_map; |
| 36 | +use function array_values; |
33 | 37 | use function class_exists; |
34 | 38 | use function count; |
35 | 39 | use function dirname; |
@@ -467,13 +471,20 @@ public static function begin( |
467 | 471 |
|
468 | 472 | $pathRoutingParser = $container->getService('pathRoutingParser'); |
469 | 473 |
|
| 474 | + /** @var StubFilesProvider $stubFilesProvider */ |
| 475 | + $stubFilesProvider = $container->getByType(StubFilesProvider::class); |
| 476 | + |
470 | 477 | /** @var Closure(): array{string[], bool} $filesCallback */ |
471 | | - $filesCallback = static function () use ($fileFinder, $pathRoutingParser, $paths): array { |
| 478 | + $filesCallback = static function () use ($currentWorkingDirectoryFileHelper, $stubFilesProvider, $fileFinder, $pathRoutingParser, $paths): array { |
472 | 479 | $fileFinderResult = $fileFinder->findFiles($paths); |
473 | 480 | $files = $fileFinderResult->getFiles(); |
474 | 481 |
|
475 | 482 | $pathRoutingParser->setAnalysedFiles($files); |
476 | 483 |
|
| 484 | + $stubFilesExcluder = new FileExcluder($currentWorkingDirectoryFileHelper, $stubFilesProvider->getProjectStubFiles()); |
| 485 | + |
| 486 | + $files = array_values(array_filter($files, static fn (string $file) => !$stubFilesExcluder->isExcludedFromAnalysing($file))); |
| 487 | + |
477 | 488 | return [$files, $fileFinderResult->isOnlyFiles()]; |
478 | 489 | }; |
479 | 490 |
|
|
0 commit comments