You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to propose a sniff that detects empty if and else blocks, since they never make any sense. Adding a comment inside the empty block would suppress the error, similar to DisallowEmptyFunctionSniff.
Empty elseif blocks can sometimes make sense if followed by other elseifs or an else.
Perhaps the sniff could even be fixable by extracting side-effects of the condition, however, it would be more useful if we can detect whether there are any side-effects at all, which I'm not sure is possible in phpcs.
The text was updated successfully, but these errors were encountered:
@jlherren Just so you know, the Generic.CodeAnalysis.EmptyStatement would largely fit your needs. Could possibly do with some fine-tuning, in which case, I suspect a PR would be welcome.
if ($true) {
} elseif($bar) {
} else {
// Do something.
}
I'd like to propose a sniff that detects empty
if
andelse
blocks, since they never make any sense. Adding a comment inside the empty block would suppress the error, similar toDisallowEmptyFunctionSniff
.Empty
elseif
blocks can sometimes make sense if followed by otherelseif
s or anelse
.Perhaps the sniff could even be fixable by extracting side-effects of the condition, however, it would be more useful if we can detect whether there are any side-effects at all, which I'm not sure is possible in phpcs.
The text was updated successfully, but these errors were encountered: