Skip to content

Fix rector CI step broken by phpstan 2.2.6 - #19569

Merged
dereuromark merged 1 commit into
5.xfrom
ci-fix-rector-phpstan-2.2.6
Jul 28, 2026
Merged

dereuromark merged 1 commit into
5.xfrom
ci-fix-rector-phpstan-2.2.6

Conversation

@dereuromark

Copy link
Copy Markdown
Member

The Coding Standard & Static Analysis job has been red on every PR since 2026-07-26, and it is not caused by any of those PRs.

What breaks

composer rector-check dies before it analyzes anything:

PHP Fatal error:  Uncaught Rector\Exception\Reflection\MissingPrivatePropertyException:
Property "$container" was not found in "PHPStan\Parser\RichParser" class
in vendor/rector/rector/src/Util/Reflection/PrivatesAccessor.php:82
Script vendor/bin/rector process --dry-run handling the rector-check event returned with error code 255

Why

rector-setup pins rector/rector:"~2.4.0". Rector 2.4.6 requires phpstan/phpstan: ^2.2.2 and reaches into a private RichParser::$container property via PHPStanContainerMemento::removeRichVisitors(). PHPStan 2.2.6, released 2026-07-26, no longer has that property, so the unpinned resolution of ^2.2.2 now picks a PHPStan that Rector 2.4.x cannot boot against.

Verified locally:

  • rector 2.4.6 + phpstan 2.2.5 - exits 0
  • rector 2.4.6 + phpstan 2.2.6 - the fatal above
  • rector 2.5.8 + phpstan 2.2.6 - boots and analyzes fine

Upstream fixed this in rector 2.5.7/2.5.8, which raise the requirement to phpstan/phpstan: ^2.2.6.

The change

  • rector-setup now installs rector/rector:"~2.5.0".
  • Rector 2.5 adds a batch of new rules to the sets we enable. They fire across ~226 files, dominated by docblock removal (RemoveUselessUnionReturnDocblockRector, RemoveMixedDocblockOverruledByNativeTypeRector, RemoveDuplicatedReturnSelfDocblockRector) plus RemoveDefaultValueFromAssignedPropertyRector. They are skipped here, same way the 2.4 bump handled SafeDeclareStrictTypesRector and RemoveUselessTernaryRector, so this PR only unblocks CI and changes no src/ code.

Whether to actually apply any of those rules is worth its own PR - I did not want to bury a 226-file sweep inside a CI fix.

Alternative considered

Keeping rector on ~2.4.0 and pinning phpstan/phpstan below 2.2.6 also makes CI green with a smaller diff, but it freezes a transitive tool at an exact patch to work around a bug upstream has already fixed. Happy to switch if the team prefers that.

Two pre-existing skips are now reported as deprecated by rector 2.5 (JoinStringConcatRector, StrictStringParamConcatRector). Left them in place to keep this diff focused; they can be pruned separately.

Rector 2.4.x reads a private RichParser::$container property that phpstan
2.2.6 removed, so composer rector-check dies with a fatal before analyzing
anything. rector-setup resolves phpstan unpinned, so every PR started
failing once 2.2.6 was released on 2026-07-26.

Bump rector-setup to ~2.5.0. Rector 2.5.7+ requires phpstan ^2.2.6 and
boots fine against it.

Rector 2.5 registers new rules in the sets we enable; they fire on about
226 files, mostly docblock removal. Skip them so this stays a CI fix and
touches no src code, matching how the 2.4 bump was handled.
@dereuromark dereuromark added this to the 5.4.1 milestone Jul 28, 2026
@dereuromark
dereuromark merged commit db11a5a into 5.x Jul 28, 2026
15 checks passed
@dereuromark
dereuromark deleted the ci-fix-rector-phpstan-2.2.6 branch July 28, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant