Commit 7fc2e87
committed
Squiz/NonExecutableCode: only ignore inline statements when PHP allows them
Aside from `T_EXIT`, PHP (prior to PHP 8.0) does not allow for the inline use of the other tokens this sniff registers.
While using those tokens inline would result in a parse error, that is not the concern of this sniff.
By ignoring these, the sniff causes false negatives.
This commit makes the sniff more selective and only ignores inline statements for tokens which are allowed in inline statements.
Includes unit test.1 parent 272aa59 commit 7fc2e87
File tree
3 files changed
+31
-4
lines changed- src/Standards/Squiz
- Sniffs/PHP
- Tests/PHP
3 files changed
+31
-4
lines changedLines changed: 18 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
19 | 29 | | |
20 | 30 | | |
21 | 31 | | |
| |||
49 | 59 | | |
50 | 60 | | |
51 | 61 | | |
52 | | - | |
53 | | - | |
54 | 62 | | |
55 | | - | |
56 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
57 | 71 | | |
58 | 72 | | |
59 | 73 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
300 | 311 | | |
301 | 312 | | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| |||
0 commit comments