Commit 3527d83
committed
Generic/ArbitraryParenthesesSpacing: improve handling of switch-case scope closers
Follow up on squizlabs/PHP_CodeSniffer 2826 which was fixed via squizlabs/PHP_CodeSniffer 2876.
The sniff explicitly only intends to handle _arbitrary_ parentheses and tries to avoid clashes with sniffs handling the parentheses spacing of function calls and language construct invocations.
This is done by the sniff bowing out early when the token before the open parenthesis is a token which can be used in a (variable) function call or one of a select list of reserved keywords.
The previous PR tweaked the "bowing out" to allow the sniff to operate on arbitrary parentheses which directly follow the close curly brace of a a previous scope.
The additional condition added was, however, not limited to `T_CLOSE_CURLY_BRACKET` tokens.
This has led to a new false positive: When a `die()`/`exit()` is used within a `switch-case` statement, the `die`/`exit` keyword will be regarded as a scope closer for the `case` statement, in which case, the parentheses for the `die`/`exit` would now be treated as arbitrary instead of as belonging to the `die`/`exit` keyword.
This commit fixes this by limiting the previously introduced check for a scope closer to curly braces only.
Includes tests proving the bug and safeguarding the fix.1 parent fda00a0 commit 3527d83
File tree
3 files changed
+22
-1
lines changed- src/Standards/Generic
- Sniffs/WhiteSpace
- Tests/WhiteSpace
3 files changed
+22
-1
lines changedLines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
0 commit comments