Skip to content

feat(php): consolidated PHP tooling (php, artisan, phpunit, phpstan, pest, paratest, ecs, pint)#1649

Open
iliaal wants to merge 3 commits into
rtk-ai:developfrom
iliaal:feat/php-tooling
Open

feat(php): consolidated PHP tooling (php, artisan, phpunit, phpstan, pest, paratest, ecs, pint)#1649
iliaal wants to merge 3 commits into
rtk-ai:developfrom
iliaal:feat/php-tooling

Conversation

@iliaal
Copy link
Copy Markdown

@iliaal iliaal commented Apr 30, 2026

Summary

Consolidates the open and closed PHP-tooling work into a single PR against develop, omitting .phpt (which has its own PR #1503).

This PR adds eight rtk subcommands for PHP test runners and code tooling: php, artisan, phpunit, phpstan, pest, paratest, ecs, pint. Output compression in the 60% to 95% range per tool, structured parsers where possible (PHPUnit state machine, PHPStan typed JSON, Pint per-file rule counts).

Credits to original authors

  • @aaronflorey (rtk-ai/rtk#1246, self-closed 2026-04-26): php, artisan, ecs, pest, paratest, test_output, utils, composer_bin_dirs, registry normalization for Composer custom-bin-dir layouts.
  • @Beninho (rtk-ai/rtk#874, open): phpunit state-machine parser. I ported it into the consolidated module, switched it to runner::run_filtered, and stripped emoji from output.
  • @LucianoVandi (rtk-ai/rtk#1110, open): phpstan typed serde::Deserialize parser for --error-format=json. Groups errors by file, sorts by count descending; passes utility commands (--version, list, clear-result-cache) through unchanged. I stripped emoji from the success output.
  • New work: pint (Laravel Pint code-style fixer) using --format=json for structured per-file rule counts.

If the maintainers prefer this consolidation, close the three separate PRs in favor of this one. If they prefer the originals, close this PR and let the per-tool PRs continue independently. Either is fine with me.

Composer custom-bin-dir support

composer_bin_dirs() reads COMPOSER_BIN_DIR and composer.json's config.bin-dir, so tools/bin/phpunit classifies identically to vendor/bin/phpunit. registry.rs normalizes tool paths before matching, so a single rule covers the standard Composer layouts.

@pszymkowiak pszymkowiak added effort-large Plusieurs jours, nouveau module enhancement New feature or request labels Apr 30, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

Type feature
🟡 Risk medium

Summary

Adds eight new rtk subcommands for PHP tooling (php, artisan, phpunit, phpstan, pest, paratest, ecs, pint) with structured output parsers and compression. Consolidates work from three prior PRs by different authors into a single module, including shared test output filtering, Composer custom-bin-dir support, and registry normalization.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #1503, #1246, #874, #1110


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@pierresh
Copy link
Copy Markdown

pierresh commented May 1, 2026

Hi,
Thanks a lot for this consolidated PHP tooling. I tested it, and it works well. Just 2 suggestions: to add Behat and Rector as they are both popular tools in the PHP world.

@iliaal
Copy link
Copy Markdown
Author

iliaal commented May 2, 2026

Hi, Thanks a lot for this consolidated PHP tooling. I tested it, and it works well. Just 2 suggestions: to add Behat and Rector as they are both popular tools in the PHP world.

Can be added maybe as a follow-up, PR is already quite big, but 100% a good idea.

@iliaal
Copy link
Copy Markdown
Author

iliaal commented May 3, 2026

Added f9e139a on top of this branch: swaps the make filter from max_lines = 50 (head-only) to head_lines = 10 + tail_lines = 40, so make test runs (e.g. PHPT, which puts ~17000 progress lines before the pass/fail summary) keep both the prologue and the trailing summary instead of dropping the latter.

Companion fix at the recovery layer: #1696 — same head-bias bug in write_tee_file, where the tee log capped at 1MB by keeping raw[..1MB]. With both landed, tail-heavy output survives at the filter and at the fallback log.

@iliaal iliaal force-pushed the feat/php-tooling branch from f9e139a to a944865 Compare May 17, 2026 15:58
iliaal added 3 commits May 29, 2026 21:36
…pest, paratest, ecs, pint)

Consolidates the PHP-tooling work from three upstream PRs plus a new
Pint module, leaving phpt to its own PR (rtk-ai#1503).

- rtk php / rtk artisan: syntax check (-l) and Laravel artisan wrapper.
- rtk phpunit: structured-state parser, aggregate counts, bounded
  failure list. Uses runner::run_filtered.
- rtk phpstan: typed serde::Deserialize parser for --error-format=json,
  groups errors by file, sorts by count desc. Utility commands
  (--version, list, clear-result-cache) pass through unchanged.
- rtk pest / rtk paratest: shared test_output helper.
- rtk ecs / rtk pint: code-style fixers; pint uses --format=json for
  structured per-file rule counts.

Composer custom-bin-dir detection: composer_bin_dirs() reads
COMPOSER_BIN_DIR and composer.json config.bin-dir, so tools/bin/phpunit
classifies identically to vendor/bin/phpunit. registry.rs normalizes
tool paths before matching.

Sources:
- rtk-ai#1246 (aaronflorey, self-closed): php, artisan, ecs, pest,
  paratest, test_output, utils, composer_bin_dirs, registry normalization.
- rtk-ai#874 (Beninho, open): phpunit state-machine parser.
- rtk-ai#1110 (LucianoVandi, open): phpstan typed parser.
- New: pint_cmd.rs.

Tests: discover::registry 253 pass; cmds::php 36 pass; cargo build
--release 0 errors; cargo fmt --check clean.
The make filter used max_lines=50, implemented as head-only truncation in
toml_filter. For commands like 'make test' running PHPT (~17000 progress
lines followed by a pass/fail summary), the cap discarded exactly the
useful part — the tail.

Switch to head_lines=10 + tail_lines=40 so both the build prologue and
the final summary survive, with a '... (N lines omitted)' marker in the
middle. Token savings on long outputs remain >60%; existing inline tests
still pass and a new tail-preservation test guards the behaviour.
Upstream develop changed `rewrite_command` to take 3 args
(cmd, excluded, transparent_prefixes). The PHP tooling tests that
don't care about transparent prefixes now use the existing
`rewrite_command_no_prefixes` helper instead.
@iliaal iliaal force-pushed the feat/php-tooling branch from a944865 to 6ba52ae Compare May 30, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort-large Plusieurs jours, nouveau module enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants