Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,15 @@ private function applyCoversAndUsesFilter(RawCodeCoverageData $rawData, array|fa

private function applyFilter(RawCodeCoverageData $data): void
{
if ($this->filter->isEmpty()) {
return;
}

foreach (array_keys($data->lineCoverage()) as $filename) {
if ($this->filter->isExcluded($filename)) {
$data->removeCoverageDataForFile($filename);
if (!$this->filter->isEmpty()) {
foreach (array_keys($data->lineCoverage()) as $filename) {
if ($this->filter->isExcluded($filename)) {
$data->removeCoverageDataForFile($filename);
}
}
}

$data->skipEmptyLines();
}

private function applyExecutableLinesFilter(RawCodeCoverageData $data): void
Expand Down
4 changes: 1 addition & 3 deletions src/Data/RawCodeCoverageData.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ private function __construct(array $lineCoverage, array $functionCoverage)
{
$this->lineCoverage = $lineCoverage;
$this->functionCoverage = $functionCoverage;

$this->skipEmptyLines();
}

public function clear(): void
Expand Down Expand Up @@ -251,7 +249,7 @@ public function removeCoverageDataForLines(string $filename, array $lines): void
*
* @see https://github.com/sebastianbergmann/php-code-coverage/issues/799
*/
private function skipEmptyLines(): void
public function skipEmptyLines(): void
{
foreach ($this->lineCoverage as $filename => $coverage) {
foreach ($this->getEmptyLinesForFile($filename) as $emptyLine) {
Expand Down
1 change: 1 addition & 0 deletions tests/tests/Data/RawCodeCoverageDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ public function testCoverageForFileWithInlineAnnotations(): void
33,
],
);
$coverage->skipEmptyLines();

$this->assertEquals(
[
Expand Down
Loading