Skip to content

chore(legacy): upgrade PHPStan to 2.x#106

Open
pjcdawkins wants to merge 1 commit into
mainfrom
worktree-phpstan-2.x
Open

chore(legacy): upgrade PHPStan to 2.x#106
pjcdawkins wants to merge 1 commit into
mainfrom
worktree-phpstan-2.x

Conversation

@pjcdawkins

Copy link
Copy Markdown
Contributor

What

Upgrades the legacy PHP CLI's static analysis to PHPStan 2.x (2.2.2), keeping level 8.

Changes

  • Make phpstan/phpstan an explicit dev dependency at ^2.1. It was previously pulled in transitively at 1.x via rector/rector.
  • Bump rector/rector to ^2.0. Rector ^1.2 requires phpstan ^1.12.5, which conflicts with phpstan 2.x, so rector has to move too.
  • 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 that migration is complete. The custom rules in src/Rector are unchanged and still run under rector 2.x.
  • Type the loose JSON payload properties in phpstan-stubs/Activity.stub as array<string, mixed>, since PHPStan 2.x requires value types on iterables.
  • Regenerate phpstan-baseline.neon for 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::testWelcomeOnLocalContainer errors with "Configuration not defined: detection.git_remote_name". It fails identically on main without these changes (verified by stashing the diff), so it is left for a separate fix.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings June 14, 2026 09:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/phpstan as an explicit dev dependency and bump rector/rector to 2.x.
  • Remove deprecated/removed Rector rule configuration (MethodCallToPropertyFetchRector) from legacy/rector.php.
  • Update PHPStan stubs and regenerate phpstan-baseline.neon for 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.

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.

2 participants