@@ -95,13 +95,13 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
9595 if ($ output ->isDebug ()) {
9696 $ output ->writeLineFormatted ('Result cache not used because of debug mode. ' );
9797 }
98- return new ResultCache ($ allAnalysedFiles , true , time (), [], [], []);
98+ return new ResultCache ($ allAnalysedFiles , true , time (), $ this -> getMeta ( $ projectConfigArray ), [], [], []);
9999 }
100100 if ($ onlyFiles ) {
101101 if ($ output ->isDebug ()) {
102102 $ output ->writeLineFormatted ('Result cache not used because only files were passed as analysed paths. ' );
103103 }
104- return new ResultCache ($ allAnalysedFiles , true , time (), [], [], []);
104+ return new ResultCache ($ allAnalysedFiles , true , time (), $ this -> getMeta ( $ projectConfigArray ), [], [], []);
105105 }
106106
107107 $ cacheFilePath = $ this ->cacheFilePath ;
@@ -116,7 +116,7 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
116116 if ($ output ->isDebug ()) {
117117 $ output ->writeLineFormatted ('Result cache not used because the cache file does not exist. ' );
118118 }
119- return new ResultCache ($ allAnalysedFiles , true , time (), [], [], []);
119+ return new ResultCache ($ allAnalysedFiles , true , time (), $ this -> getMeta ( $ projectConfigArray ), [], [], []);
120120 }
121121
122122 try {
@@ -128,7 +128,7 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
128128
129129 @unlink ($ cacheFilePath );
130130
131- return new ResultCache ($ allAnalysedFiles , true , time (), [], [], []);
131+ return new ResultCache ($ allAnalysedFiles , true , time (), $ this -> getMeta ( $ projectConfigArray ), [], [], []);
132132 }
133133
134134 if (!is_array ($ data )) {
@@ -137,22 +137,23 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
137137 $ output ->writeLineFormatted ('Result cache not used because the cache file is corrupted. ' );
138138 }
139139
140- return new ResultCache ($ allAnalysedFiles , true , time (), [], [], []);
140+ return new ResultCache ($ allAnalysedFiles , true , time (), $ this -> getMeta ( $ projectConfigArray ), [], [], []);
141141 }
142142
143- if ($ data ['meta ' ] !== $ this ->getMeta ($ projectConfigArray )) {
143+ $ meta = $ this ->getMeta ($ projectConfigArray );
144+ if ($ data ['meta ' ] !== $ meta ) {
144145 if ($ output ->isDebug ()) {
145146 $ output ->writeLineFormatted ('Result cache not used because the metadata do not match. ' );
146147 }
147- return new ResultCache ($ allAnalysedFiles , true , time (), [], [], []);
148+ return new ResultCache ($ allAnalysedFiles , true , time (), $ meta , [], [], []);
148149 }
149150
150151 if (time () - $ data ['lastFullAnalysisTime ' ] >= 60 * 60 * 24 * 7 ) {
151152 if ($ output ->isDebug ()) {
152153 $ output ->writeLineFormatted ('Result cache not used because it \'s more than 7 days since last full analysis. ' );
153154 }
154155 // run full analysis if the result cache is older than 7 days
155- return new ResultCache ($ allAnalysedFiles , true , time (), [], [], []);
156+ return new ResultCache ($ allAnalysedFiles , true , time (), $ meta , [], [], []);
156157 }
157158
158159 $ invertedDependencies = $ data ['dependencies ' ];
@@ -232,7 +233,7 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
232233 }
233234 }
234235
235- return new ResultCache (array_unique ($ filesToAnalyse ), false , $ data ['lastFullAnalysisTime ' ], $ filteredErrors , $ invertedDependenciesToReturn , $ filteredExportedNodes );
236+ return new ResultCache (array_unique ($ filesToAnalyse ), false , $ data ['lastFullAnalysisTime ' ], $ meta , $ filteredErrors , $ invertedDependenciesToReturn , $ filteredExportedNodes );
236237 }
237238
238239 /**
@@ -263,20 +264,20 @@ private function exportedNodesChanged(string $analysedFile, array $cachedFileExp
263264 /**
264265 * @param AnalyserResult $analyserResult
265266 * @param ResultCache $resultCache
266- * @param mixed[]|null $projectConfigArray
267267 * @param bool|string $save
268268 * @return ResultCacheProcessResult
269269 * @throws \PHPStan\ShouldNotHappenException
270270 */
271- public function process (AnalyserResult $ analyserResult , ResultCache $ resultCache , Output $ output , bool $ onlyFiles , ? array $ projectConfigArray , $ save ): ResultCacheProcessResult
271+ public function process (AnalyserResult $ analyserResult , ResultCache $ resultCache , Output $ output , bool $ onlyFiles , $ save ): ResultCacheProcessResult
272272 {
273273 $ internalErrors = $ analyserResult ->getInternalErrors ();
274274 $ freshErrorsByFile = [];
275275 foreach ($ analyserResult ->getErrors () as $ error ) {
276276 $ freshErrorsByFile [$ error ->getFilePath ()][] = $ error ;
277277 }
278278
279- $ doSave = function (array $ errorsByFile , ?array $ dependencies , array $ exportedNodes , ?string $ resultCacheName ) use ($ internalErrors , $ resultCache , $ output , $ onlyFiles , $ projectConfigArray ): bool {
279+ $ meta = $ resultCache ->getMeta ();
280+ $ doSave = function (array $ errorsByFile , ?array $ dependencies , array $ exportedNodes , ?string $ resultCacheName ) use ($ internalErrors , $ resultCache , $ output , $ onlyFiles , $ meta ): bool {
280281 if ($ onlyFiles ) {
281282 if ($ output ->isDebug ()) {
282283 $ output ->writeLineFormatted ('Result cache was not saved because only files were passed as analysed paths. ' );
@@ -311,7 +312,7 @@ public function process(AnalyserResult $analyserResult, ResultCache $resultCache
311312 }
312313 }
313314
314- $ this ->save ($ resultCache ->getLastFullAnalysisTime (), $ resultCacheName , $ errorsByFile , $ dependencies , $ exportedNodes , $ projectConfigArray );
315+ $ this ->save ($ resultCache ->getLastFullAnalysisTime (), $ resultCacheName , $ errorsByFile , $ dependencies , $ exportedNodes , $ meta );
315316
316317 if ($ output ->isDebug ()) {
317318 $ output ->writeLineFormatted ('Result cache is saved. ' );
@@ -445,15 +446,15 @@ private function mergeExportedNodes(ResultCache $resultCache, array $freshExport
445446 * @param array<string, array<Error>> $errors
446447 * @param array<string, array<string>> $dependencies
447448 * @param array<string, array<ExportedNode>> $exportedNodes
448- * @param mixed[]|null $projectConfigArray
449+ * @param mixed[] $meta
449450 */
450451 private function save (
451452 int $ lastFullAnalysisTime ,
452453 ?string $ resultCacheName ,
453454 array $ errors ,
454455 array $ dependencies ,
455456 array $ exportedNodes ,
456- ? array $ projectConfigArray
457+ array $ meta
457458 ): void
458459 {
459460 $ invertedDependencies = [];
@@ -519,7 +520,7 @@ private function save(
519520 sprintf (
520521 $ template ,
521522 var_export ($ lastFullAnalysisTime , true ),
522- var_export ($ this -> getMeta ( $ projectConfigArray ) , true ),
523+ var_export ($ meta , true ),
523524 var_export ($ errors , true ),
524525 var_export ($ invertedDependencies , true ),
525526 var_export ($ exportedNodes , true )
0 commit comments