Repository navigation
Build/Test Tools: Update PHPStan to 2.3.5 and document --fix - #15479
Draft
westonruter wants to merge 2 commits into
Draft
westonruter wants to merge 2 commits into
westonruter wants to merge 2 commits into
Conversation
The analysis of `phpstan.neon.dist` reports no errors with this release, and no baseline entry goes stale, so the baselines are unchanged. The phpstan-phpunit and phpstan-strict-rules extensions are already at their latest versions (2.1.1 each). The headline feature of 2.3.5 is `--fix`, which also removes stale `ignoreErrors` entries and `@phpstan-ignore` comments. Its adoption in the docs and CI follows separately. Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tnky3GdCg3QL5KeMvuQvwf Claude-Code-Session-Id: 5bac4eea-faaa-40e6-8440-b696b7773ba6
PHPStan 2.3.5 can fix stale ignores itself: `--fix` lowers a baseline entry's count that is now too high, removes an entry that matches nothing, and removes an `@phpstan-ignore` comment that no longer ignores anything. That is quicker than regenerating the baselines, since it reuses the result cache, and unlike regenerating it also clears stale inline ignores, which before had to be removed by hand. Verified against the per-identifier baselines: an inflated count was lowered back to its real value, and removing the last entry of a baseline left that file in place as `ignoreErrors: []`. Regenerating that one identifier then deleted the file and its `includes` entry. A run limited to some paths reports no stale ignores at all, so `--fix` has to be run on the whole tree. The README gains a section describing this, its caveats, and `--fix-ignored`. The CI step summary, the error annotation, and the pull request comment now suggest `--fix` first, with regenerating as the alternative that also retires an emptied baseline. Annotations of errors that PHPStan reports as fixable, which its JSON output now flags, also say how to fix them. That flag is left out of the results passed to the comment workflow, as tips are. A comment about errors not specific to a file is corrected too: since 2.3.5, an unmatched `ignoreErrors` entry without a path is reported against the config file it is in. Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tnky3GdCg3QL5KeMvuQvwf Claude-Code-Session-Id: 5bac4eea-faaa-40e6-8440-b696b7773ba6
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
westonruter
commented
Nov 8, 2026
| '>', | ||
| '> ```bash', | ||
| '> composer phpstan:baselines', | ||
| '> composer phpstan -- --fix', |
Member
Author
There was a problem hiding this comment.
Seems like there should be a phpstan:fix command.
westonruter
commented
Nov 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates PHPStan from 2.3.4 to 2.3.5, and documents its new
--fixoption as the quick way to update the baselines after fixing a baselined error.The phpstan-phpunit and phpstan-strict-rules extensions are already at their latest versions (2.1.1 each). With 2.3.5, the analysis of
phpstan.neon.distreports no errors and no stale baseline entries, so the baselines are unchanged.--fixfor stale ignoresPHPStan 2.3.5 marks errors it can fix itself with 🔧, and these include stale ignores.
composer phpstan -- --fix(ornpm run typecheck:php -- --fix) lowers a baseline entry's count that is now too high, removes an entry that matches nothing, and removes an@phpstan-ignorecomment that no longer ignores anything. That is quicker thancomposer phpstan:baselines, since it reuses the result cache. Unlike regenerating, it also clears stale inline ignores, which the CI messages previously said had to be removed by hand.Verified against the per-identifier baselines:
ignoreErrors: []. That still passes, andcomposer phpstan:baselines -- --identifier=…then deletes the file and itsincludesentry.--fixhas to be run on the whole tree.Changes
tests/phpstan/README.mdgains a section, "Removing stale entries with--fix", covering the above, the fact that it applies every fixable error the run reports, and--fix-ignored.::errorannotation, and the pull request comment now suggest--fixfirst, with regenerating as the alternative that also retires an emptied baseline.ignoreErrorsentry without a path is reported against the config file it is in, rather than as an error not specific to a file.Not adopted
base.neon: this only works when PHPStan runs on PHP 8.0+, and core's tooling still supports 7.4. The comments documenting each service inbase.neonare also worth keeping.--fix.Trac ticket: Core-65817
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5 (medium effort)
Used for: Researching the 2.3.5 changes, testing
--fixagainst the baselines, and writing the version bump, documentation, and workflow changes, all reviewed by me.This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.