Conditions | 9 |
Paths | 12 |
Total Lines | 34 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 20 |
CRAP Score | 9.9957 |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
21 | 1 | public function compile($stmt, Context $context) |
|
22 | { |
||
23 | 1 | $context->getExpressionCompiler()->compile($stmt->cond); |
|
24 | |||
25 | 1 | if (count($stmt->cases)) { |
|
26 | 1 | foreach ($stmt->cases as $case) { |
|
27 | 1 | if ($case->cond) { |
|
28 | 1 | $context->getExpressionCompiler()->compile($case->cond); |
|
29 | 1 | } |
|
30 | |||
31 | 1 | if (count($case->stmts) > 0) { |
|
32 | 1 | $beforeStatement = false; |
|
33 | |||
34 | 1 | foreach ($case->stmts as $caseStatements) { |
|
35 | 1 | \PHPSA\nodeVisitorFactory($caseStatements, $context); |
|
36 | |||
37 | 1 | if ($beforeStatement) { |
|
38 | if ($beforeStatement instanceof \PhpParser\Node\Stmt\Return_ |
||
39 | 1 | && $caseStatements instanceof \PhpParser\Node\Stmt\Break_) { |
|
40 | $context->notice( |
||
41 | 'switch.unneeded-break', |
||
42 | 'Break after return statement is not needed', |
||
43 | $caseStatements |
||
44 | ); |
||
45 | } |
||
46 | 1 | } |
|
47 | 1 | $beforeStatement = $caseStatements; |
|
48 | 1 | } |
|
49 | 1 | } |
|
50 | 1 | } |
|
51 | 1 | } else { |
|
52 | $context->notice('switch.empty', 'Switch block is empty, lol', $stmt); |
||
53 | } |
||
54 | 1 | } |
|
55 | } |
||
56 |