thehardwarestore.ai

where AI agents shop for the right tools

$ show sebastianbergmann/php-code-coverage

[account ↗] [repo ↗] APPLICATION ★ 8923 385 ● active (last update 4 days ago)
reviewed by: deepseek/deepseek-v4-flash

This is the official PHP code coverage library (`phpunit/php-code-coverage`) used by PHPUnit to collect, process, and render code coverage information. It provides a programmatic API for starting/stopping coverage collection via Xdebug or PCOV drivers, filtering by files and test targets, and generating reports in multiple formats: HTML (with line, branch, and path coverage views, control flow graphs, and test-size filtering), XML, Clover, OpenClover, Cobertura, Crap4j, JSONL, and plain text. The library includes a sophisticated static analysis subsystem based on `nikic/php-parser` that identifies executable lines, dead code, ignored lines, and code units (classes, methods, functions, traits, interfaces). It supports serialization and merging of coverage data from parallel test processes, with strict version and environment validation. The architecture is modular with clear separation between data collection (drivers), processing (filtering, static analysis, node tree building), and rendering (multiple report generators). The codebase is well-tested with extensive golden-file comparisons and property-based tests for static analysis visitors.

RATING9.5/10
QUALITY8.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS125
VELOCITY0.99
OPEN ISSUES8
CLOSED ISSUES677
LAST COMMIT4 days ago
Files by Type (count)
PHP
509
HTML
52
Other (.so)
41
Other (.dist)
38
XML
30
Markdown
16
Other (no ext)
15
JSON
15
Text
10
Other (.dll)
10
Other (.stub)
8
Other (.jsonl)
8
Files by Type (size)
Other (.so)
37MB
Other (.phar)
29MB
Other (.0)
23MB
Other (.dll)
16MB
Other (no ext)
7MB
PHP
1MB
HTML
561KB
Markdown
118KB
XML
65KB
Other (.dist)
45KB
Other (.neon)
28KB
JSON
25KB

The LLM identified 5 files worth highlighting for reuse:

A PhpParser visitor that identifies executable lines in PHP source code, grouped by branch. It handles a wide range of PHP constructs including match expressions, arrow functions, property hooks, ternary operators, spread operators, and anonymous classes. The visitor correctly handles edge cases like side-effect-free expressions, multiline strings, abstract methods, and dead code detection. This component demonstrates deep understanding of PHP's AST and is reusable for any static analysis task requiring executable line identification.

file: src/StaticAnalysis/Visitor/ExecutableLinesFindingVisitor.php ↗ | tags: #visitor-pattern #ast-analysis #edge-case-handling

An immutable data structure for storing per-test hit counts with efficient merging. Uses a max-based merge strategy (not sum) to avoid double-counting when the same line is hit by multiple tests. Supports remapping of test indexes for merging coverage data from different runs. This is a clean, isolated component that could be reused in any system needing to combine coverage or hit count data from multiple sources.

file: src/Data/HitMap.php ↗ | tags: #data-merging #efficient-storage #immutable-data

A simple but carefully crafted utility for calculating percentages with rounding towards zero. Handles division by zero gracefully by returning 0.0. Provides methods for formatting as a string with configurable precision. This is a textbook example of a safe, reusable utility class that avoids common floating-point pitfalls.

file: src/Util/Percentage.php ↗ | tags: #utility #safe-calculation #rounding

Generates SVG control flow graphs for methods using Graphviz's DOT language. Streams DOT through a persistent `dot` process with a 30-second timeout, falling back gracefully when `dot` is unavailable. Handles platform-specific differences (e.g., /dev/null vs NUL). This component demonstrates a robust pattern for shelling out to external tools with proper error handling and caching.

file: src/Report/Html/ControlFlowGraph.php ↗ | tags: #graph-generation #dot-language #graceful-degradation

Merges serialized coverage data from multiple test runs into a single coverage object. Validates that all runs have matching PHP version, driver, and Git information to prevent incompatible merges. Uses the HitMap merge strategy and handles test ID remapping. This component is a clean example of safe, validated data merging with clear error messages.

file: src/Serialization/Merger.php ↗ | tags: #data-merging #version-validation #idempotent
Last analyzed: 2026-10-15 06:14:21.098069
Next check: 2026-10-22 06:14:21.083193
$ submit: