DiscouragedFunctionsSniff
extends ForbiddenFunctionsSniff
in package
Discouraged Functions Sniff
Discourages the use of debug functions.
Tags
Table of Contents
- $error : bool
- Set error to false to show warnings.
- $forbiddenFunctions : mixed
- A list of discouraged functions with their alternatives.
- $forbiddenFunctionNames : array<string|int, mixed>|(string)
- A cache of forbidden function names, for faster lookups.
- $patternMatch : bool
- If true, forbidden functions will be considered regular expressions.
- process() : void
- Processes this test, when one of its tokens is encountered.
- register() : array<string|int, mixed>
- Returns an array of tokens this test wants to listen for.
- addError() : void
- Generates the error or warning for this sniff.
Properties
$error
Set error to false to show warnings.
public
bool
$error
= false
$forbiddenFunctions
A list of discouraged functions with their alternatives.
public
mixed
$forbiddenFunctions
= ['error_log' => null, 'print_r' => null, 'var_dump' => null]
The value is NULL if no alternative exists. IE, the function should just not be used.
array|null)
$forbiddenFunctionNames
A cache of forbidden function names, for faster lookups.
protected
array<string|int, mixed>|(string)
$forbiddenFunctionNames
= []
$patternMatch
If true, forbidden functions will be considered regular expressions.
protected
bool
$patternMatch
= false
Methods
process()
Processes this test, when one of its tokens is encountered.
public
process(File $phpcsFile, int $stackPtr) : void
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the current token in the stack passed in $tokens.
Return values
void —register()
Returns an array of tokens this test wants to listen for.
public
register() : array<string|int, mixed>
Return values
array<string|int, mixed> —addError()
Generates the error or warning for this sniff.
protected
addError(File $phpcsFile, int $stackPtr, string $function[, string $pattern = null ]) : void
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the forbidden function in the token array.
- $function : string
-
The name of the forbidden function.
- $pattern : string = null
-
The pattern used for the match.