Documentation

Squiz_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff
in package

Squiz_Sniffs_NamingConventions_ValidVariableNameSniff.

Checks the naming of variables and member variables.

Tags
category

PHP

author

Greg Sherwood gsherwood@squiz.net

author

Marc McIntyre mmcintyre@squiz.net

copyright

2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)

license

https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence

version

Release: @package_version@

link
http://pear.php.net/package/PHP_CodeSniffer

Table of Contents

$currentFile  : PHP_CodeSniffer_File
The current PHP_CodeSniffer file that we are processing.
$_endFunction  : int
The end token of the current function that we are in.
$_functionOpen  : bool
TRUE if a function is currently open.
$_ignore  : array<string|int, mixed>
Tokens to ignore so that we can find a DOUBLE_COLON.
$_listenOutside  : bool
True if this test should fire on tokens outside of the scope.
$_scopeTokens  : string
The type of scope opener tokens that this test wishes to listen to.
$_tokens  : array<string|int, mixed>
The token types that this test wishes to listen to within the scope.
__construct()  : mixed
Constructs a new AbstractScopeTest.
process()  : void
Processes the tokens that this test is listening for.
register()  : array<string|int, int>
The method that is called to register the tokens this test wishes to listen to.
processMemberVar()  : void
Processes class member variables.
processTokenOutsideScope()  : void
Processes a token that is found outside the scope that this test is listening to.
processTokenWithinScope()  : void
Processes a token that is found within the scope that this test is listening to.
processVariable()  : void
Processes this test, when one of its tokens is encountered.
processVariableInString()  : void
Processes the variable found within a double quoted string.

Properties

$currentFile

The current PHP_CodeSniffer file that we are processing.

protected PHP_CodeSniffer_File $currentFile = ull

$_endFunction

The end token of the current function that we are in.

private int $_endFunction = -1

$_ignore

Tokens to ignore so that we can find a DOUBLE_COLON.

private array<string|int, mixed> $_ignore = array(T_WHITESPACE, T_COMMENT)

$_listenOutside

True if this test should fire on tokens outside of the scope.

private bool $_listenOutside = alse

$_scopeTokens

The type of scope opener tokens that this test wishes to listen to.

private string $_scopeTokens = array()

$_tokens

The token types that this test wishes to listen to within the scope.

private array<string|int, mixed> $_tokens = array()

Methods

__construct()

Constructs a new AbstractScopeTest.

public __construct(array<string|int, mixed> $scopeTokens, array<string|int, mixed> $tokens[, bool $listenOutside = false ]) : mixed
Parameters
$scopeTokens : array<string|int, mixed>

The type of scope the test wishes to listen to.

$tokens : array<string|int, mixed>

The tokens that the test wishes to listen to within the scope.

$listenOutside : bool = false

If true this test will also alert the extending class when a token is found outside the scope, by calling the processTokenOutsideScope method.

Tags
see

PHP_CodeSniffer.getValidScopeTokeners()

throws
PHP_CodeSniffer_Exception

If the specified tokens array is empty.

Return values
mixed

process()

Processes the tokens that this test is listening for.

public final process(PHP_CodeSniffer_File $phpcsFile, int $stackPtr) : void
Parameters
$phpcsFile : PHP_CodeSniffer_File

The file where this token was found.

$stackPtr : int

The position in the stack where this token was found.

Tags
see
processTokenWithinScope()
Return values
void

register()

The method that is called to register the tokens this test wishes to listen to.

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

DO NOT OVERRIDE THIS METHOD. Use the constructor of this class to register for the desired tokens and scope.

Tags
see
__constructor()
Return values
array<string|int, int>

processMemberVar()

Processes class member variables.

protected processMemberVar(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

processTokenOutsideScope()

Processes a token that is found outside the scope that this test is listening to.

protected processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, int $stackPtr) : void
Parameters
$phpcsFile : PHP_CodeSniffer_File

The file where this token was found.

$stackPtr : int

The position in the stack where this token was found.

Return values
void

processTokenWithinScope()

Processes a token that is found within the scope that this test is listening to.

protected abstract processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, int $stackPtr, int $currScope) : void
Parameters
$phpcsFile : PHP_CodeSniffer_File

The file where this token was found.

$stackPtr : int

The position in the stack where this token was found.

$currScope : int

The position in the tokens array that opened the scope that this test is listening for.

Return values
void

processVariable()

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

protected processVariable(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

processVariableInString()

Processes the variable found within a double quoted string.

protected processVariableInString(PHP_CodeSniffer_File $phpcsFile, int $stackPtr) : void
Parameters
$phpcsFile : PHP_CodeSniffer_File

The file being scanned.

$stackPtr : int

The position of the double quoted string.

Return values
void

Search results