MemberVarSpacingSniff
extends AbstractVariableSniff
in package
Table of Contents
Properties
- $spacing : int
- The number of blank lines between member vars.
- $spacingBeforeFirst : int
- The number of blank lines before the first member var.
- $phpReservedVars : array<string|int, mixed>
- List of PHP Reserved variables.
- $listenOutside : bool
- True if this test should fire on tokens outside of the scope.
- $scopeTokens : array<string|int, int|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.
Methods
- __construct() : mixed
- Constructs an AbstractVariableTest.
- process() : void|int
- Processes the tokens that this test is listening for.
- register() : array<string|int, int|string>
- The method that is called to register the tokens this test wishes to listen to.
- processMemberVar() : void|int
- Processes the function tokens within the class.
- processTokenOutsideScope() : void|int
- Processes the token outside the scope in the file.
- processTokenWithinScope() : void|int
- Processes the token in the specified PHP_CodeSniffer\Files\File.
- processVariable() : void
- Processes normal variables.
- processVariableInString() : void
- Processes variables in double quoted strings.
Properties
$spacing
The number of blank lines between member vars.
public
int
$spacing
= 1
$spacingBeforeFirst
The number of blank lines before the first member var.
public
int
$spacingBeforeFirst
= 1
$phpReservedVars
List of PHP Reserved variables.
protected
array<string|int, mixed>
$phpReservedVars
= ['_SERVER' => true, '_GET' => true, '_POST' => true, '_REQUEST' => true, '_SESSION' => true, '_ENV' => true, '_COOKIE' => true, '_FILES' => true, 'GLOBALS' => true, 'http_response_header' => true, 'HTTP_RAW_POST_DATA' => true, 'php_errormsg' => true]
Used by various naming convention sniffs.
$listenOutside
True if this test should fire on tokens outside of the scope.
private
bool
$listenOutside
= false
$scopeTokens
The type of scope opener tokens that this test wishes to listen to.
private
array<string|int, int|string>
$scopeTokens
= []
$tokens
The token types that this test wishes to listen to within the scope.
private
array<string|int, mixed>
$tokens
= []
Methods
__construct()
Constructs an AbstractVariableTest.
public
__construct() : mixed
process()
Processes the tokens that this test is listening for.
public
final process(File $phpcsFile, int $stackPtr) : void|int
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position in the stack where this token was found.
Tags
Return values
void|int —Optionally returns a stack pointer. The sniff will not be
called again on the current file until the returned stack
pointer is reached. Return $phpcsFile->numTokens
to skip
the rest of the file.
register()
The method that is called to register the tokens this test wishes to listen to.
public
final register() : array<string|int, int|string>
DO NOT OVERRIDE THIS METHOD. Use the constructor of this class to register for the desired tokens and scope.
Tags
Return values
array<string|int, int|string>processMemberVar()
Processes the function tokens within the class.
protected
processMemberVar(File $phpcsFile, int $stackPtr) : void|int
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position where the token was found.
Return values
void|int —Optionally returns a stack pointer. The sniff will not be called again on the current file until the returned stack pointer is reached.
processTokenOutsideScope()
Processes the token outside the scope in the file.
protected
final processTokenOutsideScope(File $phpcsFile, int $stackPtr) : void|int
Parameters
- $phpcsFile : File
-
The PHP_CodeSniffer file where this token was found.
- $stackPtr : int
-
The position where the token was found.
Return values
void|int —Optionally returns a stack pointer. The sniff will not be
called again on the current file until the returned stack
pointer is reached. Return $phpcsFile->numTokens
to skip
the rest of the file.
processTokenWithinScope()
Processes the token in the specified PHP_CodeSniffer\Files\File.
protected
final processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope) : void|int
Parameters
- $phpcsFile : File
-
The PHP_CodeSniffer file where this token was found.
- $stackPtr : int
-
The position where the token was found.
- $currScope : int
-
The current scope opener token.
Return values
void|int —Optionally returns a stack pointer. The sniff will not be
called again on the current file until the returned stack
pointer is reached. Return $phpcsFile->numTokens
to skip
the rest of the file.
processVariable()
Processes normal variables.
protected
processVariable(File $phpcsFile, int $stackPtr) : void
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position where the token was found.
processVariableInString()
Processes variables in double quoted strings.
protected
processVariableInString(File $phpcsFile, int $stackPtr) : void
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position where the token was found.