ArrayWalkingFunctionsHelper
in package
Helper functions and function lists for checking whether a function applies a callback to an array.
Tags
Table of Contents
Properties
- $arrayWalkingFunctions : array<string, array<string|int, mixed>>
- List of array functions which apply a callback to the array.
Methods
- get_callback_parameter() : array<string|int, mixed>|false
- Retrieve the parameter information for the callback parameter for an array walking function.
- get_functions() : array<string, bool>
- Retrieve a list of the supported "array walking" functions.
- is_array_walking_function() : bool
- Check if a particular function is an "array walking" function.
Properties
$arrayWalkingFunctions
List of array functions which apply a callback to the array.
private
static array<string, array<string|int, mixed>>
$arrayWalkingFunctions
= array('array_map' => array('position' => 1, 'name' => 'callback'), 'map_deep' => array('position' => 2, 'name' => 'callback'))
These are often used for sanitization/escaping an array variable.
Note: functions which alter the array by reference are not listed here on purpose. These cannot easily be used for sanitization as they can't be combined with unslashing. Similarly, they cannot be used for late escaping as the return value is a boolean, not the altered array.
Tags
Methods
get_callback_parameter()
Retrieve the parameter information for the callback parameter for an array walking function.
public
static get_callback_parameter(File $phpcsFile, int $stackPtr) : array<string|int, mixed>|false
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position of function call name token.
Tags
Return values
array<string|int, mixed>|false —Array with information on the callback parameter.
Or FALSE if the parameter is not found.
See the PHPCSUtils PassedParameters::getParameters() documentation
for the format of the returned (single-dimensional) array.
get_functions()
Retrieve a list of the supported "array walking" functions.
public
static get_functions() : array<string, bool>
Tags
Return values
array<string, bool>is_array_walking_function()
Check if a particular function is an "array walking" function.
public
static is_array_walking_function(string $functionName) : bool
Parameters
- $functionName : string
-
The name of the function to check.