4949
5050/**
5151 * @phpstan-import-type LinesToIgnore from FileAnalyserResult
52+ * @phpstan-import-type CollectorData from CollectedData
5253 */
5354final class ResultCacheManager
5455{
@@ -406,10 +407,7 @@ public function process(AnalyserResult $analyserResult, ResultCache $resultCache
406407 $ freshLocallyIgnoredErrorsByFile [$ error ->getFilePath ()][] = $ error ;
407408 }
408409
409- $ freshCollectedDataByFile = [];
410- foreach ($ analyserResult ->getCollectedData () as $ collectedData ) {
411- $ freshCollectedDataByFile [$ collectedData ->getFilePath ()][] = $ collectedData ;
412- }
410+ $ freshCollectedDataByFile = $ analyserResult ->getCollectedData ();
413411
414412 $ meta = $ resultCache ->getMeta ();
415413 $ projectConfigArray = $ meta ['projectConfig ' ];
@@ -524,13 +522,6 @@ public function process(AnalyserResult $analyserResult, ResultCache $resultCache
524522 }
525523 }
526524
527- $ flatCollectedData = [];
528- foreach ($ collectedDataByFile as $ fileCollectedData ) {
529- foreach ($ fileCollectedData as $ collectedData ) {
530- $ flatCollectedData [] = $ collectedData ;
531- }
532- }
533-
534525 return new ResultCacheProcessResult (new AnalyserResult (
535526 $ flatErrors ,
536527 $ analyserResult ->getFilteredPhpErrors (),
@@ -539,7 +530,7 @@ public function process(AnalyserResult $analyserResult, ResultCache $resultCache
539530 $ linesToIgnore ,
540531 $ unmatchedLineIgnores ,
541532 $ internalErrors ,
542- $ flatCollectedData ,
533+ $ collectedDataByFile ,
543534 $ dependencies ,
544535 $ exportedNodes ,
545536 $ analyserResult ->hasReachedInternalErrorsCountLimit (),
@@ -584,8 +575,8 @@ private function mergeLocallyIgnoredErrors(ResultCache $resultCache, array $fres
584575 }
585576
586577 /**
587- * @param array<string, array<CollectedData>> $freshCollectedDataByFile
588- * @return array<string, array<CollectedData>>
578+ * @param CollectorData $freshCollectedDataByFile
579+ * @return CollectorData
589580 */
590581 private function mergeCollectedData (ResultCache $ resultCache , array $ freshCollectedDataByFile ): array
591582 {
@@ -704,7 +695,7 @@ private function mergeUnmatchedLineIgnores(ResultCache $resultCache, array $fres
704695 * @param array<string, list<Error>> $locallyIgnoredErrors
705696 * @param array<string, LinesToIgnore> $linesToIgnore
706697 * @param array<string, LinesToIgnore> $unmatchedLineIgnores
707- * @param array<string, array<CollectedData>> $collectedData
698+ * @param array<string, array<string, list< CollectedData> >> $collectedData
708699 * @param array<string, array<string>> $dependencies
709700 * @param array<string, array<RootExportedNode>> $exportedNodes
710701 * @param array<string, array{string, bool, string}> $projectExtensionFiles
@@ -760,6 +751,10 @@ private function save(
760751 ksort ($ collectedData );
761752 ksort ($ invertedDependencies );
762753
754+ foreach ($ collectedData as & $ collectedDataPerFile ) {
755+ ksort ($ collectedDataPerFile );
756+ }
757+
763758 foreach ($ invertedDependencies as $ file => $ fileData ) {
764759 $ dependentFiles = $ fileData ['dependentFiles ' ];
765760 sort ($ dependentFiles );
0 commit comments