FunctionDeclarationSniff
extends AbstractPatternSniff
in package
Table of Contents
Properties
- $ignoreComments : bool
- If true, comments will be ignored if they are found in the code.
- $currFile : string
- The current file being checked.
Methods
- __construct() : mixed
- Constructs a AbstractPatternSniff.
- process() : void
- Processes the test.
- register() : array<string|int, int|string>
- Registers the tokens to listen to.
- getPatterns() : array<string|int, mixed>
- Returns an array of patterns to check are correct.
- prepareError() : string
- Prepares an error for the specified patternCode.
- processPattern() : array<string|int, mixed>|false
- Processes the pattern and verifies the code at $stackPtr.
- processSupplementary() : void
- Processes any tokens registered with registerSupplementary().
- registerSupplementary() : array<string|int, int>
- Registers any supplementary tokens that this test might wish to process.
Properties
$ignoreComments
If true, comments will be ignored if they are found in the code.
public
bool
$ignoreComments
= false
$currFile
The current file being checked.
protected
string
$currFile
= ''
Methods
__construct()
Constructs a AbstractPatternSniff.
public
__construct([bool $ignoreComments = null ]) : mixed
Parameters
- $ignoreComments : bool = null
-
If true, comments will be ignored.
process()
Processes the test.
public
final process(File $phpcsFile, int $stackPtr) : void
Parameters
- $phpcsFile : File
-
The PHP_CodeSniffer file where the token occurred.
- $stackPtr : int
-
The position in the tokens stack where the listening token type was found.
Tags
register()
Registers the tokens to listen to.
public
final register() : array<string|int, int|string>
Classes extending AbstractPatternTest should implement the getPatterns() method to register the patterns they wish to test.
Tags
Return values
array<string|int, int|string>getPatterns()
Returns an array of patterns to check are correct.
protected
getPatterns() : array<string|int, mixed>
Return values
array<string|int, mixed>prepareError()
Prepares an error for the specified patternCode.
protected
prepareError(string $found, string $patternCode) : string
Parameters
- $found : string
-
The actual found string in the code.
- $patternCode : string
-
The expected pattern code.
Return values
string —The error message.
processPattern()
Processes the pattern and verifies the code at $stackPtr.
protected
processPattern(array<string|int, mixed> $patternInfo, File $phpcsFile, int $stackPtr) : array<string|int, mixed>|false
Parameters
- $patternInfo : array<string|int, mixed>
-
Information about the pattern used for checking, which includes are parsed token representation of the pattern.
- $phpcsFile : File
-
The PHP_CodeSniffer file where the token occurred.
- $stackPtr : int
-
The position in the tokens stack where the listening token type was found.
Return values
array<string|int, mixed>|falseprocessSupplementary()
Processes any tokens registered with registerSupplementary().
protected
processSupplementary(File $phpcsFile, int $stackPtr) : void
Parameters
- $phpcsFile : File
-
The PHP_CodeSniffer file where to process the skip.
- $stackPtr : int
-
The position in the tokens stack to process.
Tags
registerSupplementary()
Registers any supplementary tokens that this test might wish to process.
protected
registerSupplementary() : array<string|int, int>
A sniff may wish to register supplementary tests when it wishes to group an arbitrary validation that cannot be performed using a pattern, with other pattern tests.