Documentation

SideEffectsSniff
in package
implements Sniff

Table of Contents

Interfaces

Sniff

Constants

CONDITION_TOKENS  = [T_IF => T_IF, T_ELSE => T_ELSE, T_ELSEIF => T_ELSEIF]
Condition tokens within which symbols may be defined.
SYMBOL_TOKENS  = [T_CLASS => T_CLASS, T_INTERFACE => T_INTERFACE, T_TRAIT => T_TRAIT, T_ENUM => T_ENUM, T_FUNCTION => T_FUNCTION]
Tokens which represent symbols in the context of this sniff.

Methods

process()  : int
Processes this sniff, when one of its tokens is encountered.
register()  : array<string|int, int|string>
Returns an array of tokens this test wants to listen for.
searchForConflict()  : array<string|int, mixed>
Searches for symbol declarations and side effects.

Constants

CONDITION_TOKENS

Condition tokens within which symbols may be defined.

private array<int|string, int|string> CONDITION_TOKENS = [T_IF => T_IF, T_ELSE => T_ELSE, T_ELSEIF => T_ELSEIF]

SYMBOL_TOKENS

Tokens which represent symbols in the context of this sniff.

private array<int|string, int|string> SYMBOL_TOKENS = [T_CLASS => T_CLASS, T_INTERFACE => T_INTERFACE, T_TRAIT => T_TRAIT, T_ENUM => T_ENUM, T_FUNCTION => T_FUNCTION]

Methods

process()

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

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

The file being scanned.

$stackPtr : int

The position of the current token in the token stack.

Return values
int

register()

Returns an array of tokens this test wants to listen for.

public register() : array<string|int, int|string>
Return values
array<string|int, int|string>

searchForConflict()

Searches for symbol declarations and side effects.

private searchForConflict(File $phpcsFile, int $start, int $end, array<string|int, mixed> $tokens) : array<string|int, mixed>

Returns the positions of both the first symbol declared and the first side effect in the file. A NULL value for either indicates nothing was found.

Parameters
$phpcsFile : File

The file being scanned.

$start : int

The token to start searching from.

$end : int

The token to search to.

$tokens : array<string|int, mixed>

The stack of tokens that make up the file.

Return values
array<string|int, mixed>

        
On this page

Search results