Commit fd9d74e
Generic/DisallowYodaConditions: improve code coverage
Includes removing two unreachable conditions
The first condition is unreachable because PHPCS will never call
DisallowYodaConditionsSniff::process() if there is no non-empty token before a
comparison token. Even if the file contains a syntax error, there must
be at least a PHP opening tag before the comparison token for the method
to be called.
The second condition is unreachable because at this point in the code
there will always be at least two non-empty tokens before the comparison
token. If there is only one, it must be a PHP opening tag and, in this
case, the method will bail before reaching the code that sets the
`$prevIndex` variable.
This commit also documents why a certain line is uncovered by tests - and cannot be
covered, nor can it be removed as external sniffs may call
`DisallowYodaConditionsSniff::isArrayStatic()` directly.1 parent e0b9580 commit fd9d74e
File tree
3 files changed
+17
-6
lines changed- src/Standards/Generic
- Sniffs/ControlStructures
- Tests/ControlStructures
3 files changed
+17
-6
lines changedLines changed: 2 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
| 60 | + | |
63 | 61 | | |
64 | 62 | | |
65 | 63 | | |
| |||
71 | 69 | | |
72 | 70 | | |
73 | 71 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | 72 | | |
78 | 73 | | |
79 | 74 | | |
| |||
150 | 145 | | |
151 | 146 | | |
152 | 147 | | |
| 148 | + | |
153 | 149 | | |
154 | 150 | | |
155 | 151 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| |||
0 commit comments