1616use PHPStan \Analyser \MutatingScope ;
1717use PHPStan \Analyser \NodeScopeResolver ;
1818use PHPStan \Analyser \SpecifiedTypes ;
19+ use PHPStan \Analyser \VariableFlow ;
20+ use PHPStan \Analyser \VariableFlowBuilder ;
1921use PHPStan \DependencyInjection \AutowiredService ;
2022use PHPStan \Node \LiteralArrayItem ;
2123use PHPStan \Node \LiteralArrayNode ;
@@ -53,6 +55,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
5355 $ beforeScope = $ scope ;
5456 $ itemNodes = [];
5557 $ itemResults = [];
58+ $ variableFlows = [];
5659 $ hasYield = false ;
5760 $ throwPoints = [];
5861 $ impurePoints = [];
@@ -63,6 +66,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
6366 if ($ arrayItem ->key !== null ) {
6467 $ keyResult = $ nodeScopeResolver ->processExprNode ($ stmt , $ arrayItem ->key , $ scope , $ storage , $ nodeCallback , $ context ->enterDeep ());
6568 $ itemResults [spl_object_id ($ arrayItem ->key )] = $ keyResult ;
69+ $ variableFlows [] = $ keyResult ->getVariableFlow ();
6670 $ hasYield = $ hasYield || $ keyResult ->hasYield ();
6771 $ throwPoints = array_merge ($ throwPoints , $ keyResult ->getThrowPoints ());
6872 $ impurePoints = array_merge ($ impurePoints , $ keyResult ->getImpurePoints ());
@@ -72,6 +76,10 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
7276
7377 $ valueResult = $ nodeScopeResolver ->processExprNode ($ stmt , $ arrayItem ->value , $ scope , $ storage , $ nodeCallback , $ context ->enterDeep ());
7478 $ itemResults [spl_object_id ($ arrayItem ->value )] = $ valueResult ;
79+ $ variableFlows [] = $ valueResult ->getVariableFlow ();
80+ if ($ arrayItem ->byRef ) {
81+ $ variableFlows [] = VariableFlowBuilder::escapeRoot ($ arrayItem ->value );
82+ }
7583 $ hasYield = $ hasYield || $ valueResult ->hasYield ();
7684 $ throwPoints = array_merge ($ throwPoints , $ valueResult ->getThrowPoints ());
7785 $ impurePoints = array_merge ($ impurePoints , $ valueResult ->getImpurePoints ());
@@ -88,6 +96,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
8896 $ scope ,
8997 beforeScope: $ beforeScope ,
9098 expr: $ expr ,
99+ variableFlow: VariableFlow::sequence (...$ variableFlows ),
91100 hasYield: $ hasYield ,
92101 isAlwaysTerminating: $ isAlwaysTerminating ,
93102 throwPoints: $ throwPoints ,
0 commit comments