Skip to content

Commit 7af249f

Browse files
Closes #994
1 parent 8d6cb4c commit 7af249f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

ChangeLog-10.1.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
44

5+
## [10.1.1] - 2023-MM-DD
6+
7+
### Fixed
8+
9+
* [#994](https://github.com/sebastianbergmann/php-code-coverage/issues/994): Argument `$linesToBeIgnored` of `CodeCoverage::stop()` has no effect for files that are not executed at all
10+
511
## [10.1.0] - 2023-04-13
612

713
### Added
@@ -12,4 +18,5 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
1218

1319
* The `SebastianBergmann\CodeCoverage\Filter::includeDirectory()`, `SebastianBergmann\CodeCoverage\Filter::excludeDirectory()`, and `SebastianBergmann\CodeCoverage\Filter::excludeFile()` methods are now deprecated
1420

21+
[10.1.1]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.1.0...main
1522
[10.1.0]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.0.2...10.1.0

src/CodeCoverage.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use function array_flip;
1515
use function array_keys;
1616
use function array_merge;
17+
use function array_merge_recursive;
1718
use function array_unique;
1819
use function count;
1920
use function explode;
@@ -55,6 +56,11 @@ final class CodeCoverage
5556
private ProcessedCodeCoverageData $data;
5657
private bool $useAnnotationsForIgnoringCode = true;
5758

59+
/**
60+
* @psalm-var array<string,list<int>>
61+
*/
62+
private array $linesToBeIgnored = [];
63+
5864
/**
5965
* @psalm-var array<string, TestType>
6066
*/
@@ -159,6 +165,11 @@ public function stop(bool $append = true, TestStatus $status = null, array|false
159165
{
160166
$data = $this->driver->stop();
161167

168+
$this->linesToBeIgnored = array_merge_recursive(
169+
$this->linesToBeIgnored,
170+
$linesToBeIgnored
171+
);
172+
162173
$this->append($data, null, $append, $status, $linesToBeCovered, $linesToBeUsed, $linesToBeIgnored);
163174

164175
$this->currentId = null;
@@ -455,7 +466,8 @@ private function addUncoveredFilesFromFilter(): void
455466
$uncoveredFile,
456467
$this->analyser()
457468
),
458-
self::UNCOVERED_FILES
469+
self::UNCOVERED_FILES,
470+
linesToBeIgnored: $this->linesToBeIgnored
459471
);
460472
}
461473
}

0 commit comments

Comments
 (0)