Documentation

DisallowStandalonePostIncrementDecrementSniff
in package
implements Sniff

FinalYes

Disallow the use of post-in/decrements in stand-alone statements and discourage the use of multiple increment/decrement operators in a stand-alone statement.

Post-in/decrement returns the value and in/decrements afterwards. Pre-in/decrement in/decrements the value and returns afterwards. Using pre-in/decrement is more in line with the principle of least astonishment and prevents bugs when code gets moved around at a later point in time.

Tags
since
1.0.0

Table of Contents

Interfaces

Sniff

Constants

METRIC_NAME  = 'In/decrement usage in stand-alone statements'
Name of the metric.

Properties

$allowedTokens  : array<string|int, int|string>
Tokens which can be expected in a stand-alone in/decrement statement.

Methods

process()  : int|void
Processes this test, when one of its tokens is encountered.
register()  : array<string|int, int|string>
Registers the tokens that this sniff wants to listen for.

Constants

Properties

Methods

process()

Processes this test, when one of its tokens is encountered.

public process(File $phpcsFile, int $stackPtr) : int|void
Parameters
$phpcsFile : File

The file being scanned.

$stackPtr : int

The position of the current token in the stack passed in $tokens.

Tags
since
1.0.0
Return values
int|void

Integer stack pointer to skip forward or void to continue normal file processing.


        
On this page

Search results