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 : bool
$last_validation_error : \Exception|\PHPSandbox\Error
__construct(array $options, array $functions, array $variables, array $constants, array $namespaces, array $aliases, array $superglobals, array $magic_constants, array $classes, array $interfaces, array $traits) : \PHPSandbox\PHPSandbox
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 |
The returned PHPSandbox variable
create(array $options, array $functions, array $variables, array $constants, array $namespaces, array $aliases, array $superglobals, array $magic_constants, array $classes, array $interfaces, array $traits) : \PHPSandbox\PHPSandbox
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
__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
import(array|string $template, int $import_flag) : \PHPSandbox\PHPSandbox
Import JSON template into sandbox
| array|string | $template | The JSON array or string template to import |
| int | $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 chainability
importJSON(array|string $template, int $import_flag) : \PHPSandbox\PHPSandbox
Import JSON template into sandbox
| array|string | $template | The JSON array or string template to import |
| int | $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 chainability
set_option(string|array $option, bool|int|null $value) : \PHPSandbox\PHPSandbox
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 |
| bool|int|null | $value | Boolean, integer or null $value to set $option to (optional) |
Returns the PHPSandbox instance for chainability
set_options(array|string $options, bool|int|null $value) : \PHPSandbox\PHPSandbox
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 |
| bool|int|null | $value | Boolean, integer or null $value to set $option to (optional) |
Returns the PHPSandbox instance for chainability
reset_options() : \PHPSandbox\PHPSandbox
Reset PHPSandbox options to their default values
Returns the PHPSandbox instance for chainability
set_validator(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 chainability
unset_validator(string $type) : \PHPSandbox\PHPSandbox
Unset validation callable for specified $type
| string | $type | String of $type to unset |
Returns the PHPSandbox instance for chainability
set_func_validator(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 chainability
unset_func_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for functions
Returns the PHPSandbox instance for chainability
set_var_validator(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 chainability
unset_var_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for variables
Returns the PHPSandbox instance for chainability
set_global_validator(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 chainability
unset_global_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for globals
Returns the PHPSandbox instance for chainability
set_superglobal_validator(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 chainability
unset_superglobal_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for superglobals
Returns the PHPSandbox instance for chainability
set_const_validator(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 chainability
unset_const_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for constants
Returns the PHPSandbox instance for chainability
set_magic_const_validator(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 chainability
unset_magic_const_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for magic constants
Returns the PHPSandbox instance for chainability
set_namespace_validator(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 chainability
unset_namespace_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for namespaces
Returns the PHPSandbox instance for chainability
set_alias_validator(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 chainability
unset_alias_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for aliases
Returns the PHPSandbox instance for chainability
set_use_validator(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 chainability
unset_use_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for uses (aka aliases)
Returns the PHPSandbox instance for chainability
set_class_validator(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 chainability
unset_class_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for classes
Returns the PHPSandbox instance for chainability
set_interface_validator(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 chainability
unset_interface_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for interfaces
Returns the PHPSandbox instance for chainability
set_trait_validator(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 chainability
unset_trait_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for traits
Returns the PHPSandbox instance for chainability
set_keyword_validator(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 chainability
unset_keyword_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for keywords
Returns the PHPSandbox instance for chainability
set_operator_validator(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 chainability
unset_operator_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for operators
Returns the PHPSandbox instance for chainability
set_primitive_validator(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 chainability
unset_primitive_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for primitives
Returns the PHPSandbox instance for chainability
set_type_validator(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 chainability
unset_type_validator() : \PHPSandbox\PHPSandbox
Unset validation callable for types
Returns the PHPSandbox instance for chainability
set_prepended_code(string $prepended_code) : \PHPSandbox\PHPSandbox
Set PHPSandbox prepended code
| string | $prepended_code | Sets a string of the prepended code |
Returns the PHPSandbox instance for chainability
set_appended_code(string $appended_code) : \PHPSandbox\PHPSandbox
Set PHPSandbox appended code
| string | $appended_code | Sets a string of the appended code |
Returns the PHPSandbox instance for chainability
set_preparsed_code(string $preparsed_code) : \PHPSandbox\PHPSandbox
Set PHPSandbox preparsed code
| string | $preparsed_code | Sets a string of the preparsed code |
Returns the PHPSandbox instance for chainability
set_parsed_ast(array $parsed_ast) : \PHPSandbox\PHPSandbox
Set PHPSandbox parsed AST array
| array | $parsed_ast | Sets an array of the parsed AST code |
Returns the PHPSandbox instance for chainability
set_prepared_code(string $prepared_code) : \PHPSandbox\PHPSandbox
Set PHPSandbox prepared code
| string | $prepared_code | Sets a string of the prepared code |
Returns the PHPSandbox instance for chainability
set_prepared_ast(array $prepared_ast) : \PHPSandbox\PHPSandbox
Set PHPSandbox prepared AST array
| array | $prepared_ast | Sets an array of the prepared AST code |
Returns the PHPSandbox instance for chainability
set_generated_code(string $generated_code) : \PHPSandbox\PHPSandbox
Set PHPSandbox generated code
| string | $generated_code | Sets a string of the generated code |
Returns the PHPSandbox instance for chainability
set_code(string $generated_code) : \PHPSandbox\PHPSandbox
Set PHPSandbox generated code
| string | $generated_code | Sets a string of the generated code |
Returns the PHPSandbox instance for chainability
_get_defined_functions(array $functions) : 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
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
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
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
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
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
_wrap(mixed $value) : mixed|\PHPSandbox\SandboxedString
Wrap output value in SandboxString
| mixed | $value | Value to wrap |
Returns the wrapped value
define(string|array $type, string|array|null $name, mixed|null $value) : \PHPSandbox\PHPSandbox
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 chainability
undefine(string|array $type, string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
define_func(string|array $name, callable $function, bool $pass_sandbox) : \PHPSandbox\PHPSandbox
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 |
| bool | $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 chainability
define_funcs(array $functions) : \PHPSandbox\PHPSandbox
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 chainability
undefine_func(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
undefine_funcs(array $functions) : \PHPSandbox\PHPSandbox
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 chainability
define_var(string|array $name, mixed $value) : \PHPSandbox\PHPSandbox
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 chainability
define_vars(array $variables) : \PHPSandbox\PHPSandbox
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 chainability
undefine_var(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
undefine_vars(array $variables) : \PHPSandbox\PHPSandbox
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 chainability
define_superglobal(string|array $name, mixed $value) : \PHPSandbox\PHPSandbox
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 chainability
define_superglobals(array $superglobals) : \PHPSandbox\PHPSandbox
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 chainability
has_defined_superglobals(string|null $name) : int|bool
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
is_defined_superglobal(string $name, string|null $key) : bool
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
undefine_superglobal(string|array $name, string|null $key) : \PHPSandbox\PHPSandbox
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 chainability
undefine_superglobals(array $superglobals) : \PHPSandbox\PHPSandbox
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 chainability
define_const(string|array $name, mixed $value) : \PHPSandbox\PHPSandbox
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 chainability
define_consts(array $constants) : \PHPSandbox\PHPSandbox
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 chainability
undefine_const(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
undefine_consts(array $constants) : \PHPSandbox\PHPSandbox
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 chainability
define_magic_const(string|array $name, mixed $value) : \PHPSandbox\PHPSandbox
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 chainability
define_magic_consts(array $magic_constants) : \PHPSandbox\PHPSandbox
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 chainability
undefine_magic_const(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
undefine_magic_consts(array $magic_constants) : \PHPSandbox\PHPSandbox
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 chainability
define_namespace(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
define_namespaces(array $namespaces) : \PHPSandbox\PHPSandbox
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 chainability
get_defined_namespace(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
undefine_namespace(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
undefine_namespaces(array $namespaces) : \PHPSandbox\PHPSandbox
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 chainability
define_alias(string|array $name, string|null $alias) : \PHPSandbox\PHPSandbox
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 chainability
define_aliases(array $aliases) : \PHPSandbox\PHPSandbox
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 chainability
undefine_alias(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
undefine_aliases(array $aliases) : \PHPSandbox\PHPSandbox
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 chainability
define_use(string|array $name, string|null $alias) : \PHPSandbox\PHPSandbox
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 chainability
define_uses(array $uses) : \PHPSandbox\PHPSandbox
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 chainability
undefine_use(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
undefine_uses(array $uses) : \PHPSandbox\PHPSandbox
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 chainability
define_class(string|array $name, mixed $value) : \PHPSandbox\PHPSandbox
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 chainability
define_classes(array $classes) : \PHPSandbox\PHPSandbox
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 chainability
undefine_class(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
undefine_classes(array $classes) : \PHPSandbox\PHPSandbox
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 chainability
define_interface(string|array $name, mixed $value) : \PHPSandbox\PHPSandbox
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 chainability
define_interfaces(array $interfaces) : \PHPSandbox\PHPSandbox
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 chainability
get_defined_interface(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
undefine_interface(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
undefine_interfaces(array $interfaces) : \PHPSandbox\PHPSandbox
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 chainability
define_trait(string|array $name, mixed $value) : \PHPSandbox\PHPSandbox
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 chainability
define_traits(array $traits) : \PHPSandbox\PHPSandbox
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 chainability
undefine_trait(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
undefine_traits(array $traits) : \PHPSandbox\PHPSandbox
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 chainability
whitelist(string|array $type, string|array|null $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist(string|array $type, string|array|null $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist(string|array $type, string|array|null $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist(string|array $type, string|array|null $name) : \PHPSandbox\PHPSandbox
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 chainability
is_whitelisted(string $type, string $name) : bool
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
is_blacklisted(string $type, string $name) : bool
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
has_whitelist_superglobals(string $name) : int
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
has_blacklist_superglobals(string $name) : int
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
is_whitelisted_superglobal(string $name, string $key) : bool
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
is_blacklisted_superglobal(string $name, string $key) : bool
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
is_whitelisted_magic_const(string $name) : bool
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
is_blacklisted_magic_const(string $name) : bool
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
whitelist_func(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_func(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_func(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_func(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_var(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_var(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_var(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_var(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_global(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_global(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_global(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_global(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_superglobal(string|array $name, string $key) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_superglobal(string|array $name, string $key) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_superglobal(string|array $name, string $key) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_superglobal(string|array $name, string $key) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_const(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_const(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_const(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_const(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_magic_const(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_magic_const(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_magic_const(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_magic_const(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_namespace(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_namespace(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_namespace(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_namespace(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_alias(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_alias(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_alias(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_alias(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_use(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_use(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_use(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_use(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_class(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_class(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_class(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_class(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_interface(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_interface(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_interface(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_interface(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_trait(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_trait(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_trait(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_trait(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_keyword(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_keyword(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_keyword(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_keyword(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_operator(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_operator(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_operator(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_operator(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_primitive(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_primitive(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_primitive(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_primitive(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
whitelist_type(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
blacklist_type(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
dewhitelist_type(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
deblacklist_type(string|array $name) : \PHPSandbox\PHPSandbox
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 chainability
check_func(string $name) : bool
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
check_var(string $name) : bool
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
check_global(string $name) : bool
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
check_superglobal(string $name) : bool
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
check_const(string $name) : bool
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
check_magic_const(string $name) : bool
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
check_namespace(string $name) : bool
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
check_alias(string $name) : bool
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
check_use(string $name) : bool
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
check_class(string $name, bool $extends) : bool
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 |
| bool | $extends | Flag whether this is an extended class |
Throws exception if validation error occurs
Returns true if class is valid
check_interface(string $name) : bool
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
check_trait(string $name) : bool
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
check_keyword(string $name) : bool
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
check_operator(string $name) : bool
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
check_primitive(string $name) : bool
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
check_type(string $name) : bool
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
prepend(string|callable $code) : \PHPSandbox\PHPSandbox
Prepend trusted code
| string|callable | $code | String or callable of trusted $code to prepend to generated code |
Returns the PHPSandbox instance for chainability
append(string|callable $code) : \PHPSandbox\PHPSandbox
Append trusted code
| string|callable | $code | String or callable of trusted $code to append to generated code |
Returns the PHPSandbox instance for chainability
clear() : \PHPSandbox\PHPSandbox
Clear all trusted and sandboxed code
Returns the PHPSandbox instance for chainability
clear_trusted_code() : \PHPSandbox\PHPSandbox
Clear all trusted code
Returns the PHPSandbox instance for chainability
clear_prepend() : \PHPSandbox\PHPSandbox
Clear all prepended trusted code
Returns the PHPSandbox instance for chainability
clear_append() : \PHPSandbox\PHPSandbox
Clear all appended trusted code
Returns the PHPSandbox instance for chainability
clear_code() : \PHPSandbox\PHPSandbox
Clear generated code
Returns the PHPSandbox instance for chainability
get_prepared_time(int|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
| int|null | $round | The number of digits to round the return value |
The amount of time in microseconds it took to prepare the sandboxed code
get_execution_time(int|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
| int|null | $round | The number of digits to round the return value |
The amount of time in microseconds it took to execute the sandboxed code
get_time(int|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
| int|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
prepare(callable $code, boolean $skip_validation) : 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)
execute(callable|string $callable, boolean $skip_validation) : 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
set_error_handler(callable $handler, int $error_types) : \PHPSandbox\PHPSandbox
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 |
| int | $error_types | Integer flag of the error types to handle (default is E_ALL) |
Returns the PHPSandbox instance for chainability
unset_error_handler() : \PHPSandbox\PHPSandbox
Unset error handler
This function unsets the sandbox error handler.
Returns the PHPSandbox instance for chainability
error(int $errno, string $errstr, string $errfile, int $errline, array $errcontext) : mixed
Invoke sandbox error handler
| int | $errno | Error number |
| string | $errstr | Error message |
| string | $errfile | Error file |
| int | $errline | Error line number |
| array | $errcontext | Error context array |
set_exception_handler(callable $handler) : \PHPSandbox\PHPSandbox
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 chainability
unset_exception_handler() : \PHPSandbox\PHPSandbox
Unset exception handler
This function unsets the sandbox exception handler.
Returns the PHPSandbox instance for chainability
get_last_exception() : \Exception|\PHPSandbox\Error
Gets the last exception thrown by the sandbox
set_validation_error_handler(callable $handler) : \PHPSandbox\PHPSandbox
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 chainability
unset_validation_error_handler() : \PHPSandbox\PHPSandbox
Unset validation error handler
This function unsets the sandbox validation error handler.
Returns the PHPSandbox instance for chainability
get_last_validation_error() : \Exception|\PHPSandbox\Error
Gets the last validation error thrown by the sandbox
validation_error(\Exception|\PHPSandbox\Error|string $error, int $code, \PHPParser_Node|null $node, mixed $data, \Exception|\PHPSandbox\Error|null $previous) : mixed
Invoke sandbox error validation handler if it exists, throw Error otherwise
| \Exception|\PHPSandbox\Error|string | $error | Error to throw if Error is not handled, or error message string |
| int | $code | The error code |
| \PHPParser_Node|null | $node | The error parser node |
| mixed | $data | The error data |
| \Exception|\PHPSandbox\Error|null | $previous | The previous Error thrown |
getSandbox(mixed $name) : null|\PHPSandbox\PHPSandbox
Get a named PHPSandbox instance (used to retrieve the sandbox instance from within sandboxed code)
| mixed | $name |
normalize_func(string|array $name) : string|array
Normalize function name. This is an internal PHPSandbox function.
| string|array | $name | String of the function $name, or array of strings to normalize |
Returns the normalized function string or an array of normalized strings
normalize_superglobal(string|array $name) : string|array
Normalize superglobal name. This is an internal PHPSandbox function.
| string|array | $name | String of the superglobal $name, or array of strings to normalize |
Returns the normalized superglobal string or an array of normalized strings
normalize_magic_const(string|array $name) : string|array
Normalize magic constant name. This is an internal PHPSandbox function.
| string|array | $name | String of the magic constant $name, or array of strings to normalize |
Returns the normalized magic constant string or an array of normalized strings
normalize_namespace(string|array $name) : string|array
Normalize namespace name. This is an internal PHPSandbox function.
| string|array | $name | String of the namespace $name, or array of strings to normalize |
Returns the normalized namespace string or an array of normalized strings
normalize_alias(string|array $name) : string|array
Normalize alias name. This is an internal PHPSandbox function.
| string|array | $name | String of the alias $name, or array of strings to normalize |
Returns the normalized alias string or an array of normalized strings
normalize_use(string|array $name) : string|array
Normalize use (or alias) name. This is an internal PHPSandbox function.
| string|array | $name | String of the use (or alias) $name, or array of strings to normalize |
Returns the normalized use (or alias) string or an array of normalized strings
normalize_interface(string|array $name) : string|array
Normalize interface name. This is an internal PHPSandbox function.
| string|array | $name | String of the interface $name, or array of strings to normalize |
Returns the normalized interface string or an array of normalized strings
normalize_trait(string|array $name) : string|array
Normalize trait name. This is an internal PHPSandbox function.
| string|array | $name | String of the trait $name, or array of strings to normalize |
Returns the normalized trait string or an array of normalized strings
normalize_keyword(string|array $name) : string|array
Normalize keyword name. This is an internal PHPSandbox function.
| string|array | $name | String of the keyword $name, or array of strings to normalize |
Returns the normalized keyword string or an array of normalized strings
normalize_operator(string|array $name) : string|array
Normalize operator name. This is an internal PHPSandbox function.
| string|array | $name | String of the operator $name, or array of strings to normalize |
Returns the normalized operator string or an array of normalized strings
normalize_primitive(string|array $name) : string|array
Normalize primitive name. This is an internal PHPSandbox function.
| string|array | $name | String of the primitive $name, or array of strings to normalize |
Returns the normalized primitive string or an array of normalized strings
normalize_type(string|array $name) : string|array
Normalize type name. This is an internal PHPSandbox function.
| string|array | $name | String of the type $name, or array of strings to normalize |
Returns the normalized type string or an array of normalized strings
auto_whitelist(string $code, bool $appended) : mixed
Automatically whitelisted trusted code
| string | $code | String of trusted $code to automatically whitelist |
| bool | $appended | Flag if this code ir prended or appended (true = appended) |
Throw exception if code cannot be parsed for whitelisting
Return result of error handler if $code could not be parsed