@@ -120,7 +120,7 @@ protected function processAssignment($phpcsFile, $stackPtr)
120120 {
121121 $ tokens = $ phpcsFile ->getTokens ();
122122
123- $ assignedVar = $ phpcsFile ->findPrevious (T_WHITESPACE , ($ stackPtr - 1 ), null , true );
123+ $ assignedVar = $ phpcsFile ->findPrevious (Tokens:: $ emptyTokens , ($ stackPtr - 1 ), null , true );
124124 // Not an assignment, return.
125125 if ($ tokens [$ assignedVar ]['code ' ] !== T_VARIABLE ) {
126126 return ;
@@ -129,8 +129,14 @@ protected function processAssignment($phpcsFile, $stackPtr)
129129 $ statementEnd = $ phpcsFile ->findNext ([T_SEMICOLON , T_CLOSE_PARENTHESIS , T_CLOSE_SQUARE_BRACKET , T_CLOSE_CURLY_BRACKET ], $ stackPtr );
130130
131131 // If there is anything other than variables, numbers, spaces or operators we need to return.
132- $ noiseTokens = $ phpcsFile ->findNext ([T_LNUMBER , T_VARIABLE , T_WHITESPACE , T_PLUS , T_MINUS , T_OPEN_PARENTHESIS ], ($ stackPtr + 1 ), $ statementEnd , true );
133-
132+ $ find = Tokens::$ emptyTokens ;
133+ $ find [] = T_LNUMBER ;
134+ $ find [] = T_VARIABLE ;
135+ $ find [] = T_PLUS ;
136+ $ find [] = T_MINUS ;
137+ $ find [] = T_OPEN_PARENTHESIS ;
138+
139+ $ noiseTokens = $ phpcsFile ->findNext ($ find , ($ stackPtr + 1 ), $ statementEnd , true );
134140 if ($ noiseTokens !== false ) {
135141 return ;
136142 }
@@ -145,8 +151,8 @@ protected function processAssignment($phpcsFile, $stackPtr)
145151 }
146152
147153 if ($ tokens [$ stackPtr ]['code ' ] === T_EQUAL ) {
148- $ nextVar = ( $ stackPtr + 1 ) ;
149- $ previousVariable = ( $ stackPtr + 1 ) ;
154+ $ nextVar = $ stackPtr ;
155+ $ previousVariable = $ stackPtr ;
150156 $ variableCount = 0 ;
151157 while (($ nextVar = $ phpcsFile ->findNext (T_VARIABLE , ($ nextVar + 1 ), $ statementEnd )) !== false ) {
152158 $ previousVariable = $ nextVar ;
@@ -165,8 +171,8 @@ protected function processAssignment($phpcsFile, $stackPtr)
165171
166172 // We have only one variable, and it's the same as what is being assigned,
167173 // so we need to check what is being added or subtracted.
168- $ nextNumber = ( $ stackPtr + 1 ) ;
169- $ previousNumber = ( $ stackPtr + 1 ) ;
174+ $ nextNumber = $ stackPtr ;
175+ $ previousNumber = $ stackPtr ;
170176 $ numberCount = 0 ;
171177 while (($ nextNumber = $ phpcsFile ->findNext ([T_LNUMBER ], ($ nextNumber + 1 ), $ statementEnd , false )) !== false ) {
172178 $ previousNumber = $ nextNumber ;
0 commit comments