finds.dev← search

// the find

sebastianbergmann/php-code-coverage

★ 8,933 · PHP · BSD-3-Clause · updated Jul 2026

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

The PHP library behind PHPUnit's coverage reporting — collects line, branch, and path coverage data via Xdebug or PCOV, then renders it as HTML, Clover XML, Cobertura, text, or a few other formats. If you're running PHPUnit, you're already using this. It's not a library you'd normally reach for directly unless you're building a CI tool or a custom test runner.

The driver abstraction over Xdebug and PCOV is clean — you get branch and path coverage with PCOV if it supports it, falls back to Xdebug gracefully. Static analysis caching via `CachingSourceAnalyser` means repeated runs don't re-parse the AST from scratch, which matters on large codebases. The serialization layer lets you collect coverage in parallel processes and merge it afterward, which is the only sane way to handle parallel test suites. Exception types are granular enough that you can actually distinguish 'driver not available' from 'coverage data corrupted' without string-matching error messages.

Branch and path coverage require Xdebug, and Xdebug is slow — there's no PCOV path for branch-level data, so teams on fast CI setups are stuck choosing between speed and coverage depth. The HTML report bundles Bootstrap 4, jQuery, and Octicons as vendored static files, making the output unnecessarily heavy and difficult to restyle without forking templates. The `@covers` / `@uses` annotation-based targeting system is PHPUnit-specific coupling baked into this library's internals, which means using it standalone outside PHPUnit requires understanding PHPUnit's test metadata model. There's no streaming or incremental output — for very large codebases the HTML generation loads the full coverage graph into memory at once.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →