Commit c29805d
committed
Squiz/IncrementDecrementUsage: bug fix - code without whitespace [2]
As this is a sniff looking for certain functional code patterns, the sniff should disregard whitespace and comments when looking for the relevant tokens to determine whether the code under scan contains the code pattern the sniff is looking for.
The sniff, however, does not do this correctly (in multiple places).
This commit fixes the same issue as fixed in the previous commit, but now specifically for the part in the code where it is checking that a `$var = $var + 1;` like statement only has one variable in the code comprising the value being assigned.
Same as before, the `$startPtr` for the `findNext()` is incremented for each `while` loop, but the initial `$startPtr` was also incremented, which meant that if there was no whitespace after an equals sign, the first relevant token was being skipped over.
Fixed now.
Includes tests.1 parent 99abd2c commit c29805d
File tree
3 files changed
+7
-2
lines changed- src/Standards/Squiz
- Sniffs/Operators
- Tests/Operators
3 files changed
+7
-2
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
| 148 | + | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
0 commit comments