Skip to content

Commit

Permalink
ResultCacheManager: introduce flag checkDependenciesOfProjectExtensio…
Browse files Browse the repository at this point in the history
…nFiles
  • Loading branch information
janedbal authored and ondrejmirtes committed Jul 30, 2021
1 parent 91fde71 commit 10bb2b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions conf/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ parameters:
memoryLimitFile: %tmpDir%/.memory_limit
tempResultCachePath: %tmpDir%/resultCaches
resultCachePath: %tmpDir%/resultCache.php
resultCacheChecksProjectExtensionFilesDependencies: false
staticReflectionClassNamePatterns:
- '#^PhpParser\\#'
- '#^PHPStan\\#'
Expand Down Expand Up @@ -305,6 +306,7 @@ parametersSchema:
memoryLimitFile: string()
tempResultCachePath: string()
resultCachePath: string()
resultCacheChecksProjectExtensionFilesDependencies: bool()
staticReflectionClassNamePatterns: listOf(string())
dynamicConstantNames: listOf(string())
customRulesetUsed: bool()
Expand Down Expand Up @@ -477,6 +479,7 @@ services:
bootstrapFiles: %bootstrapFiles%
scanFiles: %scanFiles%
scanDirectories: %scanDirectories%
checkDependenciesOfProjectExtensionFiles: %resultCacheChecksProjectExtensionFilesDependencies%

-
class: PHPStan\Analyser\ResultCache\ResultCacheClearer
Expand Down
15 changes: 11 additions & 4 deletions src/Analyser/ResultCache/ResultCacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class ResultCacheManager
/** @var array<string, true> */
private array $alreadyProcessed = [];

private bool $checkDependenciesOfProjectExtensionFiles;

/**
* @param ExportedNodeFetcher $exportedNodeFetcher
* @param FileFinder $scanFileFinder
Expand Down Expand Up @@ -92,7 +94,8 @@ public function __construct(
array $bootstrapFiles,
array $scanFiles,
array $scanDirectories,
array $fileReplacements
array $fileReplacements,
bool $checkDependenciesOfProjectExtensionFiles
)
{
$this->exportedNodeFetcher = $exportedNodeFetcher;
Expand All @@ -109,6 +112,7 @@ public function __construct(
$this->scanFiles = $scanFiles;
$this->scanDirectories = $scanDirectories;
$this->fileReplacements = $fileReplacements;
$this->checkDependenciesOfProjectExtensionFiles = $checkDependenciesOfProjectExtensionFiles;
}

/**
Expand Down Expand Up @@ -688,9 +692,12 @@ private function getAllDependencies(string $fileName, array $dependencies): arra
$this->alreadyProcessed[$fileName] = true;

$files = [$fileName];
foreach ($dependencies[$fileName] as $fileDep) {
foreach ($this->getAllDependencies($fileDep, $dependencies) as $fileDep2) {
$files[] = $fileDep2;

if ($this->checkDependenciesOfProjectExtensionFiles) {
foreach ($dependencies[$fileName] as $fileDep) {
foreach ($this->getAllDependencies($fileDep, $dependencies) as $fileDep2) {
$files[] = $fileDep2;
}
}
}

Expand Down

0 comments on commit 10bb2b0

Please sign in to comment.