Skip to content

Commit b05dcd0

Browse files
Invalidate report cache when underlying data changes
1 parent a73ada3 commit b05dcd0

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/CodeCoverage.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ public function getReport(): Directory
144144
*/
145145
public function clear(): void
146146
{
147-
$this->currentId = null;
148-
$this->data = new ProcessedCodeCoverageData;
149-
$this->tests = [];
147+
$this->currentId = null;
148+
$this->data = new ProcessedCodeCoverageData;
149+
$this->tests = [];
150+
$this->cachedReport = null;
150151
}
151152

152153
/**
@@ -211,6 +212,8 @@ public function start($id, bool $clear = false): void
211212
$this->currentId = $id;
212213

213214
$this->driver->start();
215+
216+
$this->cachedReport = null;
214217
}
215218

216219
/**
@@ -229,7 +232,8 @@ public function stop(bool $append = true, $linesToBeCovered = [], array $linesTo
229232
$data = $this->driver->stop();
230233
$this->append($data, null, $append, $linesToBeCovered, $linesToBeUsed);
231234

232-
$this->currentId = null;
235+
$this->currentId = null;
236+
$this->cachedReport = null;
233237

234238
return $data;
235239
}
@@ -254,6 +258,8 @@ public function append(RawCodeCoverageData $rawData, $id = null, bool $append =
254258
throw new TestIdMissingException;
255259
}
256260

261+
$this->cachedReport = null;
262+
257263
$this->applyFilter($rawData);
258264

259265
$this->applyExecutableLinesFilter($rawData);
@@ -321,6 +327,8 @@ public function merge(self $that): void
321327
$this->data->merge($that->data);
322328

323329
$this->tests = array_merge($this->tests, $that->getTests());
330+
331+
$this->cachedReport = null;
324332
}
325333

326334
public function enableCheckForUnintentionallyCoveredCode(): void

0 commit comments

Comments
 (0)