Class: Generic_Sniffs_CodeAnalysis_JumbledIncrementerSniff
Source Location: /PHP_CodeSniffer-2.1.0/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php
Detects incrementer jumbling in for loops.
Author(s):
Version:
Copyright:
- 2007-2014 Manuel Pichler. All rights reserved.
Inherited Variables
Inherited Methods
Class Details
[line 47]
Detects incrementer jumbling in for loops.
This rule is based on the PMD rule catalog. The jumbling incrementer sniff detects the usage of one and the same incrementer into an outer and an inner loop. Even it is intended this is confusing code.
class Foo
{
public function bar($x)
{
for ($i = 0; $i < 10; $i++)
{
for ($k = 0; $k < 20; $i++)
{
echo 'Hello';
}
}
}
}
Method Detail
findIncrementers [line 120]
string[] findIncrementers(
array
$tokens, array
$token)
Get all used variables in the incrementer part of a for statement.
- Return: List of all found incrementer variables.
- Access: protected
Parameters:
array(integer=>array)
$tokens
—
Array with all code sniffer tokens.
array(string=>mixed)
$token
—
Current for loop token
process [line 72]
Processes this test, when one of its tokens is encountered.
Parameters:
int
$stackPtr
—
The position of the current token in the stack passed in $tokens.
register [line 56]
Registers the tokens that this sniff wants to listen for.
Documentation generated on 2019年3月11日 16:00:53 -0400 by
phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.