Skip to content

Commit 92df236

Browse files
committed
Exclude stubFiles from main analysis
1 parent 4419f2e commit 92df236

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

conf/config.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ services:
325325
class: PHPStan\File\FileExcluder
326326
arguments:
327327
analyseExcludes: %excludes_analyse%
328+
stubFiles: %stubFiles%
328329

329330
-
330331
class: PHPStan\File\FileFinder

src/Analyser/IgnoredError.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static function shouldIgnore(
5454
$ignoredErrorPattern = str_replace([preg_quote('\r\n'), preg_quote('\r')], preg_quote('\n'), $ignoredErrorPattern);
5555

5656
if ($path !== null) {
57-
$fileExcluder = new FileExcluder($fileHelper, [$path]);
57+
$fileExcluder = new FileExcluder($fileHelper, [$path], []);
5858

5959
if (\Nette\Utils\Strings::match($errorMessage, $ignoredErrorPattern) === null) {
6060
return false;

src/File/FileExcluder.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ class FileExcluder
1515
/**
1616
* @param FileHelper $fileHelper
1717
* @param string[] $analyseExcludes
18+
* @param string[] $stubFiles
1819
*/
1920
public function __construct(
2021
FileHelper $fileHelper,
21-
array $analyseExcludes
22+
array $analyseExcludes,
23+
array $stubFiles
2224
)
2325
{
2426
$this->analyseExcludes = array_map(function (string $exclude) use ($fileHelper): string {
@@ -36,7 +38,7 @@ public function __construct(
3638
}
3739

3840
return $fileHelper->absolutizePath($normalized);
39-
}, $analyseExcludes);
41+
}, array_merge($analyseExcludes, $stubFiles));
4042
}
4143

4244
public function isExcludedFromAnalysing(string $file): bool

tests/PHPStan/File/FileExcluderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function testFilesAreExcludedFromAnalysingOnWindows(
1919
{
2020
$this->skipIfNotOnWindows();
2121

22-
$fileExcluder = new FileExcluder($this->getFileHelper(), $analyseExcludes);
22+
$fileExcluder = new FileExcluder($this->getFileHelper(), $analyseExcludes, []);
2323

2424
$this->assertSame($isExcluded, $fileExcluder->isExcludedFromAnalysing($filePath));
2525
}
@@ -129,7 +129,7 @@ public function testFilesAreExcludedFromAnalysingOnUnix(
129129
{
130130
$this->skipIfNotOnUnix();
131131

132-
$fileExcluder = new FileExcluder($this->getFileHelper(), $analyseExcludes);
132+
$fileExcluder = new FileExcluder($this->getFileHelper(), $analyseExcludes, []);
133133

134134
$this->assertSame($isExcluded, $fileExcluder->isExcludedFromAnalysing($filePath));
135135
}

0 commit comments

Comments
 (0)