Skip to content

Remove PHPStan 1 throw statement handling from two architecture rules - #170

Merged
schlessera merged 1 commit into
mainfrom
refactor/169-drop-phpstan1-throw-handling
Oct 23, 2026
Merged

schlessera merged 1 commit into
mainfrom
refactor/169-drop-phpstan1-throw-handling

Conversation

@schlessera

Copy link
Copy Markdown
Member

Closes #169

What changed

ExceptionsKeepCauseRule and ThrowOnlyPluginExceptionsRule no longer handle PhpParser\Node\Stmt\Throw_, the throw node of PHP-Parser 4 that only PHPStan 1 produced, and the comments explaining the PHPStan 1 form are gone. Since only Expr\Throw_ is left, ThrowOnlyPluginExceptionsRule now listens to that node type instead of every Node. What the rules report is unchanged. The manifest and docs did not mention the node type, so they needed no change.

Why this shape

The issue allowed narrowing the node type "if the rule tests still pass". They do, unchanged, so I took it: it removes the instanceof check and states what the rule inspects.

Proof

Not a fix, so there is no failing-first test; the existing rule tests pass unchanged. Scratch-copy check (in /tmp, nothing committed, composer.lock untouched): in a copy of the branch I removed vimeo/psalm, psalm/plugin-phpunit and humanmade/psalm-plugin-wordpress from composer.json and ran composer update nikic/php-parser vimeo/psalm psalm/plugin-phpunit humanmade/psalm-plugin-wordpress -W --ignore-platform-reqs, which moved nikic/php-parser v4.19.5 to v5.9.0. Then, on PHP 8.3.36 (php:8.3-cli):

vendor/bin/phpstan analyze --memory-limit=-1 --no-progress
  • With the two rule files from origin/main: 7 errors mentioning Throw_, matching the issue.
  • With the files from this branch: [OK] No errors.

On the committed lock, on PHP 8.3.36 in php:8.3-cli:

composer test   # OK (598 tests, 3457 assertions)
composer lint   # phpcs, phpstan, psalm, rule tests (132 tests) all pass

Checklist

  • composer test and composer lint pass locally, and CI is green on the current head.
  • Every acceptance criterion from the issue is met, or the gap is named below.
  • Nothing a generated plugin relies on changed, or the issue carries breaking and a ruling.
  • Docs and inline comments reflect the change, or nothing documented moved.

Anything left open

Nothing.

@schlessera schlessera added type: refactor Structure changes; behaviour does not. area: tests tests/php: unit and integration suites, fixtures. area: tooling composer.json, PHPCS, PHPStan, Psalm and Rector configuration. labels Oct 23, 2026
@schlessera
schlessera merged commit 61a9b00 into main Oct 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests tests/php: unit and integration suites, fixtures. area: tooling composer.json, PHPCS, PHPStan, Psalm and Rector configuration. type: refactor Structure changes; behaviour does not.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tooling: architecture rules still handle PHP-Parser 4 throw statements, and PHPStan only accepts that because Psalm 5 pins PHP-Parser 4

1 participant