@@ -122,6 +122,7 @@ private function processArrayKeyFirstLast(StmtsAwareInterface $stmtsAware, bool
122122 }
123123 $ newName = self ::PREVIOUS_TO_NEW_FUNCTIONS [$ this ->getName ($ stmt ->expr )];
124124 $ keyFuncCall ->name = new Name ($ newName );
125+ $ this ->changeNextKeyCall ($ stmtsAware , $ key + 2 , $ resetOrEndFuncCall , $ keyFuncCall ->name );
125126 unset($ stmtsAware ->stmts [$ key ]);
126127 $ hasChanged = \true;
127128 return $ this ->processArrayKeyFirstLast ($ stmtsAware , $ hasChanged , $ key + 2 );
@@ -131,6 +132,24 @@ private function processArrayKeyFirstLast(StmtsAwareInterface $stmtsAware, bool
131132 }
132133 return null ;
133134 }
135+ private function changeNextKeyCall (StmtsAwareInterface $ stmtsAware , int $ key , FuncCall $ resetOrEndFuncCall , Name $ newName ) : void
136+ {
137+ $ counter = \count ($ stmtsAware ->stmts );
138+ for ($ nextKey = $ key ; $ nextKey < $ counter ; ++$ nextKey ) {
139+ if (!isset ($ stmtsAware ->stmts [$ nextKey ])) {
140+ break ;
141+ }
142+ if ($ stmtsAware ->stmts [$ nextKey ] instanceof Expression && !$ this ->shouldSkip ($ stmtsAware ->stmts [$ nextKey ])) {
143+ $ this ->processArrayKeyFirstLast ($ stmtsAware , \true, $ nextKey );
144+ break ;
145+ }
146+ $ keyFuncCall = $ this ->resolveKeyFuncCall ($ stmtsAware ->stmts [$ nextKey ], $ resetOrEndFuncCall );
147+ if (!$ keyFuncCall instanceof FuncCall) {
148+ continue ;
149+ }
150+ $ keyFuncCall ->name = $ newName ;
151+ }
152+ }
134153 private function resolveKeyFuncCall (Stmt $ nextStmt , FuncCall $ resetOrEndFuncCall ) : ?FuncCall
135154 {
136155 if ($ resetOrEndFuncCall ->isFirstClassCallable ()) {
0 commit comments