Skip to content

feat(php): add PHPStan analyse filter module#1110

Closed
LucianoVandi wants to merge 1 commit into
rtk-ai:developfrom
LucianoVandi:feat/phpstan-filter-module
Closed

feat(php): add PHPStan analyse filter module#1110
LucianoVandi wants to merge 1 commit into
rtk-ai:developfrom
LucianoVandi:feat/phpstan-filter-module

Conversation

@LucianoVandi

Copy link
Copy Markdown
Contributor

Summary

Adds a new php ecosystem module with a filter for PHPStan.

What it does

  • injects --error-format=json for analyse / analyze
  • groups errors by file, sorted by error count descending
  • shows up to 10 files × 5 messages each, with truncation hints
  • auto-detects vendor/bin/phpstan before falling back to phpstan on PATH
  • falls back to text parsing when a custom --error-format is requested
  • falls back safely to fallback_tail() if JSON parsing fails
  • leaves utility commands like --version, list, and clear-result-cache as real passthrough

Rewrite coverage

Adds rewrite support for:

  • phpstan analyse
  • vendor/bin/phpstan analyse
  • ./vendor/bin/phpstan analyse
  • php vendor/bin/phpstan analyse

Tests

Added module tests covering:

  • zero-error and error JSON output
  • truncation behavior
  • token savings on a realistic fixture
  • malformed / empty output handling
  • text fallback behavior
  • classify / rewrite behavior, including negative coverage for utility commands

Validation

cargo fmt --all --check
cargo clippy --all-targets
cargo test --all

Notes

Snapshot tests were not added because insta is not currently a repo dependency. This PR uses explicit assertions and fixture-based coverage instead.

@CLAassistant

CLAassistant commented Apr 9, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@LucianoVandi

Copy link
Copy Markdown
Contributor Author

Hi! Following up on this PR.

I know maintainers are busy, so no pressure at all! I just wanted to check whether this contribution looks useful / in scope, and whether there's anything I should adjust to make review easier.

I use PHPStan daily, so I'm happy to adjust this if needed. Thanks!

iliaal added a commit to iliaal/rtk that referenced this pull request Apr 30, 2026
…t, paratest, ecs, pint, artisan)

Consolidates three stalled upstream PRs plus a new .phpt filter and Pint
support into one coherent PHP ecosystem module:

- `rtk php` + `rtk artisan`: syntax check (-l) and Laravel artisan wrapper
- `rtk phpunit`: structured-state parser; aggregate counts + bounded failure list
  (sourced from rtk-ai#874, refactored to use runner::run_filtered and strip emoji)
- `rtk phpstan`: typed serde::Deserialize parser for --error-format=json;
  groups errors by file, sorts by count desc; handles utility commands
  (--version, list, clear-result-cache) as passthrough
  (sourced from rtk-ai#1110, strip emoji in success path)
- `rtk pest` + `rtk paratest`: shared test_output helper (from rtk-ai#1246)
- `rtk ecs` + `rtk pint`: code style fixers; pint uses --format=json for
  structured per-file rule counts
- `rtk phpt`: wraps `php run-tests.php` for php-src and PHP extensions;
  collapses per-test PASS chatter (99.5% byte reduction on a 5322-test run)

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
so one rule covers every Composer layout.

Sources:
- rtk-ai#1246 (aaronflorey): php, artisan, ecs, pest, paratest, test_output,
  utils, composer_bin_dirs + registry normalization. phpunit and phpstan stubs
  replaced with deeper implementations below.
- rtk-ai#874 (Beninho): phpunit state-machine parser (ported).
- rtk-ai#1110 (LucianoVandi): phpstan typed parser (emoji stripped).
- New: pint_cmd.rs, phpt_cmd.rs.

1744 tests pass (1683 baseline + 61 new).
iliaal added a commit to iliaal/rtk that referenced this pull request May 9, 2026
…t, paratest, ecs, pint, artisan)

Consolidates three stalled upstream PRs plus a new .phpt filter and Pint
support into one coherent PHP ecosystem module:

- `rtk php` + `rtk artisan`: syntax check (-l) and Laravel artisan wrapper
- `rtk phpunit`: structured-state parser; aggregate counts + bounded failure list
  (sourced from rtk-ai#874, refactored to use runner::run_filtered and strip emoji)
- `rtk phpstan`: typed serde::Deserialize parser for --error-format=json;
  groups errors by file, sorts by count desc; handles utility commands
  (--version, list, clear-result-cache) as passthrough
  (sourced from rtk-ai#1110, strip emoji in success path)
- `rtk pest` + `rtk paratest`: shared test_output helper (from rtk-ai#1246)
- `rtk ecs` + `rtk pint`: code style fixers; pint uses --format=json for
  structured per-file rule counts
- `rtk phpt`: wraps `php run-tests.php` for php-src and PHP extensions;
  collapses per-test PASS chatter (99.5% byte reduction on a 5322-test run)

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
so one rule covers every Composer layout.

Sources:
- rtk-ai#1246 (aaronflorey): php, artisan, ecs, pest, paratest, test_output,
  utils, composer_bin_dirs + registry normalization. phpunit and phpstan stubs
  replaced with deeper implementations below.
- rtk-ai#874 (Beninho): phpunit state-machine parser (ported).
- rtk-ai#1110 (LucianoVandi): phpstan typed parser (emoji stripped).
- New: pint_cmd.rs, phpt_cmd.rs.

1744 tests pass (1683 baseline + 61 new).
iliaal added a commit to iliaal/rtk that referenced this pull request May 17, 2026
…t, paratest, ecs, pint, artisan)

Consolidates three stalled upstream PRs plus a new .phpt filter and Pint
support into one coherent PHP ecosystem module:

- `rtk php` + `rtk artisan`: syntax check (-l) and Laravel artisan wrapper
- `rtk phpunit`: structured-state parser; aggregate counts + bounded failure list
  (sourced from rtk-ai#874, refactored to use runner::run_filtered and strip emoji)
- `rtk phpstan`: typed serde::Deserialize parser for --error-format=json;
  groups errors by file, sorts by count desc; handles utility commands
  (--version, list, clear-result-cache) as passthrough
  (sourced from rtk-ai#1110, strip emoji in success path)
- `rtk pest` + `rtk paratest`: shared test_output helper (from rtk-ai#1246)
- `rtk ecs` + `rtk pint`: code style fixers; pint uses --format=json for
  structured per-file rule counts
- `rtk phpt`: wraps `php run-tests.php` for php-src and PHP extensions;
  collapses per-test PASS chatter (99.5% byte reduction on a 5322-test run)

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
so one rule covers every Composer layout.

Sources:
- rtk-ai#1246 (aaronflorey): php, artisan, ecs, pest, paratest, test_output,
  utils, composer_bin_dirs + registry normalization. phpunit and phpstan stubs
  replaced with deeper implementations below.
- rtk-ai#874 (Beninho): phpunit state-machine parser (ported).
- rtk-ai#1110 (LucianoVandi): phpstan typed parser (emoji stripped).
- New: pint_cmd.rs, phpt_cmd.rs.

1744 tests pass (1683 baseline + 61 new).
iliaal added a commit to iliaal/rtk that referenced this pull request May 17, 2026
…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.
iliaal added a commit to iliaal/rtk that referenced this pull request May 30, 2026
…t, paratest, ecs, pint, artisan)

Consolidates three stalled upstream PRs plus a new .phpt filter and Pint
support into one coherent PHP ecosystem module:

- `rtk php` + `rtk artisan`: syntax check (-l) and Laravel artisan wrapper
- `rtk phpunit`: structured-state parser; aggregate counts + bounded failure list
  (sourced from rtk-ai#874, refactored to use runner::run_filtered and strip emoji)
- `rtk phpstan`: typed serde::Deserialize parser for --error-format=json;
  groups errors by file, sorts by count desc; handles utility commands
  (--version, list, clear-result-cache) as passthrough
  (sourced from rtk-ai#1110, strip emoji in success path)
- `rtk pest` + `rtk paratest`: shared test_output helper (from rtk-ai#1246)
- `rtk ecs` + `rtk pint`: code style fixers; pint uses --format=json for
  structured per-file rule counts
- `rtk phpt`: wraps `php run-tests.php` for php-src and PHP extensions;
  collapses per-test PASS chatter (99.5% byte reduction on a 5322-test run)

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
so one rule covers every Composer layout.

Sources:
- rtk-ai#1246 (aaronflorey): php, artisan, ecs, pest, paratest, test_output,
  utils, composer_bin_dirs + registry normalization. phpunit and phpstan stubs
  replaced with deeper implementations below.
- rtk-ai#874 (Beninho): phpunit state-machine parser (ported).
- rtk-ai#1110 (LucianoVandi): phpstan typed parser (emoji stripped).
- New: pint_cmd.rs, phpt_cmd.rs.

1744 tests pass (1683 baseline + 61 new).
iliaal added a commit to iliaal/rtk that referenced this pull request May 30, 2026
…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.
iliaal added a commit to iliaal/rtk that referenced this pull request Jun 9, 2026
…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.
iliaal added a commit to iliaal/rtk that referenced this pull request Jun 9, 2026
…t, paratest, ecs, pint, artisan)

Consolidates three stalled upstream PRs plus a new .phpt filter and Pint
support into one coherent PHP ecosystem module:

- `rtk php` + `rtk artisan`: syntax check (-l) and Laravel artisan wrapper
- `rtk phpunit`: structured-state parser; aggregate counts + bounded failure list
  (sourced from rtk-ai#874, refactored to use runner::run_filtered and strip emoji)
- `rtk phpstan`: typed serde::Deserialize parser for --error-format=json;
  groups errors by file, sorts by count desc; handles utility commands
  (--version, list, clear-result-cache) as passthrough
  (sourced from rtk-ai#1110, strip emoji in success path)
- `rtk pest` + `rtk paratest`: shared test_output helper (from rtk-ai#1246)
- `rtk ecs` + `rtk pint`: code style fixers; pint uses --format=json for
  structured per-file rule counts
- `rtk phpt`: wraps `php run-tests.php` for php-src and PHP extensions;
  collapses per-test PASS chatter (99.5% byte reduction on a 5322-test run)

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
so one rule covers every Composer layout.

Sources:
- rtk-ai#1246 (aaronflorey): php, artisan, ecs, pest, paratest, test_output,
  utils, composer_bin_dirs + registry normalization. phpunit and phpstan stubs
  replaced with deeper implementations below.
- rtk-ai#874 (Beninho): phpunit state-machine parser (ported).
- rtk-ai#1110 (LucianoVandi): phpstan typed parser (emoji stripped).
- New: pint_cmd.rs, phpt_cmd.rs.

1744 tests pass (1683 baseline + 61 new).
iliaal added a commit to iliaal/rtk that referenced this pull request Jun 18, 2026
…t, paratest, ecs, pint, artisan)

Consolidates three stalled upstream PRs plus a new .phpt filter and Pint
support into one coherent PHP ecosystem module:

- `rtk php` + `rtk artisan`: syntax check (-l) and Laravel artisan wrapper
- `rtk phpunit`: structured-state parser; aggregate counts + bounded failure list
  (sourced from rtk-ai#874, refactored to use runner::run_filtered and strip emoji)
- `rtk phpstan`: typed serde::Deserialize parser for --error-format=json;
  groups errors by file, sorts by count desc; handles utility commands
  (--version, list, clear-result-cache) as passthrough
  (sourced from rtk-ai#1110, strip emoji in success path)
- `rtk pest` + `rtk paratest`: shared test_output helper (from rtk-ai#1246)
- `rtk ecs` + `rtk pint`: code style fixers; pint uses --format=json for
  structured per-file rule counts
- `rtk phpt`: wraps `php run-tests.php` for php-src and PHP extensions;
  collapses per-test PASS chatter (99.5% byte reduction on a 5322-test run)

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
so one rule covers every Composer layout.

Sources:
- rtk-ai#1246 (aaronflorey): php, artisan, ecs, pest, paratest, test_output,
  utils, composer_bin_dirs + registry normalization. phpunit and phpstan stubs
  replaced with deeper implementations below.
- rtk-ai#874 (Beninho): phpunit state-machine parser (ported).
- rtk-ai#1110 (LucianoVandi): phpstan typed parser (emoji stripped).
- New: pint_cmd.rs, phpt_cmd.rs.

1744 tests pass (1683 baseline + 61 new).
iliaal added a commit to iliaal/rtk that referenced this pull request Jun 26, 2026
…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.
@KuSh

KuSh commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Hi, thanks for your PR. This has been superseded by #1649, and you’ve been properly credited there.

@KuSh KuSh closed this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants