CRITICAL
Rule Definition
Using curly braces with the control statements increases readability and decreases the likelihood of logical errors being introduced when new code lines are added.
Remediation
Use curly braces with the control statements even in situations where they are technically optional.
Violation Code Sample
Sample 1 : if ($variable1==1) echo '1';
Sample 2:
foreach ($stringParade as $hit)
$hitParade[] = $hit + 0; //cast to integer
Fixed Code Sample
Remediation for Sample 1:
if ($variable1==1) {
echo '1';
}
Remediation for Sample 2:
foreach ($stringParade as $hit) {
$hitParade[] = $hit + 0; //cast to integer
}
Reference
https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php
http://pear.php.net/package/PHP_CodeSniffer/docs/2.5.1/PHP_CodeSniffer/Generic_Sniffs_ControlStructures_InlineControlStructureSniff.html
Related Technologies
Technical Criterion
Complexity - Algorithmic and Control Structure Complexity
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.