Generic_Sniffs_NamingConventions_ConstructorNameSniff
extends PHP_CodeSniffer_Standards_AbstractScopeSniff
in package
Generic_Sniffs_NamingConventions_ConstructorNameSniff.
Favor PHP 5 constructor syntax, which uses "function __construct()". Avoid PHP 4 constructor syntax, which uses "function ClassName()".
Tags
Table of Contents
- $_currentClass : string
- The name of the class we are currently checking.
- $_functionList : array<string|int, string>
- A list of functions in the current class.
- $_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 the test with the tokens it wishes to listen for.
- 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.
- loadFunctionNamesInScope() : void
- Extracts all the function names found in the given scope.
- processTokenOutsideScope() : void
- Processes a token that is found outside the scope that this test is listening to.
- processTokenWithinScope() : void
- Processes this test when one of its tokens is encountered.
Properties
$_currentClass
The name of the class we are currently checking.
private
string
$_currentClass
= ''
$_functionList
A list of functions in the current class.
private
array<string|int, string>
$_functionList
= array()
$_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 the test with the tokens it wishes to listen for.
public
__construct() : mixed
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
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
Return values
array<string|int, int> —loadFunctionNamesInScope()
Extracts all the function names found in the given scope.
protected
loadFunctionNamesInScope(PHP_CodeSniffer_File $phpcsFile, int $currScope) : void
Parameters
- $phpcsFile : PHP_CodeSniffer_File
-
The current file being scanned.
- $currScope : int
-
A pointer to the start of the scope.
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 this test when one of its tokens is encountered.
protected
processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, int $stackPtr, int $currScope) : void
Parameters
- $phpcsFile : PHP_CodeSniffer_File
-
The current file being scanned.
- $stackPtr : int
-
The position of the current token in the stack passed in $tokens.
- $currScope : int
-
A pointer to the start of the scope.