@@ -2561,6 +2561,9 @@ public function processExprNode(
25612561
25622562 $ this ->callNodeCallbackWithExpression ($ nodeCallback , $ expr , $ scope , $ context );
25632563
2564+ $ expressionType = null ;
2565+ $ expressionNativeType = null ;
2566+
25642567 if ($ expr instanceof Variable) {
25652568 $ hasYield = false ;
25662569 $ throwPoints = [];
@@ -2619,7 +2622,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
26192622 $ scope = $ scope ->exitExpressionAssign ($ expr ->expr );
26202623 }
26212624
2622- $ result = new ExpressionResult ($ scope , $ hasYield , $ isAlwaysTerminating , $ throwPoints , $ impurePoints );
2625+ $ result = new ExpressionResult ($ scope , $ hasYield , $ isAlwaysTerminating , $ throwPoints , $ impurePoints, type: $ result -> getType (), nativeType: $ result -> getNativeType () );
26232626 $ storage ->storeResult ($ expr , $ result );
26242627
26252628 return $ result ;
@@ -4381,6 +4384,8 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
43814384 $ throwPoints = [];
43824385 $ impurePoints = [];
43834386 $ isAlwaysTerminating = false ;
4387+ $ expressionType = $ this ->initializerExprTypeResolver ->getType ($ expr , InitializerExprContext::fromScope ($ scope ));
4388+ $ expressionNativeType = $ expressionType ;
43844389 } elseif ($ expr instanceof ConstFetch) {
43854390 $ hasYield = false ;
43864391 $ throwPoints = [];
@@ -4402,6 +4407,8 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
44024407 $ impurePoints ,
44034408 static fn (): MutatingScope => $ scope ->filterByTruthyValue ($ expr ),
44044409 static fn (): MutatingScope => $ scope ->filterByFalseyValue ($ expr ),
4410+ $ expressionType ,
4411+ $ expressionNativeType ,
44054412 );
44064413 $ storage ->storeResult ($ expr , $ result );
44074414 return $ result ;
@@ -5872,12 +5879,16 @@ private function processAssignVar(
58725879 $ impurePoints = [];
58735880 $ isAlwaysTerminating = false ;
58745881 $ isAssignOp = $ assignedExpr instanceof Expr \AssignOp && !$ enterExpressionAssign ;
5882+ $ expressionType = null ;
5883+ $ expressionNativeType = null ;
58755884 if ($ var instanceof Variable && is_string ($ var ->name )) {
58765885 $ result = $ processExprCallback ($ scope );
58775886 $ hasYield = $ result ->hasYield ();
58785887 $ throwPoints = $ result ->getThrowPoints ();
58795888 $ impurePoints = $ result ->getImpurePoints ();
58805889 $ isAlwaysTerminating = $ result ->isAlwaysTerminating ();
5890+ $ expressionType = $ result ->getType ();
5891+ $ expressionNativeType = $ result ->getNativeType ();
58815892 if (in_array ($ var ->name , Scope::SUPERGLOBAL_VARIABLES , true )) {
58825893 $ impurePoints [] = new ImpurePoint ($ scope , $ var , 'superglobal ' , 'assign to superglobal variable ' , true );
58835894 }
@@ -6399,7 +6410,7 @@ private function processAssignVar(
63996410 }
64006411
64016412 // stored where processAssignVar is called
6402- return new ExpressionResult ($ scope , $ hasYield , $ isAlwaysTerminating , $ throwPoints , $ impurePoints );
6413+ return new ExpressionResult ($ scope , $ hasYield , $ isAlwaysTerminating , $ throwPoints , $ impurePoints, type: $ expressionType , nativeType: $ expressionNativeType );
64036414 }
64046415
64056416 /**
0 commit comments