@@ -120,7 +120,7 @@ protected function processAssignment($phpcsFile, $stackPtr)
120
120
{
121
121
$ tokens = $ phpcsFile ->getTokens ();
122
122
123
- $ assignedVar = $ phpcsFile ->findPrevious (T_WHITESPACE , ($ stackPtr - 1 ), null , true );
123
+ $ assignedVar = $ phpcsFile ->findPrevious (Tokens:: $ emptyTokens , ($ stackPtr - 1 ), null , true );
124
124
// Not an assignment, return.
125
125
if ($ tokens [$ assignedVar ]['code ' ] !== T_VARIABLE ) {
126
126
return ;
@@ -129,8 +129,14 @@ protected function processAssignment($phpcsFile, $stackPtr)
129
129
$ statementEnd = $ phpcsFile ->findNext ([T_SEMICOLON , T_CLOSE_PARENTHESIS , T_CLOSE_SQUARE_BRACKET , T_CLOSE_CURLY_BRACKET ], $ stackPtr );
130
130
131
131
// 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 );
134
140
if ($ noiseTokens !== false ) {
135
141
return ;
136
142
}
@@ -145,8 +151,8 @@ protected function processAssignment($phpcsFile, $stackPtr)
145
151
}
146
152
147
153
if ($ tokens [$ stackPtr ]['code ' ] === T_EQUAL ) {
148
- $ nextVar = ( $ stackPtr + 1 ) ;
149
- $ previousVariable = ( $ stackPtr + 1 ) ;
154
+ $ nextVar = $ stackPtr ;
155
+ $ previousVariable = $ stackPtr ;
150
156
$ variableCount = 0 ;
151
157
while (($ nextVar = $ phpcsFile ->findNext (T_VARIABLE , ($ nextVar + 1 ), $ statementEnd )) !== false ) {
152
158
$ previousVariable = $ nextVar ;
@@ -165,8 +171,8 @@ protected function processAssignment($phpcsFile, $stackPtr)
165
171
166
172
// We have only one variable, and it's the same as what is being assigned,
167
173
// 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 ;
170
176
$ numberCount = 0 ;
171
177
while (($ nextNumber = $ phpcsFile ->findNext ([T_LNUMBER ], ($ nextNumber + 1 ), $ statementEnd , false )) !== false ) {
172
178
$ previousNumber = $ nextNumber ;
0 commit comments