@@ -94,22 +94,20 @@ private function getImportedSymbolsFromGroupStatement(File $phpcsFile, int $stac
9494 // Get the namespace for the import first, so we can attach it to each Symbol
9595 $ importNamespace = $ this ->getFullSymbol ($ phpcsFile , $ startBracketPtr - 1 );
9696
97- $ lastImportPtr = $ stackPtr ;
9897 $ collectedSymbols = [];
99- $ isLastImport = false ;
100- while (! $ isLastImport ) {
101- $ nextEndOfImportPtr = $ phpcsFile ->findNext ([T_COMMA ], $ lastImportPtr + 1 , $ endBracketPtr );
102- if (! $ nextEndOfImportPtr ) {
103- $ isLastImport = true ;
104- $ nextEndOfImportPtr = $ endBracketPtr ;
105- }
106- $ lastStringPtr = $ phpcsFile ->findPrevious ([T_STRING ], $ nextEndOfImportPtr - 1 , $ stackPtr );
107- if (! $ lastStringPtr || ! isset ($ tokens [$ lastStringPtr ])) {
98+ $ lastStringPtr = $ startBracketPtr ;
99+ while ($ lastStringPtr < $ endBracketPtr ) {
100+ $ nextStringPtr = $ phpcsFile ->findNext ([T_STRING ], $ lastStringPtr + 1 , $ endBracketPtr );
101+ if (! $ nextStringPtr || ! isset ($ tokens [$ nextStringPtr ])) {
108102 break ;
109103 }
110- $ fullSymbolParts = array_merge ($ importNamespace ->getTokens (), [Symbol::getTokenWithPosition ($ tokens [$ lastStringPtr ], $ lastStringPtr )]);
111- $ collectedSymbols [] = new Symbol ($ fullSymbolParts );
112- $ lastImportPtr = $ nextEndOfImportPtr ;
104+ $ nextCommaPtr = $ phpcsFile ->findNext ([T_COMMA ], $ nextStringPtr + 1 , $ endBracketPtr ) ?: $ endBracketPtr ;
105+ $ nextAliasPtr = $ phpcsFile ->findNext ([T_AS ], $ nextStringPtr + 1 , $ nextCommaPtr );
106+ if (! $ nextAliasPtr ) {
107+ $ fullSymbolParts = array_merge ($ importNamespace ->getTokens (), [Symbol::getTokenWithPosition ($ tokens [$ nextStringPtr ], $ nextStringPtr )]);
108+ $ collectedSymbols [] = new Symbol ($ fullSymbolParts );
109+ }
110+ $ lastStringPtr = $ nextStringPtr ;
113111 }
114112 return $ collectedSymbols ;
115113 }
0 commit comments