diff --git a/src/Driver/PcovDriver.php b/src/Driver/PcovDriver.php index f4eca6031..0a433e0b9 100644 --- a/src/Driver/PcovDriver.php +++ b/src/Driver/PcovDriver.php @@ -45,14 +45,19 @@ public function stop(): RawCodeCoverageData { \pcov\stop(); - $collect = \pcov\collect( - \pcov\inclusive, - !$this->filter->isEmpty() ? $this->filter->files() : \pcov\waiting() - ); + $filesToCollectCoverageFor = \pcov\waiting(); + $collected = []; - \pcov\clear(); + if ($filesToCollectCoverageFor) { + if (!$this->filter->isEmpty()) { + $filesToCollectCoverageFor = array_intersect($filesToCollectCoverageFor, $this->filter->files()); + } + $collected = \pcov\collect(\pcov\inclusive, $filesToCollectCoverageFor); - return RawCodeCoverageData::fromXdebugWithoutPathCoverage($collect); + \pcov\clear(); + } + + return RawCodeCoverageData::fromXdebugWithoutPathCoverage($collected); } public function nameAndVersion(): string