PHP Classes

File: zray/vendor/PHP_CodeSniffer-2.2.0/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/ForLoopWithTestFunctionCallStandard.xml

Recommend this page to a friend!
  Classes of Simo  >  CodeIgniter Plugin for Z-Ray  >  zray/vendor/PHP_CodeSniffer-2.2.0/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/ForLoopWithTestFunctionCallStandard.xml  >  Download  
File: zray/vendor/PHP_CodeSniffer-2.2.0/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/ForLoopWithTestFunctionCallStandard.xml
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: CodeIgniter Plugin for Z-Ray
Show CodeIgniter application information in Z-Ray
Author: By
Last change:
Date: 3 months ago
Size: 746 bytes
 

Contents

Class file image Download
<documentation title="For Loops With Function Calls in the Test">
    <standard>
    <![CDATA[
    For loops should not call functions inside the test for the loop when they can be computed beforehand.
    ]]>
    </standard>
    <code_comparison>
        <code title="Valid: A for loop that determines its end condition before the loop starts.">
        <![CDATA[
<em>$end = count($foo);</em>
for ($i = 0; $i < $end; $i++) {
    echo $foo[$i]."\n";
}
        ]]>
        </code>
        <code title="Invalid: A for loop that unnecessarily computes the same value on every iteration.">
        <![CDATA[
for ($i = 0; $i < <em>count($foo)</em>; $i++) {
    echo $foo[$i]."\n";
}
        ]]>
        </code>
    </code_comparison>
</documentation>
For more information send a message to info at phpclasses dot org.