1.2.1217. Too Many Stringed Elseif¶
This rule also takes into account else if
structures.
<?php
if ($a === 1) { }
elseif ($a === 2) { }
elseif ($a === 3) { }
else if ($a === 4) { } // else if
elseif ($a === 5) { }
?>
Name |
Default |
Type |
Description |
maxIf |
5 |
integer |
Maximum number of allowed stringed if-then-elseif structure. |
See also Bail Out Early.
1.2.1217.1. Suggestions¶
Replace the if-then with a loop
Use the bail early strategy to isolate the if-then
1.2.1217.2. Specs¶
Short name |
Structures/TooManyElseif |
Rulesets |
|
Exakat since |
2.3.6 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |