sebastianbergmann /php-code-coverage

Library that provides collection, processing, and rendering functionality for PHP code coverage information.

★ 8,924⑂ 383👁 51⑃ 694● 685▤ 75
PHPBSD-3-ClauseCreated 2009-05-28
Download: phpunit/php-code-coverage 14.5.2phpunit/php-code-coverage-14.5.2 ↓14.5.22026-11-09
+0
Daily
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

Latest release

phpunit/php-code-coverage 14.5.2 14.5.2 2026-11-09
Fixed

 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

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON