Commit 0b13c2b
committed
PEAR/ObjectOperatorIndent: improve end of statement detection when getting the next object operator
This commit fixes a bug where `PEAR.WhiteSpace.ObjectOperatorIndent`
would generate a false positive when checking multiple chained object
operators in a multidimensional array.
The problem is that the code was using the `$local` parameter of
`findNext()` to limit the scope of the search when reassigning
`$next` to the next object operator, and `$local` only considers a
semicolon as the end of a statement.
Different chained calls are not necessarily separated by a semicolon (as
shown in the test added in this commit). This means that the sniff
currently considers the object operators on the second and third chained
method calls as part of the first chained method call. The sniff checks
their indentation using the indentation of the first element on the
first chained call as its base.
To fix this problem, instead of relying on the `$local` parameter to
find the end of the statement, the end of the statement as defined by
`File::findEndOfStatement()` is now used.1 parent 368817d commit 0b13c2b
File tree
4 files changed
+24
-4
lines changed- src/Standards/PEAR
- Sniffs/WhiteSpace
- Tests/WhiteSpace
4 files changed
+24
-4
lines changedLines changed: 1 addition & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
| 194 | + | |
198 | 195 | | |
199 | 196 | | |
200 | 197 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
0 commit comments