1.2.1407. Useless Switch¶
This switch has only one case. It may very well be replaced by a ifthen structure.
<?php
switch($a) {
case 1:
doSomething();
break;
}
// Same as
if ($a == 1) {
doSomething();
}
?>
1.2.1407.1. Connex PHP features¶
1.2.1407.1.1. Suggestions¶
Turn the switch into a if/then for better readability
Add other cases to the switch, making it adapted to the situation
1.2.1407.1.2. Specs¶
Short name |
Structures/UselessSwitch |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
Examples |
|
Available in |