-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Config option excludePaths that allows different lists for analyse an…
…d analyse+scan
- Loading branch information
1 parent
377e49c
commit bf35a10
Showing
6 changed files
with
160 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\File; | ||
|
||
class FileExcluderFactory | ||
{ | ||
|
||
private FileExcluderRawFactory $fileExcluderRawFactory; | ||
|
||
/** @var string[] */ | ||
private array $obsoleteExcludesAnalyse; | ||
|
||
/** @var array<int, string>|array{analyse?: array<int, string>, analyseAndScan?: array<int, string>}|null */ | ||
private ?array $excludePaths; | ||
|
||
/** | ||
* @param FileExcluderRawFactory $fileExcluderRawFactory | ||
* @param string[] $obsoleteExcludesAnalyse | ||
* @param array<int, string>|array{analyse?: array<int, string>, analyseAndScan?: array<int, string>}|null $excludePaths | ||
*/ | ||
public function __construct( | ||
FileExcluderRawFactory $fileExcluderRawFactory, | ||
array $obsoleteExcludesAnalyse, | ||
?array $excludePaths | ||
) | ||
{ | ||
$this->fileExcluderRawFactory = $fileExcluderRawFactory; | ||
$this->obsoleteExcludesAnalyse = $obsoleteExcludesAnalyse; | ||
$this->excludePaths = $excludePaths; | ||
} | ||
|
||
public function createAnalyseFileExcluder(): FileExcluder | ||
{ | ||
if ($this->excludePaths === null) { | ||
return $this->fileExcluderRawFactory->create($this->obsoleteExcludesAnalyse); | ||
} | ||
|
||
if (!array_key_exists('analyse', $this->excludePaths) && !array_key_exists('analyseAndScan', $this->excludePaths)) { | ||
return $this->fileExcluderRawFactory->create($this->excludePaths); | ||
} | ||
|
||
$paths = []; | ||
if (array_key_exists('analyse', $this->excludePaths)) { | ||
$paths = $this->excludePaths['analyse']; | ||
} | ||
if (array_key_exists('analyseAndScan', $this->excludePaths)) { | ||
$paths = $this->excludePaths['analyseAndScan']; | ||
} | ||
|
||
return $this->fileExcluderRawFactory->create(array_values(array_unique($paths))); | ||
} | ||
|
||
public function createScanFileExcluder(): FileExcluder | ||
{ | ||
if ($this->excludePaths === null) { | ||
return $this->fileExcluderRawFactory->create($this->obsoleteExcludesAnalyse); | ||
} | ||
|
||
if (!array_key_exists('analyse', $this->excludePaths) && !array_key_exists('analyseAndScan', $this->excludePaths)) { | ||
return $this->fileExcluderRawFactory->create($this->excludePaths); | ||
} | ||
|
||
$paths = []; | ||
if (array_key_exists('analyseAndScan', $this->excludePaths)) { | ||
$paths = $this->excludePaths['analyseAndScan']; | ||
} | ||
|
||
return $this->fileExcluderRawFactory->create(array_values(array_unique($paths))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\File; | ||
|
||
interface FileExcluderRawFactory | ||
{ | ||
|
||
/** | ||
* @param string[] $analyseExcludes | ||
* @return FileExcluder | ||
*/ | ||
public function create( | ||
array $analyseExcludes | ||
): FileExcluder; | ||
|
||
} |