Skip to content

Skip dead lines in .cov files - #91

Merged
janedbal merged 2 commits into
masterfrom
jn-fix-cov-dead-lines
Oct 20, 2026
Merged

janedbal merged 2 commits into
masterfrom
jn-fix-cov-dead-lines

Conversation

@janedbal

Copy link
Copy Markdown
Member

php-code-coverage stores null for a dead (unreachable) line in .cov files. PhpUnitCoverageExtractor accepts only arrays, so it throws on null. Every command that reads .cov (check, patch-coverage, merge, convert) then stops with an internal error.

One dead line in the coverage scope is enough. Example from a real PHPUnit 13 + Xdebug run:

switch ($a) {
    case 'x':
        return 1;
        break;    // dead line
}
Dead.php => {"10":[],"11":[],"12":null,"14":[]}

‼️  Internal error: LogicException: Invalid coverage file: 'dead3.cov'. Expected array under Dead.php and #12, got null

The null comes in two cases. If no test runs the file, php-code-coverage finds dead lines by static analysis. If a test runs the file, Xdebug reports the line as dead.

Now the extractor skips null lines, as the PHPUnit Clover and Cobertura reports do. A dead line is not executable, so no rule can require its coverage.

  • New test with a null line. It fails on master.

Co-Authored-By: Claude Code

php-code-coverage stores null for a dead (unreachable) line, for
example a break after a return in a switch. PhpUnitCoverageExtractor
accepted only arrays and threw a LogicException on null. So check,
patch-coverage, merge and convert stopped with an internal error for
every .cov file that contains one such line.

The extractor now skips null lines, as the PHPUnit Clover and Cobertura
reports do. A dead line is not executable, so no rule can require its
coverage.

Co-Authored-By: Claude Code
@janedbal
janedbal marked this pull request as ready for review October 20, 2026 07:47
@janedbal
janedbal merged commit d95e331 into master Oct 20, 2026
31 checks passed
@janedbal
janedbal deleted the jn-fix-cov-dead-lines branch October 20, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant