apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: JumbledIncrementerSniff

Source Location: /PHP_CodeSniffer-3.1.1/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php

Class Overview


Detects incrementer jumbling in for loops.


Author(s):

Copyright:

  • 2007-2014 Manuel Pichler. All rights reserved.

Methods


Inherited Variables

Inherited Methods


Class Details

[line 35]
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.

  1.  class Foo
  2.  {
  3.      public function bar($x)
  4.      {
  5.          for ($i = 0; $i < 10; $i++)
  6.          {
  7.              for ($k = 0; $k < 20; $i++)
  8.              {
  9.                  echo 'Hello';
  10.              }
  11.          }
  12.      }
  13.  }



[ Top ]


Method Detail

findIncrementers   [line 108]

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

[ Top ]

process   [line 60]

void process( File $phpcsFile, int $stackPtr)

Processes this test, when one of its tokens is encountered.
  • Access: public

Parameters:

\PHP_CodeSniffer\Files\File   $phpcsFile   —  The file being scanned.
int   $stackPtr   —  The position of the current token in the stack passed in $tokens.

[ Top ]

register   [line 44]

int[] register( )

Registers the tokens that this sniff wants to listen for.
  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:27:36 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.