CRITICAL
Rule Definition
For performance reasons, WHILE loops are preferred to FOR loops.
Remediation
Modify the source code to reduce the number of FOR loops which can be simplified to WHILE loops.
Violation Code Sample
class CastTest
{
public function test($x)
{
for (;true;) true; // there is no init or update part so it can be as well be: while (true)
}
}
Fixed Code Sample
class CastTest
{
public function test($x)
{
while (true) true;
}
}
Reference
Code Sniffer - http://pear.php.net/package/PHP_CodeSniffer/docs/1.5.2/PHP_CodeSniffer/Generic_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff.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.