diff --git a/conf/config.neon b/conf/config.neon index 0c87d17764..2c89a955d3 100644 --- a/conf/config.neon +++ b/conf/config.neon @@ -325,6 +325,7 @@ services: class: PHPStan\File\FileExcluder arguments: analyseExcludes: %excludes_analyse% + stubFiles: %stubFiles% - class: PHPStan\File\FileFinder diff --git a/src/Analyser/IgnoredError.php b/src/Analyser/IgnoredError.php index bc434c5063..f6aad8cb66 100644 --- a/src/Analyser/IgnoredError.php +++ b/src/Analyser/IgnoredError.php @@ -54,7 +54,7 @@ public static function shouldIgnore( $ignoredErrorPattern = str_replace([preg_quote('\r\n'), preg_quote('\r')], preg_quote('\n'), $ignoredErrorPattern); if ($path !== null) { - $fileExcluder = new FileExcluder($fileHelper, [$path]); + $fileExcluder = new FileExcluder($fileHelper, [$path], []); if (\Nette\Utils\Strings::match($errorMessage, $ignoredErrorPattern) === null) { return false; diff --git a/src/File/FileExcluder.php b/src/File/FileExcluder.php index 507e22e843..d13d894ed4 100644 --- a/src/File/FileExcluder.php +++ b/src/File/FileExcluder.php @@ -15,10 +15,12 @@ class FileExcluder /** * @param FileHelper $fileHelper * @param string[] $analyseExcludes + * @param string[] $stubFiles */ public function __construct( FileHelper $fileHelper, - array $analyseExcludes + array $analyseExcludes, + array $stubFiles ) { $this->analyseExcludes = array_map(function (string $exclude) use ($fileHelper): string { @@ -36,7 +38,7 @@ public function __construct( } return $fileHelper->absolutizePath($normalized); - }, $analyseExcludes); + }, array_merge($analyseExcludes, $stubFiles)); } public function isExcludedFromAnalysing(string $file): bool diff --git a/tests/PHPStan/File/FileExcluderTest.php b/tests/PHPStan/File/FileExcluderTest.php index 51d30e5753..808b36395c 100644 --- a/tests/PHPStan/File/FileExcluderTest.php +++ b/tests/PHPStan/File/FileExcluderTest.php @@ -19,7 +19,7 @@ public function testFilesAreExcludedFromAnalysingOnWindows( { $this->skipIfNotOnWindows(); - $fileExcluder = new FileExcluder($this->getFileHelper(), $analyseExcludes); + $fileExcluder = new FileExcluder($this->getFileHelper(), $analyseExcludes, []); $this->assertSame($isExcluded, $fileExcluder->isExcludedFromAnalysing($filePath)); } @@ -129,7 +129,7 @@ public function testFilesAreExcludedFromAnalysingOnUnix( { $this->skipIfNotOnUnix(); - $fileExcluder = new FileExcluder($this->getFileHelper(), $analyseExcludes); + $fileExcluder = new FileExcluder($this->getFileHelper(), $analyseExcludes, []); $this->assertSame($isExcluded, $fileExcluder->isExcludedFromAnalysing($filePath)); }