sebastianbergmann /php-code-coverage
Library that provides collection, processing, and rendering functionality for PHP code coverage information.
★ 8,924⑂ 383👁 51⑃ 694● 685▤ 75
+0
日增长
8,924
stars
383
forks
51
watchers
694
prs
685
issues
75
releases
README
phpunit/php-code-coverage
Provides collection, processing, and rendering functionality for PHP code coverage information.
Installation
You can add this library as a local, per-project dependency to your project using Composer:
composer require phpunit/php-code-coverage
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
composer require --dev phpunit/php-code-coverage
Usage
Collecting code coverage data and generating a report
php
includeFiles(
[
'/path/to/file.php',
'/path/to/another_file.php',
],
);
$coverage = new CodeCoverage(
(new DriverSelector)-forLineCoverage($filter),
$filter,
);
$coverage-start('');
// ...
$coverage-stop();
ReportFacade::fromObject($coverage)-renderOpenClover('/tmp/openclover.xml');
Generating a report from serialized code coverage data
php
unserialize('/path/to/coverage.php');
ReportFacade::fromSerializedData($data)-renderOpenClover('/tmp/openclover.xml');Top issues
#386Refactor how filtering works4 comments · 2015-09-23#1257Never-executed `match` default arm reported as covered when the `match` is the operand of `return`2 comments · 2026-07-14#1056Add branch coverage statistics to XML report output1 comments · 2024-12-13#1163Dependency Dashboard0 comments · 2026-05-16#1083identifying uncovered (executable) lines from the XML export0 comments · 2025-07-28
Latest release
phpunit/php-code-coverage 14.5.2 14.5.2 2026-11-09Fixed 1379: Opening line of a match nested in an arm of a match that is compiled to a jump table is treated as executable 1380: Opening line of a match is reported as not covered when merging coverage data from processes that compiled the file differently