Support PHPStan 2.2.10 scope changes - #8420
Merged
Merged
Conversation
PHPStan 2.2.10 emits node callbacks after a node's results are stored and replaces FiberScope with NodeCallbackScope. This flipped the parent/child callback ordering, so Rector's manual scope seeding on child expressions now overwrote the correct, narrowed scope PHPStan had already attached. - PHPStanNodeScopeResolver: unwrap NodeCallbackScope via toWalkScope(); stop clobbering arrow-function body scope; only seed a BinaryOp operand scope when PHPStan has not already set one, preserving is_array()/truthy narrowing on the right operand of && and ||. - CallCollectionAnalyzer: strip null before resolving the object class of a nullsafe call caller, as 2.2.10 no longer reports object class names for a nullable union. - NullToStrictStringIntConverter: drop the removed FiberScope handling. Bump required phpstan to ^2.2.10.
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.
PHPStan 2.2.10 emits node callbacks after a node's results are stored and replaces
FiberScopewithNodeCallbackScope. This flipped the parent/child callback ordering, so Rector's manual scope seeding on child expressions overwrote the correct, narrowed scope PHPStan had already attached. That broke type/scope resolution inside arrow functions,&&/||operands, and nullsafe calls.Changes
NodeCallbackScopeviatoWalkScope().fn($v) => $v['x']infers from the outer array shape again.BinaryOpoperand scope when PHPStan has not already set one, preservingis_array()/truthy narrowing on the right operand of&&and||.nullbefore resolving the object class of a nullsafe call caller; 2.2.10 no longer reports object class names for a nullable union, which madeRemoveUnusedPrivateMethodRectordrop methods called via?->.FiberScope.phpstan/phpstanto^2.2.10.Fixed failing fixtures
SimplifyEmptyCheckOnEmptyArrayRector-replace_is_array_checkRemoveUnusedPrivateMethodRector-keep_nullsafe_called_methodRenameParamToMatchTypeRector-used_in_arrow_function_paramAddArrowFunctionReturnTypeRector-return_by_array_shape_typeFull test suite, ECS, PHPStan level 8, and
composer rectorall pass locally.