Coverage API
This reference lists coverage maps and per-file line coverage values.
These signatures are the public API.
CoverageMap
Namespace: Greenlight\Coverage
Contains line coverage for source files in path order.
merge() combines covered and uncovered lines for each file. Covered lines
take priority. Merge order and repeated inputs do not change the result.
final readonly class CoverageMap
__construct()
public function __construct(array $files = [])
PHPDoc:
@param list<FileCoverage> $files duplicated paths are merged, covered wins
empty()
public static function empty(): self
files()
public function files(): array
PHPDoc:
@return array<non-empty-string, FileCoverage> keyed by file path, sorted by path
isEmpty()
public function isEmpty(): bool
merge()
public function merge(self $other): self
coveredLineTotal()
public function coveredLineTotal(): int
PHPDoc:
@return int<0, max>
executableLineTotal()
public function executableLineTotal(): int
PHPDoc:
@return int<0, max>
uncoveredLineTotal()
public function uncoveredLineTotal(): int
PHPDoc:
@return int<0, max>
totalPercentage()
Returns total covered lines as a percentage of executable lines.
An empty map has full coverage because it has no executable lines.
public function totalPercentage(): float
FileCoverage
Namespace: Greenlight\Coverage
The class stores both sets as sorted unique lists with no common members.
If a line is in both inputs, the covered input has priority. This rule
makes merge() commutative, associative, and idempotent.
final readonly class FileCoverage
$file
public string $file;
PHPDoc:
@var non-empty-string
$coveredLines
public array $coveredLines;
PHPDoc:
@var list<positive-int>
$uncoveredLines
public array $uncoveredLines;
PHPDoc:
@var list<positive-int>
__construct()
public function __construct(
string $file,
array $coveredLines,
array $uncoveredLines,
)
PHPDoc:
@param non-empty-string $file@param list<int> $coveredLines@param list<int> $uncoveredLines@throws \InvalidArgumentException if the file path is empty or a line number is not positive
executableLineCount()
public function executableLineCount(): int
PHPDoc:
@return int<0, max>
coveredLineCount()
public function coveredLineCount(): int
PHPDoc:
@return int<0, max>
lineHits()
Returns executable line hit counts in ascending line order.
public function lineHits(): array
PHPDoc:
@return array<positive-int, 0|1>
percentage()
Returns covered lines as a percentage of executable lines.
A file with no executable lines has full coverage.
public function percentage(): float
merge()
Merges coverage for the same file.
public function merge(self $other): self
PHPDoc:
@throws \LogicException if the file paths differ