Skip to content

Commit 0109689

Browse files
rui-smilesebastianbergmann
authored andcommitted
Add cache to Coverage Report Directory in order to avoid issues with multiple reporter when using fibers.
1 parent bf35465 commit 0109689

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/CodeCoverage.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ final class CodeCoverage
114114
*/
115115
private $cacheDirectory;
116116

117+
/**
118+
* @var ?Directory
119+
*/
120+
private $cacheReport;
121+
117122
public function __construct(Driver $driver, Filter $filter)
118123
{
119124
$this->driver = $driver;
@@ -127,7 +132,10 @@ public function __construct(Driver $driver, Filter $filter)
127132
*/
128133
public function getReport(): Directory
129134
{
130-
return (new Builder($this->analyser()))->build($this);
135+
if (!$this->cacheReport) {
136+
$this->cacheReport = (new Builder($this->analyser()))->build($this);
137+
}
138+
return clone $this->cacheReport;
131139
}
132140

133141
/**

0 commit comments

Comments
 (0)