From 8f2e45ccfca7f6e04fbe125772085aa04ee17147 Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Wed, 28 Jul 2021 14:53:35 +0200 Subject: [PATCH] ResultCacheManager: introduce flag checkDependenciesOfProjectExtensionFiles --- conf/config.neon | 3 +++ src/Analyser/ResultCache/ResultCacheManager.php | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/conf/config.neon b/conf/config.neon index a15d7c0c2b..50675c5164 100644 --- a/conf/config.neon +++ b/conf/config.neon @@ -114,6 +114,7 @@ parameters: memoryLimitFile: %tmpDir%/.memory_limit tempResultCachePath: %tmpDir%/resultCaches resultCachePath: %tmpDir%/resultCache.php + resultCacheChecksProjectExtensionFilesDependencies: false staticReflectionClassNamePatterns: - '#^PhpParser\\#' - '#^PHPStan\\#' @@ -305,6 +306,7 @@ parametersSchema: memoryLimitFile: string() tempResultCachePath: string() resultCachePath: string() + resultCacheChecksProjectExtensionFilesDependencies: bool() staticReflectionClassNamePatterns: listOf(string()) dynamicConstantNames: listOf(string()) customRulesetUsed: bool() @@ -477,6 +479,7 @@ services: bootstrapFiles: %bootstrapFiles% scanFiles: %scanFiles% scanDirectories: %scanDirectories% + checkDependenciesOfProjectExtensionFiles: %resultCacheChecksProjectExtensionFilesDependencies% - class: PHPStan\Analyser\ResultCache\ResultCacheClearer diff --git a/src/Analyser/ResultCache/ResultCacheManager.php b/src/Analyser/ResultCache/ResultCacheManager.php index aab1f449cd..71ae46d78c 100644 --- a/src/Analyser/ResultCache/ResultCacheManager.php +++ b/src/Analyser/ResultCache/ResultCacheManager.php @@ -62,6 +62,8 @@ class ResultCacheManager /** @var array */ private array $alreadyProcessed = []; + private bool $checkDependenciesOfProjectExtensionFiles; + /** * @param ExportedNodeFetcher $exportedNodeFetcher * @param FileFinder $scanFileFinder @@ -92,7 +94,8 @@ public function __construct( array $bootstrapFiles, array $scanFiles, array $scanDirectories, - array $fileReplacements + array $fileReplacements, + bool $checkDependenciesOfProjectExtensionFiles ) { $this->exportedNodeFetcher = $exportedNodeFetcher; @@ -109,6 +112,7 @@ public function __construct( $this->scanFiles = $scanFiles; $this->scanDirectories = $scanDirectories; $this->fileReplacements = $fileReplacements; + $this->checkDependenciesOfProjectExtensionFiles = $checkDependenciesOfProjectExtensionFiles; } /** @@ -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; + } } }