Do not extend Expr in the isset/empty/coalesce rule-facing virtual nodes - #6155
Merged
Conversation
IssetExpressionNode, EmptyExpressionNode and CoalesceExpressionNode are emitted to node callbacks for their rules, and third-party collectors and rules commonly call $scope->getType() on every expression they receive - which crashed in the type-cache key printer, since these nodes have no printer method: Call to undefined method Printer::pPHPStan_Node_IssetExpressionNode() Rule-facing virtual nodes extend NodeAbstract (MatchExpressionNode, BooleanAndNode, ...) precisely so they can never reach getType(); these three now follow. callNodeCallbackWithExpression() accepts any Node - it only adjusts the scope for deep contexts before emitting. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DaBZjgksga4c5s6Q9FniY7
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.
Fixes the reported integration crash:
IssetExpressionNode,EmptyExpressionNodeandCoalesceExpressionNodeare emitted to node callbacks for their rules, and third-party collectors/rules commonly call$scope->getType()on everyExprthey receive — which reached the type-cache key printer with no printer method for these nodes. The codebase convention for rule-facing virtual nodes is to extendNodeAbstract(MatchExpressionNode,BooleanAndNode, …) precisely so they can never be passed togetType(); these three now follow, andcallNodeCallbackWithExpression()accepts anyNode(it only adjusts the scope for deep contexts).The regression test mimics the crashing collector: a
Node::classrule calling$scope->getType()on every expression over an isset/empty/??/??= fixture — red with the exact production error before the fix, green after.Full test suite green with and without the active turbo extension,
make phpstanandmake csclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01DaBZjgksga4c5s6Q9FniY7