Generic_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff
in package
implements
PHP_CodeSniffer_Sniff
Detects for-loops that can be simplified to a while-loop.
This rule is based on the PMD rule catalog. Detects for-loops that can be simplified as a while-loop.
class Foo
{
public function bar($x)
{
for (;true;) true; // No Init or Update part, may as well be: while (true)
}
}
Tags
Interfaces, Classes and Traits
- PHP_CodeSniffer_Sniff
- Represents a PHP_CodeSniffer sniff for sniffing coding standards.
Table of Contents
- process() : void
- Processes this test, when one of its tokens is encountered.
- register() : array<string|int, int>
- Registers the tokens that this sniff wants to listen for.
Methods
process()
Processes this test, when one of its tokens is encountered.
public
process(PHP_CodeSniffer_File $phpcsFile, int $stackPtr) : void
Parameters
- $phpcsFile : PHP_CodeSniffer_File
-
The file being scanned.
- $stackPtr : int
-
The position of the current token in the stack passed in $tokens.
Return values
void —register()
Registers the tokens that this sniff wants to listen for.
public
register() : array<string|int, int>