119119use PHPStan \Node \MethodCallableNode ;
120120use PHPStan \Node \MethodReturnStatementsNode ;
121121use PHPStan \Node \NoopExpressionNode ;
122+ use PHPStan \Node \Printer \ExprPrinter ;
122123use PHPStan \Node \PropertyAssignNode ;
123124use PHPStan \Node \PropertyHookReturnStatementsNode ;
124125use PHPStan \Node \PropertyHookStatementNode ;
@@ -3210,13 +3211,15 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
32103211 } elseif ($ expr instanceof Expr \NullsafeMethodCall) {
32113212 $ beforeScope = $ scope ;
32123213 $ nonNullabilityResult = $ this ->ensureShallowNonNullability ($ scope , $ scope , $ expr ->var );
3214+ $ attributes = array_merge ($ expr ->getAttributes (), ['virtualNullsafeMethodCall ' => true ]);
3215+ unset($ attributes [ExprPrinter::ATTRIBUTE_CACHE_KEY ]);
32133216 $ exprResult = $ this ->processExprNode (
32143217 $ stmt ,
32153218 new MethodCall (
32163219 $ expr ->var ,
32173220 $ expr ->name ,
32183221 $ expr ->args ,
3219- array_merge ( $ expr -> getAttributes (), [ ' virtualNullsafeMethodCall ' => true ]) ,
3222+ $ attributes ,
32203223 ),
32213224 $ nonNullabilityResult ->getScope (),
32223225 $ storage ,
@@ -3438,10 +3441,12 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
34383441 } elseif ($ expr instanceof Expr \NullsafePropertyFetch) {
34393442 $ beforeScope = $ scope ;
34403443 $ nonNullabilityResult = $ this ->ensureShallowNonNullability ($ scope , $ scope , $ expr ->var );
3444+ $ attributes = array_merge ($ expr ->getAttributes (), ['virtualNullsafePropertyFetch ' => true ]);
3445+ unset($ attributes [ExprPrinter::ATTRIBUTE_CACHE_KEY ]);
34413446 $ exprResult = $ this ->processExprNode ($ stmt , new PropertyFetch (
34423447 $ expr ->var ,
34433448 $ expr ->name ,
3444- array_merge ( $ expr -> getAttributes (), [ ' virtualNullsafePropertyFetch ' => true ]) ,
3449+ $ attributes ,
34453450 ), $ nonNullabilityResult ->getScope (), $ storage , $ nodeCallback , $ context );
34463451 $ scope = $ this ->revertNonNullability ($ exprResult ->getScope (), $ nonNullabilityResult ->getSpecifiedExpressions ());
34473452
@@ -3669,10 +3674,12 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36693674 $ impurePoints = array_merge ($ condResult ->getImpurePoints (), $ rightResult ->getImpurePoints ());
36703675 $ isAlwaysTerminating = $ condResult ->isAlwaysTerminating ();
36713676 } elseif ($ expr instanceof BinaryOp \Pipe) {
3677+ $ rightAttributes = array_merge ($ expr ->right ->getAttributes (), ['virtualPipeOperatorCall ' => true ]);
3678+ unset($ rightAttributes [ExprPrinter::ATTRIBUTE_CACHE_KEY ]);
36723679 if ($ expr ->right instanceof FuncCall && $ expr ->right ->isFirstClassCallable ()) {
36733680 $ exprResult = $ this ->processExprNode ($ stmt , new FuncCall ($ expr ->right ->name , [
36743681 new Arg ($ expr ->left , attributes: $ expr ->getAttribute (ReversePipeTransformerVisitor::ARG_ATTRIBUTES_NAME , [])),
3675- ], array_merge ( $ expr -> right -> getAttributes (), [ ' virtualPipeOperatorCall ' => true ]) ), $ scope , $ storage , $ nodeCallback , $ context );
3682+ ], $ rightAttributes ), $ scope , $ storage , $ nodeCallback , $ context );
36763683 $ scope = $ exprResult ->getScope ();
36773684 $ hasYield = $ exprResult ->hasYield ();
36783685 $ throwPoints = $ exprResult ->getThrowPoints ();
@@ -3681,7 +3688,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36813688 } elseif ($ expr ->right instanceof MethodCall && $ expr ->right ->isFirstClassCallable ()) {
36823689 $ exprResult = $ this ->processExprNode ($ stmt , new MethodCall ($ expr ->right ->var , $ expr ->right ->name , [
36833690 new Arg ($ expr ->left , attributes: $ expr ->getAttribute (ReversePipeTransformerVisitor::ARG_ATTRIBUTES_NAME , [])),
3684- ], array_merge ( $ expr -> right -> getAttributes (), [ ' virtualPipeOperatorCall ' => true ]) ), $ scope , $ storage , $ nodeCallback , $ context );
3691+ ], $ rightAttributes ), $ scope , $ storage , $ nodeCallback , $ context );
36853692 $ scope = $ exprResult ->getScope ();
36863693 $ hasYield = $ exprResult ->hasYield ();
36873694 $ throwPoints = $ exprResult ->getThrowPoints ();
@@ -3690,7 +3697,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36903697 } elseif ($ expr ->right instanceof StaticCall && $ expr ->right ->isFirstClassCallable ()) {
36913698 $ exprResult = $ this ->processExprNode ($ stmt , new StaticCall ($ expr ->right ->class , $ expr ->right ->name , [
36923699 new Arg ($ expr ->left , attributes: $ expr ->getAttribute (ReversePipeTransformerVisitor::ARG_ATTRIBUTES_NAME , [])),
3693- ], array_merge ( $ expr -> right -> getAttributes (), [ ' virtualPipeOperatorCall ' => true ]) ), $ scope , $ storage , $ nodeCallback , $ context );
3700+ ], $ rightAttributes ), $ scope , $ storage , $ nodeCallback , $ context );
36943701 $ scope = $ exprResult ->getScope ();
36953702 $ hasYield = $ exprResult ->hasYield ();
36963703 $ throwPoints = $ exprResult ->getThrowPoints ();
@@ -3699,7 +3706,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36993706 } else {
37003707 $ exprResult = $ this ->processExprNode ($ stmt , new FuncCall ($ expr ->right , [
37013708 new Arg ($ expr ->left , attributes: $ expr ->getAttribute (ReversePipeTransformerVisitor::ARG_ATTRIBUTES_NAME , [])),
3702- ], array_merge ( $ expr -> right -> getAttributes (), [ ' virtualPipeOperatorCall ' => true ]) ), $ scope , $ storage , $ nodeCallback , $ context );
3709+ ], $ rightAttributes ), $ scope , $ storage , $ nodeCallback , $ context );
37033710 $ scope = $ exprResult ->getScope ();
37043711 $ hasYield = $ exprResult ->hasYield ();
37053712 $ throwPoints = $ exprResult ->getThrowPoints ();
0 commit comments