DisallowLonelyIfSniff
in package
implements
Sniff
FinalYes
Disallow `if` statements as the only statement in an `else` block.
Note: This sniff will not fix the indentation of the "inner" code. It is strongly recommended to run
this sniff together with the Generic.WhiteSpace.ScopeIndent sniff to get the correct indentation.
Inspired by the ESLint "no lonely if" rule in response to upstream PHPCS issue 3206.
Tags
Table of Contents
Interfaces
Methods
- process() : void
- Processes this test, when one of its tokens is encountered.
- register() : array<string|int, int|string>
- Returns an array of tokens this test wants to listen for.
Methods
process()
Processes this test, when one of its tokens is encountered.
public
process(File $phpcsFile, int $stackPtr) : void
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the current token in the stack passed in $tokens.
Tags
register()
Returns an array of tokens this test wants to listen for.
public
register() : array<string|int, int|string>