PHPCheckstyle / phpcheckstyle

PHPCheckstyle is an open-source tool that helps PHP programmers adhere to certain coding conventions.
https://github.com/PHPCheckstyle/phpcheckstyle
GNU Lesser General Public License v3.0
164 stars 31 forks source link

Grouped cases must contain a break #24

Closed jbrooksuk closed 7 years ago

jbrooksuk commented 10 years ago

When a select or switch has multiple cases that join together:

case T_COMMENT:
case T_ML_COMMENT:
case T_DOC_COMMENT:
    $this->_processComment($token);
    break;

The The case statement must contain a break. warning is being returned. We need to add a check on the case token that it's not immediately followed by another case.

jbrooksuk commented 10 years ago

For the checks within PHPCheckstyle, I've just put @SuppressWarnings where needed.

jbrooksuk commented 10 years ago

From my brief look through the switch handling, I'm pretty sure that PHPCheckstyle.php is already accounting for this, but it's just not working? Is this correct @tchule?

tchule commented 10 years ago

I don't remember having handled this case. We can say that a case need a break, except when it is an empty case.

jbrooksuk commented 10 years ago

I think that's a good way of doing it, but so long as it's empty & followed by another case.