Skip to content

Commit 0cb0920

Browse files
Implement cache format versioning
1 parent 6ac32d5 commit 0cb0920

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/StaticAnalysis/CachingCoveredFileAnalyser.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
final class CachingCoveredFileAnalyser extends Cache implements CoveredFileAnalyser
1818
{
19+
private const CACHE_FORMAT_VERSION = 2;
20+
1921
/**
2022
* @var CoveredFileAnalyser
2123
*/
@@ -80,8 +82,10 @@ public function ignoredLinesFor(string $filename): array
8082

8183
public function process(string $filename): void
8284
{
83-
if ($this->has($filename, __CLASS__)) {
84-
$this->cache[$filename] = $this->read($filename, __CLASS__, [LinesOfCode::class]);
85+
$cacheKey = __CLASS__ . self::CACHE_FORMAT_VERSION;
86+
87+
if ($this->has($filename, $cacheKey)) {
88+
$this->cache[$filename] = $this->read($filename, $cacheKey, [LinesOfCode::class]);
8589

8690
return;
8791
}
@@ -94,6 +98,6 @@ public function process(string $filename): void
9498
'ignoredLinesFor' => $this->coveredFileAnalyser->ignoredLinesFor($filename),
9599
];
96100

97-
$this->write($filename, __CLASS__, $this->cache[$filename]);
101+
$this->write($filename, $cacheKey, $this->cache[$filename]);
98102
}
99103
}

0 commit comments

Comments
 (0)