diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 80f55e5881..672771ad18 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -309,7 +309,7 @@ jobs:
uses: actions/cache@v1
with:
path: ./tmp
- key: "result-cache-v3"
+ key: "result-cache-v4"
- name: "PHPStan with result cache"
if: matrix.operating-system == 'ubuntu-latest'
diff --git a/phpcs.xml b/phpcs.xml
index f70a4cd616..64222d1751 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -8,6 +8,7 @@
+
diff --git a/src/Analyser/ResultCache/ResultCacheManager.php b/src/Analyser/ResultCache/ResultCacheManager.php
index a7ef094a3e..ce409a392e 100644
--- a/src/Analyser/ResultCache/ResultCacheManager.php
+++ b/src/Analyser/ResultCache/ResultCacheManager.php
@@ -11,7 +11,7 @@
class ResultCacheManager
{
- private const CACHE_VERSION = 'v3-all-errors';
+ private const CACHE_VERSION = 'v4-callback';
/** @var string */
private $cacheFilePath;
@@ -98,7 +98,7 @@ public function restore(array $allAnalysedFiles, bool $debug): ResultCache
$deletedFiles = array_fill_keys(array_keys($invertedDependencies), true);
$filesToAnalyse = [];
$invertedDependenciesToReturn = [];
- $errors = $data['errors'];
+ $errors = $data['errorsCallback']();
$filteredErrors = [];
$newFileAppeared = false;
foreach ($allAnalysedFiles as $analysedFile) {
@@ -325,16 +325,25 @@ private function save(
$invertedDependencies[$file]['dependentFiles'] = $dependentFiles;
}
+ $template = <<<'php'
+ %s,
+ 'meta' => %s,
+ 'errorsCallback' => static function (): array { return %s; },
+ 'dependencies' => %s,
+];
+php;
+
$tmpSuccess = @file_put_contents(
$this->cacheFilePath,
sprintf(
- " $lastFullAnalysisTime,
- 'meta' => $this->getMeta(),
- 'errors' => $errors,
- 'dependencies' => $invertedDependencies,
- ], true)
+ $template,
+ var_export($lastFullAnalysisTime, true),
+ var_export($this->getMeta(), true),
+ var_export($errors, true),
+ var_export($invertedDependencies, true)
)
);
if ($tmpSuccess === false) {