Rule Definition
For readability reasons, ELSE and IF should be used instead of ELSEIF.
Remediation
Modify the source code to replace ELSEIF statements in Functions and Methods with ELSE IF.
Violation Code Sample
//….
if ($a > $b) {
echo "a is bigger than b";
} elseif ($a == $b) {
echo "a is equal to b";
} else {
echo "a is smaller than b";
}
Fixed Code Sample
<?php
if ($a > $b)
{
echo "a is bigger than b";
}
else {
if ($a == $b) {
echo "a is equal to b";
}
else {
echo "a is smaller than b";
}
}
?>
Reference
Code Sniffer - http://pear.php.net/package/PHP_CodeSniffer/docs/1.5.2/PHP_CodeSniffer/Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff.html
Related Technologies
Technical Criterion
Documentation - Style Conformity
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.