-
Notifications
You must be signed in to change notification settings - Fork 162
Closed
Labels
need to discussRule requires discussionRule requires discussionnew ruleNew feature implementationNew feature implementationproposalNew rule proposalNew rule proposalwaiting for feedbackAdditional explanation neededAdditional explanation needed
Description
Rule
Function
/method
call in for
loop declaration MUST be avoided.
Reason
PHP will call the method
/function
on each iteration of the for
loop.
Bad Example:
for ($i = 0; $i < count($array); $i++){
//code goes here
}
Good example:
$count = count($array);
for ($i = 0; $i < $count; $i++){
//code goes here
}
Implementation
- Subscribe to the
T_FOR
token. - Check if condition contains function call (
T_STRING
with followed by open parentheses).
buskamuza and navarr
Metadata
Metadata
Assignees
Labels
need to discussRule requires discussionRule requires discussionnew ruleNew feature implementationNew feature implementationproposalNew rule proposalNew rule proposalwaiting for feedbackAdditional explanation neededAdditional explanation needed