Skip to content

chore: upgrade PHPStan 2.x + Rector 2.x#110

Merged
tonydspaniard merged 1 commit into
masterfrom
chore/96-phpstan-2x-upgrade
May 28, 2026
Merged

chore: upgrade PHPStan 2.x + Rector 2.x#110
tonydspaniard merged 1 commit into
masterfrom
chore/96-phpstan-2x-upgrade

Conversation

@tonydspaniard
Copy link
Copy Markdown
Member

Summary

Closes the PHPStan-2.x part of #96. PHPStan 2.x is version-locked to Rector 2.x (Rector 1.x pins phpstan ^1.12.5), so both are upgraded together.

  • composer.json: phpstan/phpstan ^1.12 → ^2.1, rector/rector ^1.2 → ^2.0.
  • Rector 2.x sweep (~94 files) — behaviour-preserving modernizations from the expanded rule sets: SafeDeclareStrictTypes (34), first-class-callable syntax (strlen(...)), explicit closure/array param types, ThrowWithPreviousException, removal of no-op ReflectionProperty::setAccessible() calls, redundant-cast removal, etc.
  • PHPStan baseline regenerated under 2.x: level 6 is stricter in 2.x, so the grandfathered count rises 51 → 80 errors — to be burned down later under Burn down PHPStan baseline and raise level 6 → 8 (Phase 4) #96 (the level is unchanged; this is just the 1.x→2.x move).

Manual corrections to Rector output

  • Pair::__get / PriorityNode::__get: Rector added : mixed but left a bare return; (a fatal with a typed return). Completed to return null; — faithful to the prior null-returning behaviour and the @return mixed|null docblock.
  • Skipped RemoveParentDelegatingConstructorRector globally: it removed Cookie::__construct(), which is not dead — it widens AbstractCookie's protected constructor to public. Restored the constructor and documented the skip in rector.php.

Test plan

  • composer cs — clean
  • composer stan (PHPStan 2.1) — [OK] No errors
  • vendor/bin/rector process --dry-run (Rector 2.4, full codebase) — clean and stable with cs-fixer (no tug-of-war)
  • composer test — 5555 tests; only the pre-existing local MongoSessionHandlerTest env errors (CI loads ext-mongodb)
  • composer validate --strict — valid

Note: the baseline was regenerated on PHP 8.5 locally; PHPStan analyses with phpVersion: 80300 so results should be deterministic on CI's PHP 8.3. CI will confirm.

PHPStan 2.x is version-locked to Rector 2.x (Rector 1.x pins phpstan
^1.12.5), so both move together:

- composer.json: phpstan/phpstan ^1.12 -> ^2.1, rector/rector ^1.2 -> ^2.0.
- Apply Rector 2.x across src/ and tests/ (~94 files): mostly cosmetic
  modernizations from the expanded rule sets — SafeDeclareStrictTypes,
  first-class-callable syntax, explicit closure/array param types,
  ThrowWithPreviousException, removal of no-op ReflectionProperty::setAccessible(),
  redundant-cast removal, etc. Behaviour-preserving; full test suite still green.
- regenerate phpstan-baseline.neon under 2.x: level 6 is stricter in 2.x, so the
  grandfathered count rises (51 -> 80 errors) to be burned down later under #96.

Manual corrections to Rector output:
- Pair::__get / PriorityNode::__get: Rector added `: mixed` but left a bare
  `return;`, which is a fatal with a typed return. Completed to `return null;`
  (faithful to the prior null-returning behaviour and the `@return mixed|null`).
- Skip RemoveParentDelegatingConstructorRector globally: it removed
  Cookie::__construct(), which is NOT dead — it widens AbstractCookie's protected
  constructor to public. Restored the constructor and documented the skip.
@tonydspaniard tonydspaniard merged commit 28c4291 into master May 28, 2026
3 checks passed
@tonydspaniard tonydspaniard deleted the chore/96-phpstan-2x-upgrade branch May 28, 2026 06:07
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.

1 participant