1.2.537. Identical Case In Switch¶
In a switch() or match() statement, when there are identical cases, it means that multiple case labels that have the same code block.
This can happen by mistake or design. They may be merged together.
<?php
switch($a) {
case 1:
$b = 2;
break;
case 2:
$b = 12;
break;
// Identical to case 1
case 3:
$b = 2;
break;
}
?>
1.2.537.1. Connex PHP features¶
1.2.537.1.1. Suggestions¶
Merge the cases and reduce the size of code
Review the cases code and make them different
1.2.537.1.2. Specs¶
Short name |
Structures/IdenticalCase |
Rulesets |
|
Exakat since |
2.5.3 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |