@@ -1336,9 +1336,9 @@ private function processStmtNode(
13361336			$ hasYieldfalse ;
13371337			$ throwPoints
13381338			foreach  ($ stmtvars  as  $ var
1339- 				$ scope$ this lookForEnterAllowedUndefinedVariable ($ scope$ var,  true );
1339+ 				$ scope$ this lookForSetAllowedUndefinedExpressions ($ scope$ var
13401340				$ scope$ this processExprNode ($ var$ scope$ nodeCallbackcreateDeep ())->getScope ();
1341- 				$ scope$ this lookForExitAllowedUndefinedVariable ($ scope$ var
1341+ 				$ scope$ this lookForUnsetAllowedUndefinedExpressions ($ scope$ var
13421342				$ scope$ scopeunsetExpression ($ var
13431343			}
13441344		} elseif  ($ stmtinstanceof  Node \Stmt \Use_) {
@@ -1355,9 +1355,9 @@ private function processStmtNode(
13551355				if  (!$ varinstanceof  Variable) {
13561356					throw  new  ShouldNotHappenException ();
13571357				}
1358- 				$ scope$ this lookForEnterAllowedUndefinedVariable ($ scope$ var,  true );
1358+ 				$ scope$ this lookForSetAllowedUndefinedExpressions ($ scope$ var
13591359				$ this processExprNode ($ var$ scope$ nodeCallbackcreateDeep ());
1360- 				$ scope$ this lookForExitAllowedUndefinedVariable ($ scope$ var
1360+ 				$ scope$ this lookForUnsetAllowedUndefinedExpressions ($ scope$ var
13611361
13621362				if  (!is_string ($ varname )) {
13631363					continue ;
@@ -1513,56 +1513,40 @@ private function createAstClassReflection(Node\Stmt\ClassLike $stmt, string $cla
15131513		);
15141514	}
15151515
1516- 	private  function  lookForEnterAllowedUndefinedVariable (MutatingScope $ scopeExpr $ expr,  bool   $ isAllowed MutatingScope 
1516+ 	private  function  lookForSetAllowedUndefinedExpressions (MutatingScope $ scopeExpr $ exprMutatingScope 
15171517	{
1518- 		if  (!$ exprinstanceof  ArrayDimFetch || $ exprdim  !== null ) {
1519- 			$ scope$ scopesetAllowedUndefinedExpression ($ expr$ isAllowed
1520- 		}
1521- 		if  (!$ exprinstanceof  Variable) {
1522- 			return  $ this lookForVariableCallback ($ scope$ exprstatic  fn  (MutatingScope $ scopeExpr $ exprMutatingScope $ scopesetAllowedUndefinedExpression ($ expr$ isAllowed
1523- 		}
1524- 
1525- 		return  $ scope
1518+ 		return  $ this lookForExpressionCallback ($ scope$ exprstatic  fn  (MutatingScope $ scopeExpr $ exprMutatingScope $ scopesetAllowedUndefinedExpression ($ expr
15261519	}
15271520
1528- 	private  function  lookForExitAllowedUndefinedVariable (MutatingScope $ scopeExpr $ exprMutatingScope 
1521+ 	private  function  lookForUnsetAllowedUndefinedExpressions (MutatingScope $ scopeExpr $ exprMutatingScope 
15291522	{
1530- 		if  (!$ exprinstanceof  ArrayDimFetch || $ exprdim  !== null ) {
1531- 			$ scope$ scopeunsetAllowedUndefinedExpression ($ expr
1532- 		}
1533- 		if  (!$ exprinstanceof  Variable) {
1534- 			return  $ this lookForVariableCallback ($ scope$ exprstatic  fn  (MutatingScope $ scopeExpr $ exprMutatingScope $ scopeunsetAllowedUndefinedExpression ($ expr
1535- 		}
1536- 
1537- 		return  $ scope
1523+ 		return  $ this lookForExpressionCallback ($ scope$ exprstatic  fn  (MutatingScope $ scopeExpr $ exprMutatingScope $ scopeunsetAllowedUndefinedExpression ($ expr
15381524	}
15391525
15401526	/** 
15411527	 * @param Closure(MutatingScope $scope, Expr $expr): MutatingScope $callback 
15421528	 */ 
1543- 	private  function  lookForVariableCallback (MutatingScope $ scopeExpr $ exprClosure $ callbackMutatingScope 
1529+ 	private  function  lookForExpressionCallback (MutatingScope $ scopeExpr $ exprClosure $ callbackMutatingScope 
15441530	{
1545- 		if  ($ exprinstanceof  Variable ) {
1531+ 		if  (! $ exprinstanceof  ArrayDimFetch ||  $ expr -> dim  !==  null ) {
15461532			$ scope$ callback$ scope$ expr
1547- 		} elseif  ($ exprinstanceof  ArrayDimFetch) {
1548- 			if  ($ exprdim  !== null ) {
1549- 				$ scope$ callback$ scope$ expr
1550- 			}
1533+ 		}
15511534
1552- 			$ scope$ this lookForVariableCallback ($ scope$ exprvar , $ callback
1535+ 		if  ($ exprinstanceof  ArrayDimFetch) {
1536+ 			$ scope$ this lookForExpressionCallback ($ scope$ exprvar , $ callback
15531537		} elseif  ($ exprinstanceof  PropertyFetch || $ exprinstanceof  Expr \NullsafePropertyFetch) {
1554- 			$ scope$ this lookForVariableCallback ($ scope$ exprvar , $ callback
1538+ 			$ scope$ this lookForExpressionCallback ($ scope$ exprvar , $ callback
15551539		} elseif  ($ exprinstanceof  StaticPropertyFetch) {
15561540			if  ($ exprclass  instanceof  Expr) {
1557- 				$ scope$ this lookForVariableCallback ($ scope$ exprclass , $ callback
1541+ 				$ scope$ this lookForExpressionCallback ($ scope$ exprclass , $ callback
15581542			}
15591543		} elseif  ($ exprinstanceof  Array_ || $ exprinstanceof  List_) {
15601544			foreach  ($ expritems  as  $ item
15611545				if  ($ itemnull ) {
15621546					continue ;
15631547				}
15641548
1565- 				$ scope$ this lookForVariableCallback ($ scope$ itemvalue , $ callback
1549+ 				$ scope$ this lookForExpressionCallback ($ scope$ itemvalue , $ callback
15661550			}
15671551		}
15681552
@@ -2321,10 +2305,10 @@ static function (?Type $offsetType, Type $valueType) use (&$arrayType): void {
23212305			);
23222306		} elseif  ($ exprinstanceof  Coalesce) {
23232307			$ nonNullabilityResult$ this ensureNonNullability ($ scope$ exprleft , false );
2324- 			$ condScope$ this lookForEnterAllowedUndefinedVariable ($ nonNullabilityResultgetScope (), $ exprleft ,  true );
2308+ 			$ condScope$ this lookForSetAllowedUndefinedExpressions ($ nonNullabilityResultgetScope (), $ exprleft );
23252309			$ condResult$ this processExprNode ($ exprleft , $ condScope$ nodeCallback$ contextenterDeep ());
23262310			$ scope$ this revertNonNullability ($ condResultgetScope (), $ nonNullabilityResultgetSpecifiedExpressions ());
2327- 			$ scope$ this lookForExitAllowedUndefinedVariable ($ scope$ exprleft );
2311+ 			$ scope$ this lookForUnsetAllowedUndefinedExpressions ($ scope$ exprleft );
23282312
23292313			$ rightScope$ scopefilterByFalseyValue (new  Expr \Isset_ ([$ exprleft ]));
23302314			$ rightResult$ this processExprNode ($ exprright , $ rightScope$ nodeCallback$ contextenterDeep ());
@@ -2395,26 +2379,26 @@ static function (?Type $offsetType, Type $valueType) use (&$arrayType): void {
23952379			}
23962380		} elseif  ($ exprinstanceof  Expr \Empty_) {
23972381			$ nonNullabilityResult$ this ensureNonNullability ($ scope$ exprexpr , true );
2398- 			$ scope$ this lookForEnterAllowedUndefinedVariable ($ nonNullabilityResultgetScope (), $ exprexpr ,  true );
2382+ 			$ scope$ this lookForSetAllowedUndefinedExpressions ($ nonNullabilityResultgetScope (), $ exprexpr );
23992383			$ result$ this processExprNode ($ exprexpr , $ scope$ nodeCallback$ contextenterDeep ());
24002384			$ scope$ resultgetScope ();
24012385			$ hasYield$ resulthasYield ();
24022386			$ throwPoints$ resultgetThrowPoints ();
24032387			$ scope$ this revertNonNullability ($ scope$ nonNullabilityResultgetSpecifiedExpressions ());
2404- 			$ scope$ this lookForExitAllowedUndefinedVariable ($ scope$ exprexpr );
2388+ 			$ scope$ this lookForUnsetAllowedUndefinedExpressions ($ scope$ exprexpr );
24052389		} elseif  ($ exprinstanceof  Expr \Isset_) {
24062390			$ hasYieldfalse ;
24072391			$ throwPoints
24082392			$ nonNullabilityResults
24092393			foreach  ($ exprvars  as  $ var
24102394				$ nonNullabilityResult$ this ensureNonNullability ($ scope$ vartrue );
2411- 				$ scope$ this lookForEnterAllowedUndefinedVariable ($ nonNullabilityResultgetScope (), $ var,  true );
2395+ 				$ scope$ this lookForSetAllowedUndefinedExpressions ($ nonNullabilityResultgetScope (), $ var
24122396				$ result$ this processExprNode ($ var$ scope$ nodeCallback$ contextenterDeep ());
24132397				$ scope$ resultgetScope ();
24142398				$ hasYield$ hasYield$ resulthasYield ();
24152399				$ throwPointsarray_merge ($ throwPoints$ resultgetThrowPoints ());
24162400				$ nonNullabilityResults$ nonNullabilityResult
2417- 				$ scope$ this lookForExitAllowedUndefinedVariable ($ scope$ var
2401+ 				$ scope$ this lookForUnsetAllowedUndefinedExpressions ($ scope$ var
24182402			}
24192403			foreach  (array_reverse ($ nonNullabilityResultsas  $ nonNullabilityResult
24202404				$ scope$ this revertNonNullability ($ scope$ nonNullabilityResultgetSpecifiedExpressions ());
@@ -3466,7 +3450,7 @@ static function (): void {
34663450				if  ($ arrayItemvalue  instanceof  ArrayDimFetch && $ arrayItemvalue ->dim  === null ) {
34673451					$ itemScope$ itemScopeenterExpressionAssign ($ arrayItemvalue );
34683452				}
3469- 				$ itemScope$ this lookForEnterAllowedUndefinedVariable ($ itemScope$ arrayItemvalue ,  true );
3453+ 				$ itemScope$ this lookForSetAllowedUndefinedExpressions ($ itemScope$ arrayItemvalue );
34703454				$ itemResult$ this processExprNode ($ arrayItem$ itemScope$ nodeCallback$ contextenterDeep ());
34713455				$ hasYield$ hasYield$ itemResulthasYield ();
34723456				$ throwPointsarray_merge ($ throwPoints$ itemResultgetThrowPoints ());
0 commit comments