CRITICAL
Rule Definition
Using function call in the test expression for a FOR loop decrease the performance of your application by calling the same function multiple times. Using variables is much faster and can improve the performance of the application.
Violation Code Sample
for ($i = 0; $i < getValue($a); $i++) {
$a[$i] *= $i;
}
Fixed Code Sample
$x = getValue($a)
for ($i = 0; $i < $x; $i++) {
$a[$i] *= $i;
}
Reference
Code Sniffer - https://pear.php.net/reference/PHP_CodeSniffer-latest/PHP_CodeSniffer/Generic_Sniffs_CodeAnalysis_ForLoopWithTestFunctionCallSniff.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.