Documentation

Squiz_Sniffs_PHP_ForbiddenFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff
in package

Squiz_Sniffs_PHP_ForbiddenFunctionsSniff.

Discourages the use of alias functions that are kept in PHP for compatibility with older versions. Can be used to forbid the use of any function.

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

$error  : bool
If true, an error will be thrown; otherwise a warning.
$forbiddenFunctions  : mixed
A list of forbidden 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

$forbiddenFunctions

A list of forbidden functions with their alternatives.

public mixed $forbiddenFunctions = array('sizeof' => 'count', 'delete' => 'unset', 'print' => 'echo', 'is_null' => ull, 'create_function' => ull)

The value is NULL if no alternative exists. IE, the function should just not be used.

$forbiddenFunctionNames

A cache of forbidden function names, for faster lookups.

protected array<string|int, mixed>|(string) $forbiddenFunctionNames = array()

$patternMatch

If true, forbidden functions will be considered regular expressions.

protected bool $patternMatch = alse

Methods

process()

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

public process(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

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(PHP_CodeSniffer_File $phpcsFile, int $stackPtr, string $function[, string $pattern = null ]) : void
Parameters
$phpcsFile : PHP_CodeSniffer_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.

Return values
void

Search results