Skip to content

fix: support the php-code-coverage 14.3 line coverage shape - #39

Open
maks-oleksyuk wants to merge 1 commit into
pestphp:5.xfrom
maks-oleksyuk:pr/code-coverage-14.3
Open

fix: support the php-code-coverage 14.3 line coverage shape#39
maks-oleksyuk wants to merge 1 commit into
pestphp:5.xfrom
maks-oleksyuk:pr/code-coverage-14.3

Conversation

@maks-oleksyuk

@maks-oleksyuk maks-oleksyuk commented Aug 7, 2026

Copy link
Copy Markdown

php-code-coverage 14.3 changed the shape of ProcessedCodeCoverageData::lineCoverage(). A line used to hold the list of test ids covering it; it now holds hit counts keyed by an index into a separate list returned by testIds().

Mutation testing reads that structure to work out which tests cover a mutation. Against 14.3 it receives integers where strings are expected, and every run aborts on the first covered mutation with preg_match(): Argument #2 ($subject) must be of type string, int given.

phpunit/phpunit allows phpunit/php-code-coverage: ^14.2.3, so both shapes are in circulation and both have to keep working.

What changed

MutationTestRunner::coveredLines() normalises the coverage data into [file => [line => [testId, ...]]] before anything consumes it. testIdsCoveringLine() tells the two shapes apart by their structure rather than by a version check: a string value is a test id from 14.2 and earlier, an integer key is an index into the ids reported by 14.3.

This also clears the two pre-existing PHPStan errors on MutationTestRunner, which were the same mismatch surfacing statically.

Testing

tests/Unit/Tester/MutationTestRunnerTest.php covers both shapes, an index with no matching test id, and a line nothing covers.

Follow-ups

Mutation sharding builds on this fix in #40 and #41, and on pestphp/pest#1829.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@devfake

devfake commented Aug 8, 2026

Copy link
Copy Markdown

would be great to have this merged. the error is preg_match(): Argument #2 ($subject) must be of type string, int given. current fix is to downgrade to phpunit/php-code-coverage:14.2.4.

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.

2 participants