PHP Coverage

This documentation was generated with the assistance of AI. Please report any inaccuracies.

Run a PHP project’s tests with a coverage driver enabled and report the exact, measured coverage for the classes or files the caller cares about, read from a Clover XML report. It only measures and reports: it never adds tests, edits code, or installs extensions unless asked to as a follow-up.

Purpose

iru-php-coverage replaces eyeballing the runner’s console coverage table with exact numbers. It reuses iru-php-test’s environment, runner, config and unit-versus-integration detection, picks a coverage driver (PCOV first, Xdebug in `coverage mode otherwise), writes --coverage-clover, and computes line coverage (coveredstatements / statements) and method coverage per target class, plus the uncovered line ranges for targets under the caller’s bar. It refuses to report a false 0%: with no driver it says "no coverage driver available" and how to install PCOV, and a target absent from the report is reported as outside the config’s <source>.

Purpose group

Plugin

Shipped by the iru-php plugin of the ai-catalog marketplace (install with /plugin install iru-php@ai-catalog; see Plugins).

Invocation

/iru-php-coverage
/iru-php-coverage <selector> [TargetClass1,TargetClass2,...]

Inputs

Argument Required Description Default

selector

No

Same syntax as iru-php-test: file, directory, --filter <pattern>, --testsuite <name>, --group <name>, -c <config>. A narrow selector undercounts classes covered by other suites, so a broader one is preferred when in doubt.

None — runs the whole suite and reports whole-project coverage.

TargetClass1,…​

No

Comma-separated short names or FQCNs (or files, for procedural WordPress/PrestaShop code) to report on.

Inferred from the selector by test-name convention (FooTest targets Foo); otherwise every class in the report.

Driver choice, in order: PCOV when loaded (fast, line coverage only; pcov.directory is overridden with -d pcov.directory=. when code lives outside src/, lib/ or app/), then Xdebug with XDEBUG_MODE=coverage (slower, the only driver for branch and path coverage via --path-coverage), else stop. php artisan test and --parallel start a child process that does not inherit -d options, so the runner binary is called directly or the driver is loaded through PHP_INI_SCAN_DIR.

Outputs

  • A summary naming the driver and environment/runner, then per target class (or file) the line coverage percentage and method coverage, computed from the Clover numbers; branch and path coverage only when collected with Xdebug, and an explicit "unavailable" with PCOV.

  • For targets under the user’s bar, the uncovered line ranges (for example uncovered: 17, 24-31).

  • A clear verdict per target and for the total when a bar such as "at least 80%" was given.

  • Missing driver, missing environment, or a target outside <source> is reported with the failing command and the fix instead of a percentage. Numbers from a failing test run are labeled as such.

  • The Clover and text reports are written under build/iru-php-coverage-* and deleted afterwards. No source or test code is modified.

Execution flow

flowchart TD A["Start /iru-php-coverage\n(selector, optional targets)"] --> B["Step 1: detect environment,\nrunner, configs as iru-php-test"] B --> C{"Environment usable?"} C -- no --> D["Stop: report missing\nenvironment"] C -- yes --> E["Step 2: determine target\nclasses or files"] E --> F["Step 3: detect driver\nwith php -m"] F --> G{"PCOV or Xdebug\navailable?"} G -- neither --> H["Stop: no coverage driver\navailable, how to install PCOV"] G -- yes --> I["Step 4: run tests with\n--coverage-clover in build/"] I --> J{"Run failed or\nno Clover file?"} J -- yes --> K["Report the failure,\nnever read a stale report"] J -- no --> L["Step 5: parse Clover XML:\nline and method coverage,\nuncovered ranges"] L --> M["Delete generated reports"] M --> N["Step 6: report per-target\ncoverage versus the bar"]

Dependencies

Invokes

None — iru-php-coverage is a leaf skill. It reuses `iru-php-test’s detection rules by convention (Steps 1–3) but runs its own commands and does not call that skill.

Invoked by

None — it spawns no agents itself. Calling skills normally run it inside an iru-gate-runner sub-agent.

Source

SKILL.md on GitHub — the file this page was generated from.