diff --git a/ChangeLog-12.0.md b/ChangeLog-12.0.md index 4427d3d4..fe5b6f06 100644 --- a/ChangeLog-12.0.md +++ b/ChangeLog-12.0.md @@ -6,6 +6,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt ### Removed +* Optional argument `$linesToBeUsed` of `CodeCoverage::stop()` and `CodeCoverage::append()` methods * This component is no longer supported on PHP 8.2 [12.0.0]: https://github.com/sebastianbergmann/php-code-coverage/compare/11.0...main diff --git a/src/CodeCoverage.php b/src/CodeCoverage.php index c23fe17b..959c238f 100644 --- a/src/CodeCoverage.php +++ b/src/CodeCoverage.php @@ -14,7 +14,6 @@ use function array_flip; use function array_keys; use function array_merge; -use function array_merge_recursive; use function array_unique; use function count; use function explode; @@ -56,11 +55,6 @@ final class CodeCoverage private ProcessedCodeCoverageData $data; private bool $useAnnotationsForIgnoringCode = true; - /** - * @var array> - */ - private array $linesToBeIgnored = []; - /** * @var array */ @@ -174,19 +168,11 @@ public function start(string $id, ?TestSize $size = null, bool $clear = false): $this->cachedReport = null; } - /** - * @param array> $linesToBeIgnored - */ - public function stop(bool $append = true, ?TestStatus $status = null, array|false $linesToBeCovered = [], array $linesToBeUsed = [], array $linesToBeIgnored = []): RawCodeCoverageData + public function stop(bool $append = true, ?TestStatus $status = null, array|false $linesToBeCovered = [], array $linesToBeUsed = []): RawCodeCoverageData { $data = $this->driver->stop(); - $this->linesToBeIgnored = array_merge_recursive( - $this->linesToBeIgnored, - $linesToBeIgnored, - ); - - $this->append($data, null, $append, $status, $linesToBeCovered, $linesToBeUsed, $linesToBeIgnored); + $this->append($data, null, $append, $status, $linesToBeCovered, $linesToBeUsed); $this->currentId = null; $this->currentSize = null; @@ -196,13 +182,11 @@ public function stop(bool $append = true, ?TestStatus $status = null, array|fals } /** - * @param array> $linesToBeIgnored - * * @throws ReflectionException * @throws TestIdMissingException * @throws UnintentionallyCoveredCodeException */ - public function append(RawCodeCoverageData $rawData, ?string $id = null, bool $append = true, ?TestStatus $status = null, array|false $linesToBeCovered = [], array $linesToBeUsed = [], array $linesToBeIgnored = []): void + public function append(RawCodeCoverageData $rawData, ?string $id = null, bool $append = true, ?TestStatus $status = null, array|false $linesToBeCovered = [], array $linesToBeUsed = []): void { if ($id === null) { $id = $this->currentId; @@ -229,7 +213,7 @@ public function append(RawCodeCoverageData $rawData, ?string $id = null, bool $a $this->applyExecutableLinesFilter($rawData); if ($this->useAnnotationsForIgnoringCode) { - $this->applyIgnoredLinesFilter($rawData, $linesToBeIgnored); + $this->applyIgnoredLinesFilter($rawData); } $this->data->initializeUnseenData($rawData); @@ -452,23 +436,13 @@ private function applyExecutableLinesFilter(RawCodeCoverageData $data): void } } - /** - * @param array> $linesToBeIgnored - */ - private function applyIgnoredLinesFilter(RawCodeCoverageData $data, array $linesToBeIgnored): void + private function applyIgnoredLinesFilter(RawCodeCoverageData $data): void { foreach (array_keys($data->lineCoverage()) as $filename) { if (!$this->filter->isFile($filename)) { continue; } - if (isset($linesToBeIgnored[$filename])) { - $data->removeCoverageDataForLines( - $filename, - $linesToBeIgnored[$filename], - ); - } - $data->removeCoverageDataForLines( $filename, $this->analyser()->ignoredLinesFor($filename), @@ -494,7 +468,6 @@ private function addUncoveredFilesFromFilter(): void $this->analyser(), ), self::UNCOVERED_FILES, - linesToBeIgnored: $this->linesToBeIgnored, ); } }