private checkCaseStatement ( PhpParser\Node\Stmt\Case_ $case, |
||
$case | PhpParser\Node\Stmt\Case_ | |
$context | ||
return | boolean |
private function checkCaseStatement(Stmt\Case_ $case, Context $context)
{
/*
* switch(…) {
* case 41:
* case 42:
* case 43:
* return 'the truth, or almost.';
* }
*/
if (!$case->stmts) {
return false;
}
foreach ($case->stmts as $node) {
// look for a break statement
if ($node instanceof Stmt\Break_) {
return false;
}
// or for a return
if ($node instanceof Stmt\Return_) {
return false;
}
}
$context->notice('missing_break_statement', 'Missing "break" statement', $case);
return true;
}