@@ -167,34 +167,36 @@ public function process(File $phpcsFile, $stringPointer): void
167167 private function shouldBeSkipped (File $ phpcsFile , int $ stringPointer , int $ parenthesisCloserPointer ): bool
168168 {
169169 $ tokens = $ phpcsFile ->getTokens ();
170+ $ nameTokenCodes = TokenHelper::getOnlyNameTokenCodes ();
170171
171- $ firstPointerOnLine = TokenHelper::findFirstNonWhitespaceOnLine ($ phpcsFile , $ stringPointer );
172- $ stringPointersBefore = TokenHelper:: findNextAll (
173- $ phpcsFile ,
174- TokenHelper:: getOnlyNameTokenCodes (),
175- $ firstPointerOnLine ,
176- $ stringPointer
177- );
172+ $ searchStartPointer = TokenHelper::findFirstNonWhitespaceOnLine ($ phpcsFile , $ stringPointer );
173+ while ( true ) {
174+ $ stringPointerBefore = TokenHelper:: findNext ( $ phpcsFile , $ nameTokenCodes , $ searchStartPointer , $ stringPointer );
175+
176+ if ( $ stringPointerBefore === null ) {
177+ break ;
178+ }
178179
179- foreach ($ stringPointersBefore as $ stringPointerBefore ) {
180180 $ pointerAfterStringPointerBefore = TokenHelper::findNextEffective ($ phpcsFile , $ stringPointerBefore + 1 );
181181 if (
182182 $ tokens [$ pointerAfterStringPointerBefore ]['code ' ] === T_OPEN_PARENTHESIS
183183 && $ tokens [$ pointerAfterStringPointerBefore ]['parenthesis_closer ' ] > $ stringPointer
184184 ) {
185185 return true ;
186186 }
187+
188+ $ searchStartPointer = $ stringPointerBefore + 1 ;
187189 }
188190
189191 $ lastPointerOnLine = TokenHelper::findLastTokenOnLine ($ phpcsFile , $ parenthesisCloserPointer );
190- $ stringPointersAfter = TokenHelper::findNextAll (
191- $ phpcsFile ,
192- TokenHelper::getOnlyNameTokenCodes (),
193- $ parenthesisCloserPointer + 1 ,
194- $ lastPointerOnLine + 1
195- );
192+ $ searchStartPointer = $ parenthesisCloserPointer + 1 ;
193+ while (true ) {
194+ $ stringPointerAfter = TokenHelper::findNext ($ phpcsFile , $ nameTokenCodes , $ searchStartPointer , $ lastPointerOnLine + 1 );
195+
196+ if ($ stringPointerAfter === null ) {
197+ break ;
198+ }
196199
197- foreach ($ stringPointersAfter as $ stringPointerAfter ) {
198200 $ pointerAfterStringPointerAfter = TokenHelper::findNextEffective ($ phpcsFile , $ stringPointerAfter + 1 );
199201 if (
200202 $ pointerAfterStringPointerAfter !== null
@@ -207,6 +209,8 @@ private function shouldBeSkipped(File $phpcsFile, int $stringPointer, int $paren
207209 ) {
208210 return true ;
209211 }
212+
213+ $ searchStartPointer = $ stringPointerAfter + 1 ;
210214 }
211215
212216 return false ;
0 commit comments