Skip to content

Commit

Permalink
Exclude stubFiles from main analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 4, 2020
1 parent 4419f2e commit 92df236
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions conf/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ services:
class: PHPStan\File\FileExcluder
arguments:
analyseExcludes: %excludes_analyse%
stubFiles: %stubFiles%

-
class: PHPStan\File\FileFinder
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/IgnoredError.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/File/FileExcluder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -36,7 +38,7 @@ public function __construct(
}

return $fileHelper->absolutizePath($normalized);
}, $analyseExcludes);
}, array_merge($analyseExcludes, $stubFiles));
}

public function isExcludedFromAnalysing(string $file): bool
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/File/FileExcluderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 92df236

Please sign in to comment.