chore(legacy): upgrade PHPStan to 2.x#106
Open
pjcdawkins wants to merge 1 commit into
Open
Conversation
Make phpstan/phpstan an explicit dev dependency at ^2.1. It was previously pulled in transitively at 1.x via rector/rector. rector/rector ^1.2 requires phpstan ^1.12.5, which conflicts with phpstan 2.x, so bump rector to ^2.0 as well. Rector 2.x removed the built-in MethodCallToPropertyFetchRector, so drop the two configured uses of it from rector.php; those were one-time migration helpers ($this->api()/$this->config() to property access) and the migration is complete. The custom Rector rules in src/Rector are unchanged and still run under rector 2.x. Fix the Activity stub for PHPStan 2.x, which requires value types on iterables: type the loose JSON payload properties as array<string, mixed>. Regenerate phpstan-baseline.neon for the stricter level-8 rules added in PHPStan 2.x. The level (8) is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Upgrades the legacy PHP CLI’s static analysis and refactoring tooling to PHPStan 2.x and Rector 2.x, updating configuration/stubs and regenerating the PHPStan baseline to keep analysis at level 8.
Changes:
- Add
phpstan/phpstanas an explicit dev dependency and bumprector/rectorto 2.x. - Remove deprecated/removed Rector rule configuration (
MethodCallToPropertyFetchRector) fromlegacy/rector.php. - Update PHPStan stubs and regenerate
phpstan-baseline.neonfor PHPStan 2.x.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
legacy/rector.php |
Drops removed Rector transform configuration and unused imports, keeping only supported rules. |
legacy/phpstan-stubs/Activity.stub |
Adds iterable value types (array<string, mixed>) required by PHPStan 2.x. |
legacy/phpstan-baseline.neon |
Regenerated baseline to reflect PHPStan 2.x rule set/identifiers at level 8. |
legacy/composer.json |
Adds explicit PHPStan dev dependency and bumps Rector constraint to ^2.0. |
legacy/composer.lock |
Locks updated versions for PHPStan (2.2.2) and Rector (2.4.5) and related metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
What
Upgrades the legacy PHP CLI's static analysis to PHPStan 2.x (2.2.2), keeping level 8.
Changes
phpstan/phpstanan explicit dev dependency at^2.1. It was previously pulled in transitively at 1.x viarector/rector.rector/rectorto^2.0. Rector^1.2requires phpstan^1.12.5, which conflicts with phpstan 2.x, so rector has to move too.MethodCallToPropertyFetchRector, so drop the two configured uses of it fromrector.php. Those were one-time migration helpers ($this->api()/$this->config()to property access) and that migration is complete. The custom rules insrc/Rectorare unchanged and still run under rector 2.x.phpstan-stubs/Activity.stubasarray<string, mixed>, since PHPStan 2.x requires value types on iterables.phpstan-baseline.neonfor the stricter level-8 rules added in PHPStan 2.x.Verification
make lint(php-cs-fixer + phpstan 2.x): passes.rector process --dry-run: config loads and custom rules run.Note
One pre-existing legacy test failure is unrelated to this change:
WelcomeCommandTest::testWelcomeOnLocalContainererrors with "Configuration not defined: detection.git_remote_name". It fails identically onmainwithout these changes (verified by stashing the diff), so it is left for a separate fix.🤖 Generated with Claude Code