From c0fb0885bc2182669811971a91f791dfcfd26aec Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Wed, 13 May 2020 13:53:29 +0100 Subject: [PATCH] Use PCOV's built-in filter --- src/CodeCoverage.php | 2 +- src/Driver/PCOV.php | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/CodeCoverage.php b/src/CodeCoverage.php index 765629d33..9e7396214 100644 --- a/src/CodeCoverage.php +++ b/src/CodeCoverage.php @@ -897,7 +897,7 @@ private function selectDriver(Filter $filter): Driver } if ($runtime->hasPCOV()) { - return new PCOV; + return new PCOV($filter); } if ($runtime->hasXdebug()) { diff --git a/src/Driver/PCOV.php b/src/Driver/PCOV.php index d3d218993..1ee2e9b3d 100644 --- a/src/Driver/PCOV.php +++ b/src/Driver/PCOV.php @@ -9,11 +9,23 @@ */ namespace SebastianBergmann\CodeCoverage\Driver; +use SebastianBergmann\CodeCoverage\Filter; + /** * Driver for PCOV code coverage functionality. */ final class PCOV implements Driver { + /** + * @var Filter + */ + private $filter; + + public function __construct(Filter $filter) + { + $this->filter = $filter; + } + /** * Start collection of code coverage information. */ @@ -29,14 +41,9 @@ public function stop(): array { \pcov\stop(); - $waiting = \pcov\waiting(); - $collect = []; - - if ($waiting) { - $collect = \pcov\collect(\pcov\inclusive, $waiting); + $collect = \pcov\collect(\pcov\inclusive, $this->filter->getWhitelist()); - \pcov\clear(); - } + \pcov\clear(); return $collect; }