SANDBOX_PREFIX
SANDBOX_PREFIX
PHPSandbox class for PHP Sandboxes.
This class encapsulates the entire functionality of a PHPSandbox so that an end user only has to create a PHPSandbox instance, configure its options, and run their code
$allow_backticks : boolean
$sandboxes : array<mixed,\PHPSandbox\PHPSandbox>
$last_validation_error : \Exception|\PHPSandbox\Error
__construct(array $options = array(), array $functions = array(), array $variables = array(), array $constants = array(), array $namespaces = array(), array $aliases = array(), array $superglobals = array(), array $magic_constants = array(), array $classes = array(), array $interfaces = array(), array $traits = array())
PHPSandbox class constructor
array | $options | Optional array of options to set for the sandbox |
array | $functions | Optional array of functions to define for the sandbox |
array | $variables | Optional array of variables to define for the sandbox |
array | $constants | Optional array of constants to define for the sandbox |
array | $namespaces | Optional array of namespaces to define for the sandbox |
array | $aliases | Optional array of aliases to define for the sandbox |
array | $superglobals | Optional array of superglobals to define for the sandbox |
array | $magic_constants | Optional array of magic constants to define for the sandbox |
array | $classes | Optional array of classes to define for the sandbox |
array | $interfaces | Optional array of interfaces to define for the sandbox |
array | $traits | Optional array of traits to define for the sandbox |
** File not found : $sandbox **
create(array $options = array(), array $functions = array(), array $variables = array(), array $constants = array(), array $namespaces = array(), array $aliases = array(), array $superglobals = array(), array $magic_constants = array(), array $classes = array(), array $interfaces = array(), array $traits = array()) : $this
PHPSandbox static factory method
You can pass optional arrays of predefined functions, variables, etc. to the sandbox through the constructor
array | $options | Optional array of options to set for the sandbox |
array | $functions | Optional array of functions to define for the sandbox |
array | $variables | Optional array of variables to define for the sandbox |
array | $constants | Optional array of constants to define for the sandbox |
array | $namespaces | Optional array of namespaces to define for the sandbox |
array | $aliases | Optional array of aliases to define for the sandbox |
array | $superglobals | Optional array of superglobals to define for the sandbox |
array | $magic_constants | Optional array of magic constants to define for the sandbox |
array | $classes | Optional array of classes to define for the sandbox |
array | $interfaces | Optional array of interfaces to define for the sandbox |
array | $traits | Optional array of traits to define for the sandbox |
The returned PHPSandbox variable
** File not found : $sandbox **
__invoke(\Closure|callable|string $code) : mixed
PHPSandbox __invoke magic method
Besides the code or closure to be executed, you can also pass additional arguments that will overwrite the default values of their respective arguments defined in the code
\Closure|callable|string | $code | The closure, callable or string of code to execute |
The output of the executed sandboxed code
** File not found : $sandbox **
import(array|string $template, integer $import_flag) : $this
Import JSON template into sandbox
array|string | $template | The JSON array or string template to import |
integer | $import_flag | Binary flags signifying which parts of the JSON template to import |
Throws exception if JSON template could not be imported
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->import(['code' **
** File not found : $sandbox->import(file_get_contents("template.json")); **
importJSON(array|string $template, integer $import_flag) : $this
Import JSON template into sandbox
array|string | $template | The JSON array or string template to import |
integer | $import_flag | Binary flags signifying which parts of the JSON template to import |
Throws exception if JSON template could not be imported
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->importJSON(['code' **
** File not found : $sandbox->importJSON(file_get_contents("template.json")); **
setOption(string|array $option, boolean|integer|null $value = null) : $this
Set PHPSandbox option
You can pass an $option name to set to $value, an array of $option names to set to $value, or an associative array of $option names and their values to set.
string|array | $option | String or array of strings or associative array of keys of option names to set $value to |
boolean|integer|null | $value | Boolean, integer or null $value to set $option to (optional) |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setOption(['allow_functions' **
** File not found : $sandbox->setOption(['allow_functions', **
** File not found : $sandbox->setOption('allow_functions', **
setOptions(array|string $options, boolean|integer|null $value = null) : $this
Set PHPSandbox options by array
You can pass an array of option names to set to $value, or an associative array of option names and their values to set.
array|string | $options | Array of strings or associative array of keys of option names to set $value to, or JSON array or string template to import |
boolean|integer|null | $value | Boolean, integer or null $value to set $option to (optional) |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setOption(['allow_functions' **
** File not found : $sandbox->setOption(['allow_functions', **
getOption(string $option) : boolean|integer|null
Get PHPSandbox option
You pass a string $option name to get its associated value
string | $option | String of $option name to get |
Returns the value of the requested option
** File not found : $sandbox->getOption('allow_functions'); **
setValidator(string $type, callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for specified $type
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
string | $type | String of $type name to set validator for |
callable | $callable | Callable that validates the passed element |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setValidator('function', **
unsetValidator(string $type) : \PHPSandbox\PHPSandbox
Unset validation callable for specified $type
string | $type | String of $type to unset |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetValidator('function'); **
setFuncValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for functions
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance. NOTE: Normalized function names include the namespace and are lowercase!
callable | $callable | Callable that validates the normalized passed function name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setFuncValidator(function($function, **
unsetFuncValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for functions
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetFuncValidator(); **
setVarValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for variables
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
callable | $callable | Callable that validates the passed variable name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setVarValidator(function($variable, **
unsetVarValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for variables
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetVarValidator(); **
setGlobalValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for globals
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
callable | $callable | Callable that validates the passed global name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setGlobalValidator(function($global, **
unsetGlobalValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for globals
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetGlobalValidator(); **
setSuperglobalValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for superglobals
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance. NOTE: Normalized superglobal names are uppercase and without a leading _
callable | $callable | Callable that validates the passed superglobal name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setSuperglobalValidator(function($superglobal, **
unsetSuperglobalValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for superglobals
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetSuperglobalValidator(); **
setConstValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for constants
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
callable | $callable | Callable that validates the passed constant name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setConstValidator(function($constant, **
unsetConstValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for constants
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetConstValidator(); **
setMagicConstValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for magic constants
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance. NOTE: Normalized magic constant names are upper case and trimmed of __
callable | $callable | Callable that validates the passed magic constant name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setMagicConstValidator(function($magic_constant, **
unsetMagicConstValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for magic constants
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetMagicConstValidator(); **
setNamespaceValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for namespaces
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
callable | $callable | Callable that validates the passed namespace name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setNamespaceValidator(function($namespace, **
unsetNamespaceValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for namespaces
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetNamespaceValidator(); **
setAliasValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for aliases
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
callable | $callable | Callable that validates the passed alias name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setAliasValidator(function($alias, **
unsetAliasValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for aliases
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetAliasValidator(); **
setUseValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for uses (aka aliases)
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
callable | $callable | Callable that validates the passed use (aka alias) name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setUseValidator(function($use, **
unsetUseValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for uses (aka aliases)
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetUseValidator(); **
setClassValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for classes
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance. NOTE: Normalized class names are lowercase
callable | $callable | Callable that validates the passed class name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setClassValidator(function($class, **
unsetClassValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for classes
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetClassValidator(); **
setInterfaceValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for interfaces
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance. NOTE: Normalized interface names are lowercase
callable | $callable | Callable that validates the passed interface name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setInterfaceValidator(function($interface, **
unsetInterfaceValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for interfaces
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetInterfaceValidator(); **
setTraitValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for traits
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance. NOTE: Normalized trait names are lowercase
callable | $callable | Callable that validates the passed trait name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setTraitValidator(function($trait, **
unsetTraitValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for traits
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetTraitValidator(); **
setKeywordValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for keywords
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
callable | $callable | Callable that validates the passed keyword name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setKeywordValidator(function($keyword, **
unsetKeywordValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for keywords
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetKeywordValidator(); **
setOperatorValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for operators
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
callable | $callable | Callable that validates the passed operator name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setOperatorValidator(function($operator, **
unsetOperatorValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for operators
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetOperatorValidator(); **
setPrimitiveValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for primitives
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
callable | $callable | Callable that validates the passed primitive name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setPrimitiveValidator(function($primitive, **
unsetPrimitiveValidator() : \PHPSandbox\PHPSandbox
Unset validation callable for primitives
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->unsetPrimitiveValidator(); **
setTypeValidator(callable $callable) : \PHPSandbox\PHPSandbox
Set validation callable for types
Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
callable | $callable | Callable that validates the passed type name |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setTypeValidator(function($type, **
_get_defined_functions(array $functions = array()) : array
Get PHPSandbox redefined functions in place of get_defined_functions(). This is an internal PHPSandbox function but requires public access to work.
array | $functions | Array result from get_defined_functions() is passed here |
Returns the redefined functions array
_get_defined_vars(array $variables = array()) : array
Get PHPSandbox redefined variables in place of get_defined_vars(). This is an internal PHPSandbox function but requires public access to work.
array | $variables | Array result from get_defined_vars() is passed here |
Returns the redefined variables array
_get_magic_const(string $name) : array
Get PHPSandbox redefined magic constant. This is an internal PHPSandbox function but requires public access to work.
string | $name | Requested magic constant name (e.g. FILE, LINE, etc.) |
Returns the redefined magic constant
_get_defined_constants(array $constants = array()) : array
Get PHPSandbox redefined constants in place of get_defined_constants(). This is an internal PHPSandbox function but requires public access to work.
array | $constants | Array result from get_defined_constants() is passed here |
Returns the redefined constants
_get_declared_classes(array $classes = array()) : array
Get PHPSandbox redefined classes in place of get_declared_classes(). This is an internal PHPSandbox function but requires public access to work.
array | $classes | Array result from get_declared_classes() is passed here |
Returns the redefined classes
_get_declared_interfaces(array $interfaces = array()) : array
Get PHPSandbox redefined interfaces in place of get_declared_interfaces(). This is an internal PHPSandbox function but requires public access to work.
array | $interfaces | Array result from get_declared_interfaces() is passed here |
Returns the redefined interfaces
_get_declared_traits(array $traits = array()) : array
Get PHPSandbox redefined traits in place of get_declared_traits(). This is an internal PHPSandbox function but requires public access to work.
array | $traits | Array result from get_declared_traits() is passed here |
Returns the redefined traits
_func_get_arg(array $arguments = array(), integer $index) : array
Get PHPSandbox redefined function argument
array | $arguments | Array result from func_get_args() is passed here |
integer | $index | Requested func_get_arg index is passed here |
Returns the redefined argument
define(string|array $type, string|array|null $name = null, mixed|null $value = null) : $this
Define PHPSandbox definitions, such as functions, constants, namespaces, etc.
You can pass a string of the $type, $name and $value, or pass an associative array of definitions types and an associative array of their corresponding values
string|array | $type | Associative array or string of definition type to define |
string|array|null | $name | Associative array or string of definition name to define |
mixed|null | $value | Value of definition to define |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->define('functions', **
** File not found : $sandbox->define(['functions' **
undefine(string|array $type, string|array $name = null) : $this
Undefine PHPSandbox definitions, such as functions, constants, namespaces, etc.
You can pass a string of the $type and $name to undefine, or pass an associative array of definitions types and an array of key names to undefine
string|array | $type | Associative array or string of definition type to undefine |
string|array | $name | Associative array or string of definition name to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefine('functions', **
** File not found : $sandbox->undefine(['functions' **
defineFunc(string|array $name, callable $function, boolean $pass_sandbox = false) : $this
Define PHPSandbox function
You can pass the function $name and $function closure or callable to define, or an associative array of functions to define, which can have callable values or arrays of the function callable and $pass_sandbox flag
string|array | $name | Associative array or string of function $name to define |
callable | $function | Callable to define $function to |
boolean | $pass_sandbox | Pass PHPSandbox instance to defined function when called? Default is false |
Throws exception if unnamed or uncallable $function is defined
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineFunc('test', **
** File not found : $sandbox->defineFunc(['test' **
** File not found : $sandbox->defineFunc(['test' **
defineFuncs(array $functions = array()) : $this
Define PHPSandbox functions by array
You can pass an associative array of functions to define
array | $functions | Associative array of $functions to define |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineFuncs(['test' **
hasDefinedFuncs() : integer
Query whether PHPSandbox instance has defined functions
Returns the number of functions this instance has defined
** File not found : $sandbox->hasDefinedFuncs(); **
isDefinedFunc(string $name) : boolean
Check if PHPSandbox instance has $name function defined
string | $name | String of function $name to query |
Returns true if PHPSandbox instance has defined function, false otherwise
** File not found : $sandbox->isDefinedFunc('test'); **
undefineFunc(string|array $name) : $this
Undefine PHPSandbox function
You can pass a string of function $name to undefine, or pass an array of function names to undefine
string|array | $name | String of function name or array of function names to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineFunc('test'); **
** File not found : $sandbox->undefineFunc(['test', **
undefineFuncs(array $functions = array()) : $this
Undefine PHPSandbox functions by array
You can pass an array of function names to undefine, or an empty array or null argument to undefine all functions
array | $functions | Array of function names to undefine. Passing an empty array or no argument will result in undefining all functions |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineFuncs(['test', **
** File not found : $sandbox->undefineFuncs(); **
defineVar(string|array $name, mixed $value) : $this
Define PHPSandbox variable
You can pass the variable $name and $value to define, or an associative array of variables to define
string|array | $name | String of variable $name or associative array to define |
mixed | $value | Value to define variable to |
Throws exception if unnamed variable is defined
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineVar('test', **
** File not found : $sandbox->defineVar(['test' **
defineVars(array $variables = array()) : $this
Define PHPSandbox variables by array
You can pass an associative array of variables to define
array | $variables | Associative array of $variables to define |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineVars(['test' **
isDefinedVar(string $name) : boolean
Check if PHPSandbox instance has $name variable defined
string | $name | String of variable $name to query |
Returns true if PHPSandbox instance has defined variable, false otherwise
** File not found : $sandbox->isDefinedVar('test'); **
undefineVar(string|array $name) : $this
Undefine PHPSandbox variable
You can pass a string of variable $name to undefine, or an array of variable names to undefine
string|array | $name | String of variable name or an array of variable names to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineVar('test'); **
** File not found : $sandbox->undefineVar(['test', **
undefineVars(array $variables = array()) : $this
Undefine PHPSandbox variables by array
You can pass an array of variable names to undefine, or an empty array or null argument to undefine all variables
array | $variables | Array of variable names to undefine. Passing an empty array or no argument will result in undefining all variables |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineVars(['test', **
** File not found : $sandbox->undefineVars(); **
defineSuperglobal(string|array $name, mixed $value) : $this
Define PHPSandbox superglobal
You can pass the superglobal $name and $value to define, or an associative array of superglobals to define, or a third variable to define the $key
string|array | $name | String of superglobal $name or associative array of superglobal names to define |
mixed | $value | Value to define superglobal to, can be callable |
Throws exception if unnamed superglobal is defined
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineSuperglobal('_GET', **
** File not found : $sandbox->defineSuperglobal(['_GET' **
** File not found : $sandbox->defineSuperglobal('_GET', **
defineSuperglobals(array $superglobals = array()) : $this
Define PHPSandbox superglobals by array
You can pass an associative array of superglobals to define
array | $superglobals | Associative array of $superglobals to define |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineSuperglobals(['_GET' **
hasDefinedSuperglobals(string|null $name = null) : integer|boolean
Query whether PHPSandbox instance has defined superglobals, or if superglobal $name has defined keys
string|null | $name | String of superglobal $name to check for keys |
Returns the number of superglobals or superglobal keys this instance has defined, or false if invalid superglobal name specified
** File not found : $sandbox->hasDefinedSuperglobals(); **
** File not found : $sandbox->hasDefinedSuperglobals('_GET'); **
isDefinedSuperglobal(string $name, string|null $key = null) : boolean
Check if PHPSandbox instance has $name superglobal defined, or if superglobal $name key is defined
string | $name | String of superglobal $name to query |
string|null | $key | String of key to to query in superglobal |
Returns true if PHPSandbox instance has defined superglobal, false otherwise
** File not found : $sandbox->isDefinedSuperglobal('_GET'); **
** File not found : $sandbox->isDefinedSuperglobal('_GET', **
undefineSuperglobal(string|array $name, string|null $key = null) : $this
Undefine PHPSandbox superglobal or superglobal key
You can pass a string of superglobal $name to undefine, or a superglobal $key to undefine, or an array of superglobal names to undefine, or an an associative array of superglobal names and keys to undefine
string|array | $name | String of superglobal $name, or array of superglobal names, or associative array of superglobal names and keys to undefine |
string|null | $key | String of superglobal $key to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineSuperglobal('_GET'); **
** File not found : $sandbox->undefineSuperglobal('_GET', **
** File not found : $sandbox->undefineSuperglobal(['_GET', **
undefineSuperglobals(array $superglobals = array()) : $this
Undefine PHPSandbox superglobals by array
You can pass an array of superglobal names to undefine, or an associative array of superglobals names and key to undefine, or an empty array or null to undefine all superglobals
array | $superglobals | Associative array of superglobal names and keys or array of superglobal names to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineSuperglobals(['_GET', **
** File not found : $sandbox->undefineSuperglobals(['_GET' **
** File not found : $sandbox->undefineSuperglobals(); **
defineConst(string|array $name, mixed $value) : $this
Define PHPSandbox constant
You can pass the constant $name and $value to define, or an associative array of constants to define
string|array | $name | String of constant $name or associative array to define |
mixed | $value | Value to define constant to |
Throws exception if unnamed constant is defined
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineConst('TEST', **
** File not found : $sandbox->defineConst(['TEST' **
defineConsts(array $constants = array()) : $this
Define PHPSandbox constants by array
You can pass an associative array of constants to define
array | $constants | Associative array of $constants to define |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineConsts(['test' **
hasDefinedConsts() : integer
Query whether PHPSandbox instance has defined constants
Returns the number of constants this instance has defined
** File not found : $sandbox->hasDefinedConsts(); **
isDefinedConst(string $name) : boolean
Check if PHPSandbox instance has $name constant defined
string | $name | String of constant $name to query |
Returns true if PHPSandbox instance has defined constant, false otherwise
** File not found : $sandbox->isDefinedConst('test'); **
undefineConst(string|array $name) : $this
Undefine PHPSandbox constant
You can pass a string of constant $name to undefine, or an array of constant names to undefine
string|array | $name | String of constant name or array of constant names to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineConst('test'); **
** File not found : $sandbox->undefineConst(['test', **
undefineConsts(array $constants = array()) : $this
Undefine PHPSandbox constants by array
You can pass an array of constant names to undefine, or an empty array or null argument to undefine all constants
array | $constants | Array of constant names to undefine. Passing an empty array or no argument will result in undefining all constants |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineConsts(['test', **
** File not found : $sandbox->undefineConsts(); **
defineMagicConst(string|array $name, mixed $value) : $this
Define PHPSandbox magic constant
You can pass the magic constant $name and $value to define, or an associative array of magic constants to define
string|array | $name | String of magic constant $name or associative array to define |
mixed | $value | Value to define magic constant to, can be callable |
Throws exception if unnamed magic constant is defined
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineMagicConst('__LINE__', **
** File not found : $sandbox->defineMagicConst(['__LINE__' **
defineMagicConsts(array $magic_constants = array()) : $this
Define PHPSandbox magic constants by array
You can pass an associative array of magic constants to define
array | $magic_constants | Associative array of $magic_constants to define |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineMagicConsts(['__LINE__' **
hasDefinedMagicConsts() : integer
Query whether PHPSandbox instance has defined magic constants
Returns the number of magic constants this instance has defined
** File not found : $sandbox->hasDefinedMagicConsts(); **
isDefinedMagicConst(string $name) : boolean
Check if PHPSandbox instance has $name magic constant defined
string | $name | String of magic constant $name to query |
Returns true if PHPSandbox instance has defined magic constant, false otherwise
** File not found : $sandbox->isDefinedMagicConst('__LINE__'); **
undefineMagicConst(string|array $name) : $this
Undefine PHPSandbox magic constant
You can pass an a string of magic constant $name to undefine, or array of magic constant names to undefine
string|array | $name | String of magic constant name, or array of magic constant names to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineMagicConst('__LINE__'); **
** File not found : $sandbox->undefineMagicConst(['__LINE__', **
undefineMagicConsts(array $magic_constants = array()) : $this
Undefine PHPSandbox magic constants by array
You can pass an array of magic constant names to undefine, or an empty array or null argument to undefine all magic constants
array | $magic_constants | Array of magic constant names to undefine. Passing an empty array or no argument will result in undefining all magic constants |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineMagicConsts(['__LINE__', **
** File not found : $sandbox->undefineMagicConsts(); **
defineNamespace(string|array $name) : $this
Define PHPSandbox namespace
You can pass the namespace $name and $value to define, or an array of namespaces to define
string|array | $name | String of namespace $name, or an array of namespace names to define |
Throws exception if unnamed namespace is defined
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineNamespace('Foo'); **
** File not found : $sandbox->defineNamespace(['Foo', **
defineNamespaces(array $namespaces = array()) : $this
Define PHPSandbox namespaces by array
You can pass an array of namespaces to define
array | $namespaces | Array of $namespaces to define |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineNamespaces(['Foo', **
hasDefinedNamespaces() : integer
Query whether PHPSandbox instance has defined namespaces
Returns the number of namespaces this instance has defined
** File not found : $sandbox->hasDefinedNamespaces(); **
isDefinedNamespace(string $name) : boolean
Check if PHPSandbox instance has $name namespace defined
string | $name | String of namespace $name to query |
Returns true if PHPSandbox instance has defined namespace, false otherwise
** File not found : $sandbox->isDefinedNamespace('Foo'); **
getDefinedNamespace(string $name) : string
Get defined namespace of $name
string | $name | String of namespace $name to get |
Throws an exception if an invalid namespace name is requested
Returns string of defined namespace value
** File not found : $sandbox->getDefinedNamespace('Test'); **
undefineNamespace(string|array $name) : $this
Undefine PHPSandbox namespace
You can pass a string of namespace $name to undefine, or an array of namespace names to undefine
string|array | $name | String of namespace $name, or an array of namespace names to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineNamespace('Foo'); **
** File not found : $sandbox->undefineNamespace(['Foo', **
undefineNamespaces(array $namespaces = array()) : $this
Undefine PHPSandbox namespaces by array
You can pass an array of namespace names to undefine, or an empty array or null argument to undefine all namespaces
array | $namespaces | Array of namespace names to undefine. Passing an empty array or no argument will result in undefining all namespaces |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineNamespaces(['Foo', **
** File not found : $sandbox->undefineNamespaces(); **
defineAlias(string|array $name, string|null $alias = null) : $this
Define PHPSandbox alias
You can pass the namespace $name and $alias to use, an array of namespaces to use, or an associative array of namespaces to use and their aliases
string|array | $name | String of namespace $name to use, or or an array of namespaces to use, or an associative array of namespaces and their aliases to use |
string|null | $alias | String of $alias to use |
Throws exception if unnamed namespace is used
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineAlias('Foo'); **
** File not found : $sandbox->defineAlias('Foo', **
** File not found : $sandbox->defineAlias(['Foo', **
** File not found : $sandbox->defineAlias(['Foo' **
defineAliases(array $aliases = array()) : $this
Define PHPSandbox aliases by array
You can pass an array of namespaces to use, or an associative array of namespaces to use and their aliases
array | $aliases | Array of namespaces to use, or an associative array of namespaces and their aliases to use |
Throws exception if unnamed namespace is used
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineAliases(['Foo', **
** File not found : $sandbox->defineAliases(['Foo' **
hasDefinedAliases() : integer
Query whether PHPSandbox instance has defined aliases
Returns the number of aliases this instance has defined
** File not found : $sandbox->hasDefinedAliases(); **
isDefinedAlias(string $name) : boolean
Check if PHPSandbox instance has $name alias defined
string | $name | String of alias $name to query |
Returns true if PHPSandbox instance has defined aliases, false otherwise
** File not found : $sandbox->isDefinedAlias('Foo'); **
undefineAlias(string|array $name) : $this
Undefine PHPSandbox alias
You can pass a string of alias $name to undefine, or an array of alias names to undefine
string|array | $name | String of alias name, or array of alias names to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineAlias('Foo'); **
** File not found : $sandbox->undefineAlias(['Foo', **
undefineAliases(array $aliases = array()) : $this
Undefine PHPSandbox aliases by array
You can pass an array of alias names to undefine, or an empty array or null argument to undefine all aliases
array | $aliases | Array of alias names to undefine. Passing an empty array or no argument will result in undefining all aliases |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineAliases(['Foo', **
** File not found : $sandbox->undefineAliases(); **
defineUse(string|array $name, string|null $alias = null) : $this
Define PHPSandbox use (or alias)
string|array | $name | String of namespace $name to use, or or an array of namespaces to use, or an associative array of namespaces and their aliases to use |
string|null | $alias | String of $alias to use |
Throws exception if unnamed namespace is used
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineUse('Foo'); **
** File not found : $sandbox->defineUse('Foo', **
** File not found : $sandbox->defineUse(['Foo', **
** File not found : $sandbox->defineUse(['Foo' **
defineUses(array $uses = array()) : $this
Define PHPSandbox uses (or aliases) by array
array | $uses | Array of namespaces to use, or an associative array of namespaces and their aliases to use |
Throws exception if unnamed namespace is used
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineUses(['Foo', **
** File not found : $sandbox->defineUses(['Foo' **
hasDefinedUses() : integer
Query whether PHPSandbox instance has defined uses (or aliases)
Returns the number of uses (or aliases) this instance has defined
** File not found : $sandbox->hasDefinedUses(); **
isDefinedUse(string $name) : boolean
Check if PHPSandbox instance has $name uses (or alias) defined
string | $name | String of use (or alias) $name to query |
Returns true if PHPSandbox instance has defined uses (or aliases) and false otherwise
** File not found : $sandbox->isDefinedUse('Foo'); **
undefineUse(string|array $name) : $this
Undefine PHPSandbox use (or alias)
You can pass a string of use (or alias) $name to undefine, or an array of use (or alias) names to undefine
string|array | $name | String of use (or alias) name, or array of use (or alias) names to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineUse('Foo'); **
** File not found : $sandbox->undefineUse(['Foo', **
undefineUses(array $uses = array()) : $this
Undefine PHPSandbox uses (or aliases) by array
array | $uses | Array of use (or alias) names to undefine. Passing an empty array or no argument will result in undefining all uses (or aliases) |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineUses(['Foo', **
** File not found : $sandbox->undefineUses(); **
defineClass(string|array $name, mixed $value) : $this
Define PHPSandbox class
You can pass the class $name and $value to define, or an associative array of classes to define
string|array | $name | String of class $name or associative array to define |
mixed | $value | Value to define class to |
Throws exception if unnamed class is defined
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineClass('Test', **
** File not found : $sandbox->defineClass(['Test' **
defineClasses(array $classes = array()) : $this
Define PHPSandbox classes by array
You can pass an associative array of classes to define
array | $classes | Associative array of $classes to define |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineClasses(['Test' **
hasDefinedClasses() : integer
Query whether PHPSandbox instance has defined classes
Returns the number of classes this instance has defined
** File not found : $sandbox->hasDefinedClasses(); **
isDefinedClass(string $name) : boolean
Check if PHPSandbox instance has $name class defined
string | $name | String of class $name to query |
Returns true if PHPSandbox instance has defined class, false otherwise
** File not found : $sandbox->isDefinedClass('Test'); **
getDefinedClass(string $name) : string
Get defined class of $name
string | $name | String of class $name to get |
Throws an exception if an invalid class name is requested
Returns string of defined class value
** File not found : $sandbox->getDefinedClass('Test'); **
undefineClass(string|array $name) : $this
Undefine PHPSandbox class
You can pass a string of class $name to undefine, or an array of class names to undefine
string|array | $name | String of class name or an array of class names to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineClass('Test'); **
** File not found : $sandbox->undefineClass(['Test', **
undefineClasses(array $classes = array()) : $this
Undefine PHPSandbox classes by array
You can pass an array of class names to undefine, or an empty array or null argument to undefine all classes
array | $classes | Array of class names to undefine. Passing an empty array or no argument will result in undefining all classes |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineClasses(['Test', **
** File not found : $sandbox->undefineClasses(); **
defineInterface(string|array $name, mixed $value) : $this
Define PHPSandbox interface
You can pass the interface $name and $value to define, or an associative array of interfaces to define
string|array | $name | String of interface $name or associative array to define |
mixed | $value | Value to define interface to |
Throws exception if unnamed interface is defined
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineInterface('Test', **
** File not found : $sandbox->defineInterface(['Test' **
defineInterfaces(array $interfaces = array()) : $this
Define PHPSandbox interfaces by array
You can pass an associative array of interfaces to define
array | $interfaces | Associative array of $interfaces to define |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineInterfaces(['Test' **
hasDefinedInterfaces() : integer
Query whether PHPSandbox instance has defined interfaces
Returns the number of interfaces this instance has defined
** File not found : $sandbox->hasDefinedInterfaces(); **
isDefinedInterface(string $name) : boolean
Check if PHPSandbox instance has $name interface defined
string | $name | String of interface $name to query |
Returns true if PHPSandbox instance has defined interface, false otherwise
** File not found : $sandbox->isDefinedInterface('Test'); **
getDefinedInterface(string $name) : string
Get defined interface of $name
string | $name | String of interface $name to get |
Throws an exception if an invalid interface name is requested
Returns string of defined interface value
** File not found : $sandbox->getDefinedInterface('Test'); **
undefineInterface(string|array $name) : $this
Undefine PHPSandbox interface
You can pass a string of interface $name to undefine, or an array of interface names to undefine
string|array | $name | String of interface name or an array of interface names to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineInterface('Test'); **
** File not found : $sandbox->undefineInterface(['Test', **
undefineInterfaces(array $interfaces = array()) : $this
Undefine PHPSandbox interfaces by array
You can pass an array of interface names to undefine, or an empty array or null argument to undefine all interfaces
array | $interfaces | Array of interface names to undefine. Passing an empty array or no argument will result in undefining all interfaces |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineInterfaces(['Test', **
** File not found : $sandbox->undefineInterfaces(); **
defineTrait(string|array $name, mixed $value) : $this
Define PHPSandbox trait
You can pass the trait $name and $value to define, or an associative array of traits to define
string|array | $name | String of trait $name or associative array to define |
mixed | $value | Value to define trait to |
Throws exception if unnamed trait is defined
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineTrait('Test', **
** File not found : $sandbox->defineTrait(['Test' **
defineTraits(array $traits = array()) : $this
Define PHPSandbox traits by array
You can pass an associative array of traits to define
array | $traits | Associative array of $traits to define |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->defineTraits(['Test' **
isDefinedTrait(string $name) : boolean
Check if PHPSandbox instance has $name trait defined
string | $name | String of trait $name to query |
Returns true if PHPSandbox instance has defined trait, false otherwise
** File not found : $sandbox->isDefinedTrait('Test'); **
getDefinedTrait(string $name) : string
Get defined trait of $name
string | $name | String of trait $name to get |
Throws an exception if an invalid trait name is requested
Returns string of defined trait value
** File not found : $sandbox->getDefinedTrait('Test'); **
undefineTrait(string|array $name) : $this
Undefine PHPSandbox trait
You can pass a string of trait $name to undefine, or an array of trait names to undefine
string|array | $name | String of trait name or an array of trait names to undefine |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineTrait('Test'); **
** File not found : $sandbox->undefineTrait(['Test', **
undefineTraits(array $traits = array()) : $this
Undefine PHPSandbox traits by array
You can pass an array of trait names to undefine, or an empty array or null argument to undefine all traits
array | $traits | Array of trait names to undefine. Passing an empty array or no argument will result in undefining all traits |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->undefineTraits(['Test', **
** File not found : $sandbox->undefineTraits(); **
whitelist(string|array $type, string|array|null $name = null) : $this
Whitelist PHPSandbox definitions, such as functions, constants, classes, etc. to set
You can pass an associative array of whitelist types and their names, or a string $type and array of $names, or pass a string of the $type and $name
string|array | $type | Associative array or string of whitelist type to set |
string|array|null | $name | Array or string of whitelist name to set |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelist(['functions' **
** File not found : $sandbox->whitelist('functions', **
** File not found : $sandbox->whitelist('functions', **
blacklist(string|array $type, string|array|null $name = null) : $this
Blacklist PHPSandbox definitions, such as functions, constants, classes, etc. to set
You can pass an associative array of blacklist types and their names, or a string $type and array of $names, or pass a string of the $type and $name
string|array | $type | Associative array or string of blacklist type to set |
string|array|null | $name | Array or string of blacklist name to set |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklist(['functions' **
** File not found : $sandbox->blacklist('functions', **
** File not found : $sandbox->blacklist('functions', **
dewhitelist(string|array $type, string|array|null $name) : $this
Remove PHPSandbox definitions, such as functions, constants, classes, etc. from whitelist
You can pass an associative array of whitelist types and their names, or a string $type and array of $names, or pass a string of the $type and $name to unset
string|array | $type | Associative array or string of whitelist type to unset |
string|array|null | $name | Array or string of whitelist name to unset |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelist(['functions' **
** File not found : $sandbox->dewhitelist('functions', **
** File not found : $sandbox->dewhitelist('functions', **
deblacklist(string|array $type, string|array|null $name) : $this
Remove PHPSandbox definitions, such as functions, constants, classes, etc. from blacklist
You can pass an associative array of blacklist types and their names, or a string $type and array of $names, or pass a string of the $type and $name to unset
string|array | $type | Associative array or string of blacklist type to unset |
string|array|null | $name | Array or string of blacklist name to unset |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklist(['functions' **
** File not found : $sandbox->deblacklist('functions', **
** File not found : $sandbox->deblacklist('functions', **
hasWhitelist(string $type) : integer
Query whether PHPSandbox instance has whitelist type
string | $type | The whitelist type to query |
Returns the number of whitelists this instance has defined
** File not found : $sandbox->hasWhitelist('functions'); **
hasBlacklist(string $type) : integer
Query whether PHPSandbox instance has blacklist type.
string | $type | The blacklist type to query |
Returns the number of blacklists this instance has defined
** File not found : $sandbox->hasBlacklist('functions'); **
isWhitelisted(string $type, string $name) : boolean
Check if PHPSandbox instance has whitelist type and name set
string | $type | String of whitelist $type to query |
string | $name | String of whitelist $name to query |
Returns true if PHPSandbox instance has whitelisted $type and $name, false otherwise
** File not found : $sandbox->isWhitelisted('functions', **
isBlacklisted(string $type, string $name) : boolean
Check if PHPSandbox instance has blacklist type and name set
string | $type | String of blacklist $type to query |
string | $name | String of blacklist $name to query |
Returns true if PHPSandbox instance has blacklisted $type and $name, false otherwise
** File not found : $sandbox->isBlacklisted('functions', **
hasWhitelistedFuncs() : integer
Query whether PHPSandbox instance has whitelisted functions.
Returns the number of whitelisted functions this instance has defined
** File not found : $sandbox->hasWhitelistedFuncs(); **
hasBlacklistedFuncs() : integer
Query whether PHPSandbox instance has blacklisted functions.
Returns the number of blacklisted functions this instance has defined
** File not found : $sandbox->hasBlacklistedFuncs(); **
isWhitelistedFunc(string $name) : boolean
Check if PHPSandbox instance has whitelisted function name set
string | $name | String of function $name to query |
Returns true if PHPSandbox instance has whitelisted function $name, false otherwise
** File not found : $sandbox->isWhitelistedFunc('test'); **
isBlacklistedFunc(string $name) : boolean
Check if PHPSandbox instance has blacklisted function name set
string | $name | String of function $name to query |
Returns true if PHPSandbox instance has blacklisted function $name, false otherwise
** File not found : $sandbox->isBlacklistedFunc('test'); **
hasWhitelistedVars() : integer
Query whether PHPSandbox instance has whitelisted variables.
Returns the number of whitelisted variables this instance has defined
** File not found : $sandbox->hasWhitelistedVars(); **
hasBlacklistedVars() : integer
Query whether PHPSandbox instance has blacklisted variables.
Returns the number of blacklisted variables this instance has defined
** File not found : $sandbox->hasBlacklistedVars(); **
isWhitelistedVar(string $name) : boolean
Check if PHPSandbox instance has whitelisted variable name set
string | $name | String of variable $name to query |
Returns true if PHPSandbox instance has whitelisted variable $name, false otherwise
** File not found : $sandbox->isWhitelistedVar('test'); **
isBlacklistedVar(string $name) : boolean
Check if PHPSandbox instance has blacklisted variable name set
string | $name | String of variable $name to query |
Returns true if PHPSandbox instance has blacklisted variable $name, false otherwise
** File not found : $sandbox->isBlacklistedVar('test'); **
hasWhitelistedGlobals() : integer
Query whether PHPSandbox instance has whitelisted globals.
Returns the number of whitelisted globals this instance has defined
** File not found : $sandbox->hasWhitelistedGlobals(); **
hasBlacklistedGlobals() : integer
Query whether PHPSandbox instance has blacklisted globals.
Returns the number of blacklisted globals this instance has defined
** File not found : $sandbox->hasBlacklistedGlobals(); **
isWhitelistedGlobal(string $name) : boolean
Check if PHPSandbox instance has whitelisted global name set
string | $name | String of global $name to query |
Returns true if PHPSandbox instance has whitelisted global $name, false otherwise
** File not found : $sandbox->isWhitelistedGlobal('test'); **
isBlacklistedGlobal(string $name) : boolean
Check if PHPSandbox instance has blacklisted global name set
string | $name | String of global $name to query |
Returns true if PHPSandbox instance has blacklisted global $name, false otherwise
** File not found : $sandbox->isBlacklistedGlobal('test'); **
hasWhitelistedSuperglobals(string $name = null) : integer
Query whether PHPSandbox instance has whitelisted superglobals, or superglobal keys
string | $name | The whitelist superglobal key to query |
Returns the number of whitelisted superglobals or superglobal keys this instance has defined
** File not found : $sandbox->hasWhitelistedSuperglobals(); **
** File not found : $sandbox->hasWhitelistedSuperglobals('_GET'); **
hasBlacklistedSuperglobals(string $name = null) : integer
Query whether PHPSandbox instance has blacklisted superglobals, or superglobal keys
string | $name | The blacklist superglobal key to query |
Returns the number of blacklisted superglobals or superglobal keys this instance has defined
** File not found : $sandbox->hasBlacklistedSuperglobals(); **
** File not found : $sandbox->hasBlacklistedSuperglobals('_GET'); **
isWhitelistedSuperglobal(string $name, string $key = null) : boolean
Check if PHPSandbox instance has whitelisted superglobal or superglobal key set
string | $name | String of whitelisted superglobal $name to query |
string | $key | String of whitelisted superglobal $key to query |
Returns true if PHPSandbox instance has whitelisted superglobal key or superglobal, false otherwise
** File not found : $sandbox->isWhitelistedSuperglobal('_GET'); **
** File not found : $sandbox->isWhitelistedSuperglobal('_GET', **
isBlacklistedSuperglobal(string $name, string $key = null) : boolean
Check if PHPSandbox instance has blacklisted superglobal or superglobal key set
string | $name | String of blacklisted superglobal $name to query |
string | $key | String of blacklisted superglobal $key to query |
Returns true if PHPSandbox instance has blacklisted superglobal key or superglobal, false otherwise
** File not found : $sandbox->isBlacklistedSuperglobal('_GET'); **
** File not found : $sandbox->isBlacklistedSuperglobal('_GET', **
hasWhitelistedConsts() : integer
Query whether PHPSandbox instance has whitelisted constants.
Returns the number of whitelisted constants this instance has defined
** File not found : $sandbox->hasWhitelistedConsts(); **
hasBlacklistedConsts() : integer
Query whether PHPSandbox instance has blacklisted constants.
Returns the number of blacklisted constants this instance has defined
** File not found : $sandbox->hasBlacklistedConsts(); **
isWhitelistedConst(string $name) : boolean
Check if PHPSandbox instance has whitelisted constant name set
string | $name | String of constant $name to query |
Returns true if PHPSandbox instance has whitelisted constant $name, false otherwise
** File not found : $sandbox->isWhitelistedConst('TEST'); **
isBlacklistedConst(string $name) : boolean
Check if PHPSandbox instance has blacklisted constant name set
string | $name | String of constant $name to query |
Returns true if PHPSandbox instance has blacklisted constant $name, false otherwise
** File not found : $sandbox->isBlacklistedConst('TEST'); **
hasWhitelistedMagicConsts() : integer
Query whether PHPSandbox instance has whitelisted magic constants.
Returns the number of whitelisted magic constants this instance has defined
** File not found : $sandbox->hasWhitelistedMagicConsts(); **
hasBlacklistedMagicConsts() : integer
Query whether PHPSandbox instance has blacklisted magic constants.
Returns the number of blacklisted magic constants this instance has defined
** File not found : $sandbox->hasBlacklistedMagicConsts(); **
isWhitelistedMagicConst(string $name) : boolean
Check if PHPSandbox instance has whitelisted magic constant name set
string | $name | String of magic constant $name to query |
Returns true if PHPSandbox instance has whitelisted magic constant $name, false otherwise
** File not found : $sandbox->isWhitelistedMagicConst('__LINE__'); **
isBlacklistedMagicConst(string $name) : boolean
Check if PHPSandbox instance has blacklisted magic constant name set
string | $name | String of magic constant $name to query |
Returns true if PHPSandbox instance has blacklisted magic constant $name, false otherwise
** File not found : $sandbox->isBlacklistedMagicConst('__LINE__'); **
hasWhitelistedNamespaces() : integer
Query whether PHPSandbox instance has whitelisted namespaces.
Returns the number of whitelisted namespaces this instance has defined
** File not found : $sandbox->hasWhitelistedNamespaces(); **
hasBlacklistedNamespaces() : integer
Query whether PHPSandbox instance has blacklisted namespaces.
Returns the number of blacklisted namespaces this instance has defined
** File not found : $sandbox->hasBlacklistedNamespaces(); **
isWhitelistedNamespace(string $name) : boolean
Check if PHPSandbox instance has whitelisted namespace name set
string | $name | String of namespace $name to query |
Returns true if PHPSandbox instance has whitelisted namespace $name, false otherwise
** File not found : $sandbox->isWhitelistedNamespace('Test'); **
isBlacklistedNamespace(string $name) : boolean
Check if PHPSandbox instance has blacklisted namespace name set
string | $name | String of namespace $name to query |
Returns true if PHPSandbox instance has blacklisted namespace $name, false otherwise
** File not found : $sandbox->isBlacklistedNamespace('Test'); **
hasWhitelistedAliases() : integer
Query whether PHPSandbox instance has whitelisted aliases.
Returns the number of whitelisted aliases this instance has defined
** File not found : $sandbox->hasWhitelistedAliases(); **
hasBlacklistedAliases() : integer
Query whether PHPSandbox instance has blacklisted aliases.
Returns the number of blacklisted aliases this instance has defined
** File not found : $sandbox->hasBlacklistedAliases(); **
isWhitelistedAlias(string $name) : boolean
Check if PHPSandbox instance has whitelisted alias name set
string | $name | String of alias $name to query |
Returns true if PHPSandbox instance has whitelisted alias $name, false otherwise
** File not found : $sandbox->isWhitelistedAlias('Test'); **
isBlacklistedAlias(string $name) : boolean
Check if PHPSandbox instance has blacklisted alias name set
string | $name | String of alias $name to query |
Returns true if PHPSandbox instance has blacklisted alias $name, false otherwise
** File not found : $sandbox->isBlacklistedAlias('Test'); **
hasWhitelistedUses() : integer
Query whether PHPSandbox instance has whitelisted uses (or aliases.)
Returns the number of whitelisted uses (or aliases) this instance has defined
** File not found : $sandbox->hasWhitelistedUses(); **
hasBlacklistedUses() : integer
Query whether PHPSandbox instance has blacklisted uses (or aliases.)
Returns the number of blacklisted uses (or aliases) this instance has defined
** File not found : $sandbox->hasBlacklistedUses(); **
isWhitelistedUse(string $name) : boolean
Check if PHPSandbox instance has whitelisted use (or alias) name set
string | $name | String of use (or alias) $name to query |
Returns true if PHPSandbox instance has whitelisted use (or alias) $name, false otherwise
** File not found : $sandbox->isWhitelistedUse('Test'); **
isBlacklistedUse(string $name) : boolean
Check if PHPSandbox instance has blacklisted use (or alias) name set
string | $name | String of use (or alias) $name to query |
Returns true if PHPSandbox instance has blacklisted use (or alias) $name, false otherwise
** File not found : $sandbox->isBlacklistedUse('Test'); **
hasWhitelistedClasses() : integer
Query whether PHPSandbox instance has whitelisted classes.
Returns the number of whitelisted classes this instance has defined
** File not found : $sandbox->hasWhitelistClasses(); **
hasBlacklistedClasses() : integer
Query whether PHPSandbox instance has blacklisted classes.
Returns the number of blacklisted classes this instance has defined
** File not found : $sandbox->hasBlacklistedClasses(); **
isWhitelistedClass(string $name) : boolean
Check if PHPSandbox instance has whitelisted class name set
string | $name | String of class $name to query |
Returns true if PHPSandbox instance has whitelisted class $name, false otherwise
** File not found : $sandbox->isWhitelistedClass('Test'); **
isBlacklistedClass(string $name) : boolean
Check if PHPSandbox instance has blacklisted class name set
string | $name | String of class $name to query |
Returns true if PHPSandbox instance has blacklisted class $name, false otherwise
** File not found : $sandbox->isBlacklistedClass('Test'); **
hasWhitelistedInterfaces() : integer
Query whether PHPSandbox instance has whitelisted interfaces.
Returns the number of whitelisted interfaces this instance has defined
** File not found : $sandbox->hasWhitelistedInterfaces(); **
hasBlacklistedInterfaces() : integer
Query whether PHPSandbox instance has blacklisted interfaces.
Returns the number of blacklisted interfaces this instance has defined
** File not found : $sandbox->hasBlacklistedInterfaces(); **
isWhitelistedInterface(string $name) : boolean
Check if PHPSandbox instance has whitelisted interface name set
string | $name | String of interface $name to query |
Returns true if PHPSandbox instance has whitelisted interface $name, false otherwise
** File not found : $sandbox->isWhitelistedInterface('Test'); **
isBlacklistedInterface(string $name) : boolean
Check if PHPSandbox instance has blacklisted interface name set
string | $name | String of interface $name to query |
Returns true if PHPSandbox instance has blacklisted interface $name, false otherwise
** File not found : $sandbox->isBlacklistedInterface('Test'); **
hasWhitelistedTraits() : integer
Query whether PHPSandbox instance has whitelisted traits.
Returns the number of whitelisted traits this instance has defined
** File not found : $sandbox->hasWhitelistedTraits(); **
hasBlacklistedTraits() : integer
Query whether PHPSandbox instance has blacklisted traits.
Returns the number of blacklisted traits this instance has defined
** File not found : $sandbox->hasBlacklistedTraits(); **
isWhitelistedTrait(string $name) : boolean
Check if PHPSandbox instance has whitelisted trait name set
string | $name | String of trait $name to query |
Returns true if PHPSandbox instance has whitelisted trait $name, false otherwise
** File not found : $sandbox->isWhitelistedTrait('Test'); **
isBlacklistedTrait(string $name) : boolean
Check if PHPSandbox instance has blacklisted trait name set
string | $name | String of trait $name to query |
Returns true if PHPSandbox instance has blacklisted trait $name, false otherwise
** File not found : $sandbox->isBlacklistedTrait('Test'); **
hasWhitelistKeywords() : integer
Query whether PHPSandbox instance has whitelisted keywords.
Returns the number of whitelisted keywords this instance has defined
** File not found : $sandbox->hasWhitelistKeywords(); **
hasBlacklistedKeywords() : integer
Query whether PHPSandbox instance has blacklisted keywords.
Returns the number of blacklisted keywords this instance has defined
** File not found : $sandbox->hasBlacklistedKeywords(); **
isWhitelistedKeyword(string $name) : boolean
Check if PHPSandbox instance has whitelisted keyword name set
string | $name | String of keyword $name to query |
Returns true if PHPSandbox instance has whitelisted keyword $name, false otherwise
** File not found : $sandbox->isWhitelistedKeyword('echo'); **
isBlacklistedKeyword(string $name) : boolean
Check if PHPSandbox instance has blacklisted keyword name set
string | $name | String of keyword $name to query |
Returns true if PHPSandbox instance has blacklisted keyword $name, false otherwise
** File not found : $sandbox->isBlacklistedKeyword('echo'); **
hasWhitelistedOperators() : integer
Query whether PHPSandbox instance has whitelisted operators.
Returns the number of whitelisted operators this instance has defined
** File not found : $sandbox->hasWhitelistOperators(); **
hasBlacklistedOperators() : integer
Query whether PHPSandbox instance has blacklisted operators.
Returns the number of blacklisted operators this instance has defined
** File not found : $sandbox->hasBlacklistOperators(); **
isWhitelistedOperator(string $name) : boolean
Check if PHPSandbox instance has whitelisted operator name set
string | $name | String of operator $name to query |
Returns true if PHPSandbox instance has whitelisted operator $name, false otherwise
** File not found : $sandbox->isWhitelistedOperator('+'); **
isBlacklistedOperator(string $name) : boolean
Check if PHPSandbox instance has blacklisted operator name set
string | $name | String of operator $name to query |
Returns true if PHPSandbox instance has blacklisted operator $name, false otherwise
** File not found : $sandbox->isBlacklistedOperator('+'); **
hasWhitelistedPrimitives() : integer
Query whether PHPSandbox instance has whitelisted primitives.
Returns the number of whitelisted primitives this instance has defined
** File not found : $sandbox->hasWhitelistedPrimitives(); **
hasBlacklistedPrimitives() : integer
Query whether PHPSandbox instance has blacklisted primitives.
Returns the number of blacklisted primitives this instance has defined
** File not found : $sandbox->hasBlacklistedPrimitives(); **
isWhitelistedPrimitive(string $name) : boolean
Check if PHPSandbox instance has whitelisted primitive name set
string | $name | String of primitive $name to query |
Returns true if PHPSandbox instance has whitelisted primitive $name, false otherwise
** File not found : $sandbox->isWhitelistedPrimitive('array'); **
isBlacklistedPrimitive(string $name) : boolean
Check if PHPSandbox instance has blacklisted primitive name set
string | $name | String of primitive $name to query |
Returns true if PHPSandbox instance has blacklisted primitive $name, false otherwise
** File not found : $sandbox->isBlacklistedPrimitive('array'); **
hasWhitelistedTypes() : integer
Query whether PHPSandbox instance has whitelisted types.
Returns the number of whitelisted types this instance has defined
** File not found : $sandbox->hasWhitelistedTypes(); **
hasBlacklistedTypes() : integer
Query whether PHPSandbox instance has blacklisted types.
Returns the number of blacklisted types this instance has defined
** File not found : $sandbox->hasBlacklistedTypes(); **
isWhitelistedType(string $name) : boolean
Check if PHPSandbox instance has whitelisted type name set
string | $name | String of type $name to query |
Returns true if PHPSandbox instance has whitelisted type $name, false otherwise
** File not found : $sandbox->isWhitelistedType('array'); **
isBlacklistedType(string $name) : boolean
Check if PHPSandbox instance has blacklisted type name set
string | $name | String of type $name to query |
Returns true if PHPSandbox instance has blacklisted type $name, false otherwise
** File not found : $sandbox->isBlacklistedType('array'); **
whitelistFunc(string|array $name) : $this
Whitelist function
You can pass a string of the function name, or pass an array of function names to whitelist
string|array | $name | String of function name, or array of function names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistFunc('var_dump'); **
** File not found : $sandbox->whitelistFunc('var_dump', **
** File not found : $sandbox->whitelistFunc(['var_dump', **
blacklistFunc(string|array $name) : $this
Blacklist function
You can pass a string of the function name, or pass an array of function names to blacklist
string|array | $name | String of function name, or array of function names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistFunc('var_dump'); **
** File not found : $sandbox->blacklistFunc(['var_dump', **
dewhitelistFunc(string|array $name) : $this
Remove function from whitelist
You can pass a string of the function name, or pass an array of function names to remove from whitelist
string|array | $name | String of function name or array of function names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistFunc('var_dump'); **
** File not found : $sandbox->dewhitelistFunc(['var_dump', **
deblacklistFunc(string|array $name) : $this
Remove function from blacklist
You can pass a string of the function name, or pass an array of function names to remove from blacklist
string|array | $name | String of function name or array of function names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistFunc('var_dump'); **
** File not found : $sandbox->deblacklistFunc(['var_dump', **
whitelistVar(string|array $name) : $this
Whitelist variable
You can pass a string of variable name, or pass an array of the variable names to whitelist
string|array | $name | String of variable name or array of variable names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistVar('a'); **
** File not found : $sandbox->whitelistVar(['a', **
blacklistVar(string|array $name) : $this
Blacklist variable
You can pass a string of variable name, or pass an array of the variable names to blacklist
string|array | $name | String of variable name or array of variable names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistVar('a'); **
** File not found : $sandbox->blacklistVar(['a', **
dewhitelistVar(string|array $name) : $this
Remove variable from whitelist
You can pass a string of variable name, or pass an array of the variable names to remove from whitelist
string|array | $name | String of variable name or array of variable names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistVar('a'); **
** File not found : $sandbox->dewhitelistVar(['a', **
deblacklistVar(string|array $name) : $this
Remove function from blacklist
You can pass a string of variable name, or pass an array of the variable names to remove from blacklist
string|array | $name | String of variable name or array of variable names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistVar('a'); **
** File not found : $sandbox->deblacklistVar(['a', **
whitelistGlobal(string|array $name) : $this
Whitelist global
You can pass a string of global name, or pass an array of the global names to whitelist
string|array | $name | String of global name or array of global names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistGlobal('a'); **
** File not found : $sandbox->whitelistGlobal(['a', **
blacklistGlobal(string|array $name) : $this
Blacklist global
You can pass a string of global name, or pass an array of the global names to blacklist
string|array | $name | String of global name or array of global names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistGlobal('a'); **
** File not found : $sandbox->blacklistGlobal(['a', **
dewhitelistGlobal(string|array $name) : $this
Remove global from whitelist
You can pass a string of global name, or pass an array of the global names to remove from whitelist
string|array | $name | String of global name or array of global names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistGlobal('a'); **
** File not found : $sandbox->dewhitelistGlobal(['a', **
deblacklistGlobal(string|array $name) : $this
Remove global from blacklist
You can pass a string of global name, or pass an array of the global names to remove from blacklist
string|array | $name | String of global name or array of global names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistGlobal('a'); **
** File not found : $sandbox->deblacklistGlobal(['a', **
whitelistSuperglobal(string|array $name, string $key = null) : $this
Whitelist superglobal or superglobal key
You can pass a string of the superglobal name, or a string of the superglobal name and a string of the key, or pass an array of superglobal names, or an associative array of superglobal names and their keys to whitelist
string|array | $name | String of superglobal name, or an array of superglobal names, or an associative array of superglobal names and their keys to whitelist |
string | $key | String of superglobal key to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistSuperglobal('_GET'); **
** File not found : $sandbox->whitelistSuperglobal('_GET', **
** File not found : $sandbox->whitelistSuperglobal(['_GET', **
** File not found : $sandbox->whitelistSuperglobal(['_GET' **
blacklistSuperglobal(string|array $name, string $key = null) : $this
Blacklist superglobal or superglobal key * You can pass a string of the superglobal name, or a string of the superglobal name and a string of the key, or pass an array of superglobal names, or an associative array of superglobal names and their keys to blacklist
string|array | $name | String of superglobal name, or an array of superglobal names, or an associative array of superglobal names and their keys to blacklist |
string | $key | String of superglobal key to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistSuperglobal('_GET'); **
** File not found : $sandbox->blacklistSuperglobal('_GET', **
** File not found : $sandbox->blacklistSuperglobal(['_GET', **
** File not found : $sandbox->blacklistSuperglobal(['_GET' **
dewhitelistSuperglobal(string|array $name, string $key = null) : $this
Remove superglobal or superglobal key from whitelist * You can pass a string of the superglobal name, or a string of the superglobal name and a string of the key, or pass an array of superglobal names, or an associative array of superglobal names and their keys to remove from whitelist
string|array | $name | String of superglobal name, or an array of superglobal names, or an associative array of superglobal names and their keys to remove from whitelist |
string | $key | String of superglobal key to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistSuperglobal('_GET'); **
** File not found : $sandbox->dewhitelistSuperglobal('_GET', **
** File not found : $sandbox->dewhitelistSuperglobal(['_GET', **
** File not found : $sandbox->dewhitelistSuperglobal(['_GET' **
deblacklistSuperglobal(string|array $name, string $key = null) : $this
Remove superglobal or superglobal key from blacklist * You can pass a string of the superglobal name, or a string of the superglobal name and a string of the key, or pass an array of superglobal names, or an associative array of superglobal names and their keys to remove from blacklist
string|array | $name | String of superglobal name, or an array of superglobal names, or an associative array of superglobal names and their keys to remove from blacklist |
string | $key | String of superglobal key to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistSuperglobal('_GET'); **
** File not found : $sandbox->deblacklistSuperglobal('_GET', **
** File not found : $sandbox->deblacklistSuperglobal(['_GET', **
** File not found : $sandbox->deblacklistSuperglobal(['_GET' **
whitelistConst(string|array $name) : $this
Whitelist constant
You can pass a string of constant name, or pass an array of the constant names to whitelist
string|array | $name | String of constant name or array of constant names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistConst('FOO'); **
** File not found : $sandbox->whitelistConst(['FOO', **
blacklistConst(string|array $name) : $this
Blacklist constant
You can pass a string of constant name, or pass an array of the constant names to blacklist
string|array | $name | String of constant name or array of constant names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistConst('FOO'); **
** File not found : $sandbox->blacklistConst(['FOO', **
dewhitelistConst(string|array $name) : $this
Remove constant from whitelist
You can pass a string of constant name, or pass an array of the constant names to remove from whitelist
string|array | $name | String of constant name or array of constant names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistConst('FOO'); **
** File not found : $sandbox->dewhitelistConst(['FOO', **
deblacklistConst(string|array $name) : $this
Remove constant from blacklist
You can pass a string of constant name, or pass an array of the constant names to remove from blacklist
string|array | $name | String of constant name or array of constant names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistConst('FOO'); **
** File not found : $sandbox->deblacklistConst(['FOO', **
whitelistMagicConst(string|array $name) : $this
Whitelist magic constant
You can pass a string of magic constant name, or pass an array of the magic constant names to whitelist
string|array | $name | String of magic constant name or array of magic constant names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistMagicConst('__LINE__'); **
** File not found : $sandbox->whitelistMagicConst(['__LINE__', **
blacklistMagicConst(string|array $name) : $this
Blacklist magic constant
You can pass a string of magic constant name, or pass an array of the magic constant names to blacklist
string|array | $name | String of magic constant name or array of magic constant names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistMagicConst('__LINE__'); **
** File not found : $sandbox->blacklistMagicConst(['__LINE__', **
dewhitelistMagicConst(string|array $name) : $this
Remove magic constant from whitelist
You can pass a string of magic constant name, or pass an array of the magic constant names to remove from whitelist
string|array | $name | String of magic constant name or array of magic constant names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistMagicConst('__LINE__'); **
** File not found : $sandbox->dewhitelistMagicConst(['__LINE__', **
deblacklistMagicConst(string|array $name) : $this
Remove magic constant from blacklist
You can pass a string of magic constant name, or pass an array of the magic constant names to remove from blacklist
string|array | $name | String of magic constant name or array of magic constant names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistMagicConst('__LINE__'); **
** File not found : $sandbox->deblacklistMagicConst(['__LINE__', **
whitelistNamespace(string|array $name) : $this
Whitelist namespace
You can pass a string of namespace name, or pass an array of the namespace names to whitelist
string|array | $name | String of namespace name or array of namespace names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistNamespace('Foo'); **
** File not found : $sandbox->whitelistNamespace(['Foo', **
blacklistNamespace(string|array $name) : $this
Blacklist namespace
You can pass a string of namespace name, or pass an array of the namespace names to blacklist
string|array | $name | String of namespace name or array of namespace names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistNamespace('Foo'); **
** File not found : $sandbox->blacklistNamespace(['Foo', **
dewhitelistNamespace(string|array $name) : $this
Remove namespace from whitelist
You can pass a string of namespace name, or pass an array of the namespace names to remove from whitelist
string|array | $name | String of namespace name or array of namespace names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistNamespace('Foo'); **
** File not found : $sandbox->dewhitelistNamespace(['Foo', **
deblacklistNamespace(string|array $name) : $this
Remove namespace from blacklist
You can pass a string of namespace name, or pass an array of the namespace names to remove from blacklist
string|array | $name | String of namespace name or array of namespace names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistNamespace('Foo'); **
** File not found : $sandbox->deblacklistNamespace(['Foo', **
whitelistAlias(string|array $name) : $this
Whitelist alias
You can pass a string of alias name, or pass an array of the alias names to whitelist
string|array | $name | String of alias names or array of alias names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistAlias('Foo'); **
** File not found : $sandbox->whitelistAlias(['Foo', **
blacklistAlias(string|array $name) : $this
Blacklist alias
You can pass a string of alias name, or pass an array of the alias names to blacklist
string|array | $name | String of alias name or array of alias names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistAlias('Foo'); **
** File not found : $sandbox->blacklistAlias(['Foo', **
dewhitelistAlias(string|array $name) : $this
Remove alias from whitelist
You can pass a string of alias name, or pass an array of the alias names to remove from whitelist
string|array | $name | String of alias name or array of alias names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistAlias('Foo'); **
** File not found : $sandbox->dewhitelistAlias(['Foo', **
deblacklistAlias(string|array $name) : $this
Remove alias from blacklist
You can pass a string of alias name, or pass an array of the alias names to remove from blacklist
string|array | $name | String of alias name or array of alias names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistAlias('Foo'); **
** File not found : $sandbox->deblacklistAlias(['Foo', **
whitelistUse(string|array $name) : $this
Whitelist use (or alias)
You can pass a string of use (or alias) name, or pass an array of the use (or alias) names to whitelist
string|array | $name | String of use (or alias) name or array of use (or alias) names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistUse('Foo'); **
** File not found : $sandbox->whitelistUse(['Foo', **
blacklistUse(string|array $name) : $this
Blacklist use (or alias)
You can pass a string of use (or alias) name, or pass an array of the use (or alias) names to blacklist
string|array | $name | String of use (or alias) name or array of use (or alias) names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistUse('Foo'); **
** File not found : $sandbox->blacklistUse(['Foo', **
dewhitelistUse(string|array $name) : $this
Remove use (or alias) from whitelist
You can pass a string of use (or alias name, or pass an array of the use (or alias) names to remove from whitelist
string|array | $name | String of use (or alias) name or array of use (or alias) names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistUse('Foo'); **
** File not found : $sandbox->dewhitelistUse(['Foo', **
deblacklistUse(string|array $name) : $this
Remove use (or alias) from blacklist
You can pass a string of use (or alias name, or pass an array of the use (or alias) names to remove from blacklist
string|array | $name | String of use (or alias) name or array of use (or alias) names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistUse('Foo'); **
** File not found : $sandbox->deblacklistUse(['Foo', **
whitelistClass(string|array $name) : $this
Whitelist class
You can pass a string of class name, or pass an array of the class names to whitelist
string|array | $name | String of class name or array of class names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistClass('Foo'); **
** File not found : $sandbox->whitelistClass(['Foo', **
blacklistClass(string|array $name) : $this
Blacklist class
You can pass a string of class name, or pass an array of the class names to blacklist
string|array | $name | String of class name or array of class names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistClass('Foo'); **
** File not found : $sandbox->blacklistClass(['Foo', **
dewhitelistClass(string|array $name) : $this
Remove class from whitelist
You can pass a string of class name, or pass an array of the class names to remove from whitelist
string|array | $name | String of class name or array of class names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistClass('Foo'); **
** File not found : $sandbox->dewhitelistClass(['Foo', **
deblacklistClass(string|array $name) : $this
Remove class from blacklist
You can pass a string of class name, or pass an array of the class names to remove from blacklist
string|array | $name | String of class name or array of class names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistClass('Foo'); **
** File not found : $sandbox->deblacklistClass(['Foo', **
whitelistInterface(string|array $name) : $this
Whitelist interface
You can pass a string of interface name, or pass an array of the interface names to whitelist
string|array | $name | String of interface name or array of interface names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistInterface('Foo'); **
** File not found : $sandbox->whitelistInterface(['Foo', **
blacklistInterface(string|array $name) : $this
Blacklist interface
You can pass a string of interface name, or pass an array of the interface names to blacklist
string|array | $name | String of interface name or array of interface names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistInterface('Foo'); **
** File not found : $sandbox->blacklistInterface(['Foo', **
dewhitelistInterface(string|array $name) : $this
Remove interface from whitelist
You can pass a string of interface name, or pass an array of the interface names to remove from whitelist
string|array | $name | String of interface name or array of interface names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistInterface('Foo'); **
** File not found : $sandbox->dewhitelistInterface(['Foo', **
deblacklistInterface(string|array $name) : $this
Remove interface from blacklist
You can pass a string of interface name, or pass an array of the interface names to remove from blacklist
string|array | $name | String of interface name or array of interface names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistInterface('Foo'); **
** File not found : $sandbox->deblacklistInterface(['Foo', **
whitelistTrait(string|array $name) : $this
Whitelist trait
You can pass a string of trait name, or pass an array of the trait names to whitelist
string|array | $name | String of trait name or array of trait names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistTrait('Foo'); **
** File not found : $sandbox->whitelistTrait(['Foo', **
blacklistTrait(string|array $name) : $this
Blacklist trait
You can pass a string of trait name, or pass an array of the trait names to blacklist
string|array | $name | String of trait name or array of trait names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistTrait('Foo'); **
** File not found : $sandbox->blacklistTrait(['Foo', **
dewhitelistTrait(string|array $name) : $this
Remove trait from whitelist
You can pass a string of trait name, or pass an array of the trait names to remove from whitelist
string|array | $name | String of trait name or array of trait names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistTrait('Foo'); **
** File not found : $sandbox->dewhitelistTrait(['Foo', **
deblacklistTrait(string|array $name) : $this
Remove trait from blacklist
You can pass a string of trait name, or pass an array of the trait names to remove from blacklist
string|array | $name | String of trait name or array of trait names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistTrait('Foo'); **
** File not found : $sandbox->deblacklistTrait(['Foo', **
whitelistKeyword(string|array $name) : $this
Whitelist keyword
You can pass a string of keyword name, or pass an array of the keyword names to whitelist
string|array | $name | String of keyword name or array of keyword names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistKeyword('echo'); **
** File not found : $sandbox->whitelistKeyword(['echo', **
blacklistKeyword(string|array $name) : $this
Blacklist keyword
You can pass a string of keyword name, or pass an array of the keyword names to blacklist
string|array | $name | String of keyword name or array of keyword names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistKeyword('echo'); **
** File not found : $sandbox->blacklistKeyword(['echo', **
dewhitelistKeyword(string|array $name) : $this
Remove keyword from whitelist
You can pass a string of keyword name, or pass an array of the keyword names to remove from whitelist
string|array | $name | String of keyword name or array of keyword names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistKeyword('echo'); **
** File not found : $sandbox->dewhitelistKeyword(['echo', **
deblacklistKeyword(string|array $name) : $this
Remove keyword from blacklist
You can pass a string of keyword name, or pass an array of the keyword names to remove from blacklist
string|array | $name | String of keyword name or array of keyword names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistKeyword('echo'); **
** File not found : $sandbox->deblacklistKeyword(['echo', **
whitelistOperator(string|array $name) : $this
Whitelist operator
You can pass a string of operator name, or pass an array of the operator names to whitelist
string|array | $name | String of operator name or array of operator names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistOperator('+'); **
** File not found : $sandbox->whitelistOperator(['+', **
blacklistOperator(string|array $name) : $this
Blacklist operator
You can pass a string of operator name, or pass an array of the operator names to blacklist
string|array | $name | String of operator name or array of operator names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistOperator('+'); **
** File not found : $sandbox->blacklistOperator(['+', **
dewhitelistOperator(string|array $name) : $this
Remove operator from whitelist
You can pass a string of operator name, or pass an array of the operator names to remove from whitelist
string|array | $name | String of operator name or array of operator names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistOperator('+'); **
** File not found : $sandbox->dewhitelistOperator(['+', **
deblacklistOperator(string|array $name) : $this
Remove operator from blacklist
You can pass a string of operator name, or pass an array of the operator names to remove from blacklist
string|array | $name | String of operator name or array of operator names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistOperator('+'); **
** File not found : $sandbox->deblacklistOperator(['+', **
whitelistPrimitive(string|array $name) : $this
Whitelist primitive
You can pass a string of primitive name, or pass an array of the primitive names to whitelist
string|array | $name | String of primitive name or array of primitive names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistPrimitive('int'); **
** File not found : $sandbox->whitelistPrimitive(['int', **
blacklistPrimitive(string|array $name) : $this
Blacklist primitive
You can pass a string of primitive name, or pass an array of the primitive names to blacklist
string|array | $name | String of primitive name or array of primitive names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistPrimitive('int'); **
** File not found : $sandbox->blacklistPrimitive(['int', **
dewhitelistPrimitive(string|array $name) : $this
Remove primitive from whitelist
You can pass a string of primitive name, or pass an array of the primitive names to remove from whitelist
string|array | $name | String of primitive name or array of primitive names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistPrimitive('int'); **
** File not found : $sandbox->dewhitelistPrimitive(['int', **
deblacklistPrimitive(string|array $name) : $this
Remove primitive from blacklist
You can pass a string of primitive name, or pass an array of the primitive names to remove from blacklist
string|array | $name | String of primitive name or array of primitive names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistPrimitive('int'); **
** File not found : $sandbox->deblacklistPrimitive(['int', **
whitelistType(string|array $name) : $this
Whitelist type
You can pass a string of type name, or pass an array of the type names to whitelist
string|array | $name | String of type name or array of type names to whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->whitelistType('PHPSandbox'); **
** File not found : $sandbox->whitelistType(['PHPSandbox', **
blacklistType(string|array $name) : $this
Blacklist type
You can pass a string of type name, or pass an array of the type names to blacklist
string|array | $name | String of type name or array of type names to blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->blacklistType('PHPSandbox'); **
** File not found : $sandbox->blacklistType(['PHPSandbox', **
dewhitelistType(string|array $name) : $this
Remove type from whitelist
You can pass a string of type name, or pass an array of the type names to remove from whitelist
string|array | $name | String of type name or array of type names to remove from whitelist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->dewhitelistType('PHPSandbox'); **
** File not found : $sandbox->dewhitelistType(['PHPSandbox', **
deblacklistType(string|array $name) : $this
Remove type from blacklist
You can pass a string of type name, or pass an array of the type names to remove from blacklist
string|array | $name | String of type name or array of type names to remove from blacklist |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->deblacklistType('PHPSandbox'); **
** File not found : $sandbox->deblacklistType(['PHPSandbox', **
checkFunc(string $name) : boolean
Check function name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the function name to check |
Throws exception if validation error occurs
Returns true if function is valid, this is also used for testing closures
checkVar(string $name) : boolean
Check variable name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the variable name to check |
Throws exception if validation error occurs
Returns true if variable is valid
checkGlobal(string $name) : boolean
Check global name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the global name to check |
Throws exception if validation error occurs
Returns true if global is valid
checkSuperglobal(string $name) : boolean
Check superglobal name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the superglobal name to check |
Throws exception if validation error occurs
Returns true if superglobal is valid
checkConst(string $name) : boolean
Check constant name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the constant name to check |
Throws exception if validation error occurs
Returns true if constant is valid
checkMagicConst(string $name) : boolean
Check magic constant name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the magic constant name to check |
Throws exception if validation error occurs
Returns true if magic constant is valid
checkNamespace(string $name) : boolean
Check namespace name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the namespace name to check |
Throws exception if validation error occurs
Returns true if namespace is valid
checkAlias(string $name) : boolean
Check alias name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the alias name to check |
Throws exception if validation error occurs
Returns true if alias is valid
checkUse(string $name) : boolean
Check use (or alias) name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the use (or alias) name to check |
Throws exception if validation error occurs
Returns true if use (or alias) is valid
checkClass(string $name, boolean $extends = false) : boolean
Check class name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the class name to check |
boolean | $extends | Flag whether this is an extended class |
Throws exception if validation error occurs
Returns true if class is valid
checkInterface(string $name) : boolean
Check interface name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the interface name to check |
Throws exception if validation error occurs
Returns true if interface is valid
checkTrait(string $name) : boolean
Check trait name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the trait name to check |
Throws exception if validation error occurs
Returns true if trait is valid
checkKeyword(string $name) : boolean
Check keyword name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the keyword name to check |
Throws exception if validation error occurs
Returns true if keyword is valid
checkOperator(string $name) : boolean
Check operator name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the type operator to check |
Throws exception if validation error occurs
Returns true if operator is valid
checkPrimitive(string $name) : boolean
Check primitive name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the primitive name to check |
Throws exception if validation error occurs
Returns true if primitive is valid
checkType(string $name) : boolean
Check type name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
string | $name | String of the type name to check |
Throws exception if validation error occurs
Returns true if type is valid
getPreparedTime(integer|null $round) : float
Return the amount of time the sandbox spent preparing the sandboxed code
You can pass the number of digits you wish to round the return value
integer|null | $round | The number of digits to round the return value |
The amount of time in microseconds it took to prepare the sandboxed code
** File not found : $sandbox->getPreparedTime(); **
** File not found : $sandbox->getPreparedTime(3); **
getExecutionTime(integer|null $round) : float
Return the amount of time the sandbox spent executing the sandboxed code
You can pass the number of digits you wish to round the return value
integer|null | $round | The number of digits to round the return value |
The amount of time in microseconds it took to execute the sandboxed code
** File not found : $sandbox->getExecutionTime(); **
** File not found : $sandbox->getExecutionTime(3); **
getTime(integer|null $round) : float
Return the amount of time the sandbox spent preparing and executing the sandboxed code
You can pass the number of digits you wish to round the return value
integer|null | $round | The number of digits to round the return value |
The amount of time in microseconds it took to prepare and execute the sandboxed code
** File not found : $sandbox->getTime(); **
** File not found : $sandbox->getTime(3); **
getMemoryUsage(integer|null $round) : integer
Return the amount of bytes the sandbox allocated while preparing and executing the sandboxed code
You can pass the number of digits you wish to round the return value
integer|null | $round | The number of digits to round the return value |
The amount of bytes in memory it took to prepare and execute the sandboxed code
** File not found : $sandbox->getMemoryUsage(); **
** File not found : $sandbox->getMemoryUsage(3); **
validate(callable|string $code) : $this
Validate passed callable for execution
callable|string | $code | The callable or string of code to validate |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->validate('<?php **
prepare(callable $code, boolean $skip_validation = false) : string
Prepare passed callable for execution
This function validates your code and automatically whitelists it according to your specified configuration
callable | $code | The callable to prepare for execution |
boolean | $skip_validation | Boolean flag to indicate whether the sandbox should skip validation. Default is false. |
Throws exception if error occurs in parsing, validation or whitelisting
The generated code (this can also be accessed via $sandbox->generated_code)
** File not found : $sandbox->prepare(function(){ **
execute(callable|string $callable = null, boolean $skip_validation = false) : mixed
Prepare and execute callable and return output
This function validates your code and automatically whitelists it according to your specified configuration, then executes it.
callable|string | $callable | Callable or string of PHP code to prepare and execute within the sandbox |
boolean | $skip_validation | Boolean flag to indicate whether the sandbox should skip validation of the pass callable. Default is false. |
Throws exception if error occurs in parsing, validation or whitelisting or if generated closure is invalid
The output from the executed sandboxed code
** File not found : $sandbox->execute(function(){ **
setErrorHandler(callable $handler, integer $error_types = E_ALL) : $this
Set callable to handle errors
This function sets the sandbox error handler and the handled error types. The handler accepts the error number, the error message, the error file, the error line, the error context and the sandbox instance as arguments. If the error handler does not handle errors correctly then the sandbox's security may become compromised!
callable | $handler | Callable to handle thrown Errors |
integer | $error_types | Integer flag of the error types to handle (default is E_ALL) |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setErrorHandler(function($errno, **
error(integer $errno, string $errstr, string $errfile, integer $errline, array $errcontext) : mixed
Invoke sandbox error handler
integer | $errno | Error number |
string | $errstr | Error message |
string | $errfile | Error file |
integer | $errline | Error line number |
array | $errcontext | Error context array |
** File not found : $sandbox->error(0, **
setExceptionHandler(callable $handler) : $this
Set callable to handle thrown exceptions
This function sets the sandbox exception handler. The handler accepts the thrown exception and the sandbox instance as arguments. If the exception handler does not handle exceptions correctly then the sandbox's security may become compromised!
callable | $handler | Callable to handle thrown exceptions |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setExceptionHandler(function(Exception **
getLastException() : \Exception|\PHPSandbox\Error
Gets the last exception thrown by the sandbox
setValidationErrorHandler(callable $handler) : $this
Set callable to handle thrown validation Errors
This function sets the sandbox validation Error handler. The handler accepts the thrown Error and the sandbox instance as arguments. If the error handler does not handle validation errors correctly then the sandbox's security may become compromised!
callable | $handler | Callable to handle thrown validation Errors |
Returns the PHPSandbox instance for fluent querying
** File not found : $sandbox->setValidationErrorHandler(function(Error **