\PHPSandboxPHPSandbox

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

Summary

Methods
Properties
Constants
__construct()
create()
__invoke()
__sleep()
__wakeup()
import()
importJSON()
getName()
setOption()
setOptions()
resetOptions()
getOption()
setValidator()
getValidator()
unsetValidator()
setFuncValidator()
getFuncValidator()
unsetFuncValidator()
setVarValidator()
getVarValidator()
unsetVarValidator()
setGlobalValidator()
getGlobalValidator()
unsetGlobalValidator()
setSuperglobalValidator()
getSuperglobalValidator()
unsetSuperglobalValidator()
setConstValidator()
getConstValidator()
unsetConstValidator()
setMagicConstValidator()
getMagicConstValidator()
unsetMagicConstValidator()
setNamespaceValidator()
getNamespaceValidator()
unsetNamespaceValidator()
setAliasValidator()
getAliasValidator()
unsetAliasValidator()
setUseValidator()
getUseValidator()
unsetUseValidator()
setClassValidator()
getClassValidator()
unsetClassValidator()
setInterfaceValidator()
getInterfaceValidator()
unsetInterfaceValidator()
setTraitValidator()
getTraitValidator()
unsetTraitValidator()
setKeywordValidator()
getKeywordValidator()
unsetKeywordValidator()
setOperatorValidator()
getOperatorValidator()
unsetOperatorValidator()
setPrimitiveValidator()
getPrimitiveValidator()
unsetPrimitiveValidator()
setTypeValidator()
getTypeValidator()
unsetTypeValidator()
setPrependedCode()
setAppendedCode()
setPreparsedCode()
setParsedAST()
setPreparedCode()
setPreparedAST()
setGeneratedCode()
setCode()
getPrependedCode()
getAppendedCode()
getPreparsedCode()
getParsedAST()
getPreparedCode()
getPreparedAST()
getGeneratedCode()
getCode()
_get_defined_functions()
_get_defined_vars()
_get_superglobal()
_get_magic_const()
_get_defined_constants()
_get_declared_classes()
_get_declared_interfaces()
_get_declared_traits()
_func_get_args()
_func_get_arg()
_func_num_args()
_var_dump()
_print_r()
_var_export()
_intval()
_floatval()
_boolval()
_arrayval()
_objectval()
_is_string()
_is_object()
_is_scalar()
_is_callable()
_get_included_files()
_include()
_include_once()
_require()
_require_once()
call_func()
define()
undefine()
defineFunc()
defineFuncs()
hasDefinedFuncs()
isDefinedFunc()
undefineFunc()
undefineFuncs()
defineVar()
defineVars()
hasDefinedVars()
isDefinedVar()
undefineVar()
undefineVars()
defineSuperglobal()
defineSuperglobals()
hasDefinedSuperglobals()
isDefinedSuperglobal()
undefineSuperglobal()
undefineSuperglobals()
defineConst()
defineConsts()
hasDefinedConsts()
isDefinedConst()
undefineConst()
undefineConsts()
defineMagicConst()
defineMagicConsts()
hasDefinedMagicConsts()
isDefinedMagicConst()
undefineMagicConst()
undefineMagicConsts()
defineNamespace()
defineNamespaces()
hasDefinedNamespaces()
isDefinedNamespace()
getDefinedNamespace()
undefineNamespace()
undefineNamespaces()
defineAlias()
defineAliases()
hasDefinedAliases()
isDefinedAlias()
undefineAlias()
undefineAliases()
defineUse()
defineUses()
hasDefinedUses()
isDefinedUse()
undefineUse()
undefineUses()
defineClass()
defineClasses()
hasDefinedClasses()
isDefinedClass()
getDefinedClass()
undefineClass()
undefineClasses()
defineInterface()
defineInterfaces()
hasDefinedInterfaces()
isDefinedInterface()
getDefinedInterface()
undefineInterface()
undefineInterfaces()
defineTrait()
defineTraits()
hasDefinedTraits()
isDefinedTrait()
getDefinedTrait()
undefineTrait()
undefineTraits()
whitelist()
blacklist()
dewhitelist()
deblacklist()
hasWhitelist()
hasBlacklist()
isWhitelisted()
isBlacklisted()
hasWhitelistedFuncs()
hasBlacklistedFuncs()
isWhitelistedFunc()
isBlacklistedFunc()
hasWhitelistedVars()
hasBlacklistedVars()
isWhitelistedVar()
isBlacklistedVar()
hasWhitelistedGlobals()
hasBlacklistedGlobals()
isWhitelistedGlobal()
isBlacklistedGlobal()
hasWhitelistedSuperglobals()
hasBlacklistedSuperglobals()
isWhitelistedSuperglobal()
isBlacklistedSuperglobal()
hasWhitelistedConsts()
hasBlacklistedConsts()
isWhitelistedConst()
isBlacklistedConst()
hasWhitelistedMagicConsts()
hasBlacklistedMagicConsts()
isWhitelistedMagicConst()
isBlacklistedMagicConst()
hasWhitelistedNamespaces()
hasBlacklistedNamespaces()
isWhitelistedNamespace()
isBlacklistedNamespace()
hasWhitelistedAliases()
hasBlacklistedAliases()
isWhitelistedAlias()
isBlacklistedAlias()
hasWhitelistedUses()
hasBlacklistedUses()
isWhitelistedUse()
isBlacklistedUse()
hasWhitelistedClasses()
hasBlacklistedClasses()
isWhitelistedClass()
isBlacklistedClass()
hasWhitelistedInterfaces()
hasBlacklistedInterfaces()
isWhitelistedInterface()
isBlacklistedInterface()
hasWhitelistedTraits()
hasBlacklistedTraits()
isWhitelistedTrait()
isBlacklistedTrait()
hasWhitelistKeywords()
hasBlacklistedKeywords()
isWhitelistedKeyword()
isBlacklistedKeyword()
hasWhitelistedOperators()
hasBlacklistedOperators()
isWhitelistedOperator()
isBlacklistedOperator()
hasWhitelistedPrimitives()
hasBlacklistedPrimitives()
isWhitelistedPrimitive()
isBlacklistedPrimitive()
hasWhitelistedTypes()
hasBlacklistedTypes()
isWhitelistedType()
isBlacklistedType()
whitelistFunc()
blacklistFunc()
dewhitelistFunc()
deblacklistFunc()
whitelistVar()
blacklistVar()
dewhitelistVar()
deblacklistVar()
whitelistGlobal()
blacklistGlobal()
dewhitelistGlobal()
deblacklistGlobal()
whitelistSuperglobal()
blacklistSuperglobal()
dewhitelistSuperglobal()
deblacklistSuperglobal()
whitelistConst()
blacklistConst()
dewhitelistConst()
deblacklistConst()
whitelistMagicConst()
blacklistMagicConst()
dewhitelistMagicConst()
deblacklistMagicConst()
whitelistNamespace()
blacklistNamespace()
dewhitelistNamespace()
deblacklistNamespace()
whitelistAlias()
blacklistAlias()
dewhitelistAlias()
deblacklistAlias()
whitelistUse()
blacklistUse()
dewhitelistUse()
deblacklistUse()
whitelistClass()
blacklistClass()
dewhitelistClass()
deblacklistClass()
whitelistInterface()
blacklistInterface()
dewhitelistInterface()
deblacklistInterface()
whitelistTrait()
blacklistTrait()
dewhitelistTrait()
deblacklistTrait()
whitelistKeyword()
blacklistKeyword()
dewhitelistKeyword()
deblacklistKeyword()
whitelistOperator()
blacklistOperator()
dewhitelistOperator()
deblacklistOperator()
whitelistPrimitive()
blacklistPrimitive()
dewhitelistPrimitive()
deblacklistPrimitive()
whitelistType()
blacklistType()
dewhitelistType()
deblacklistType()
checkFunc()
checkVar()
checkGlobal()
checkSuperglobal()
checkConst()
checkMagicConst()
checkNamespace()
checkAlias()
checkUse()
checkClass()
checkInterface()
checkTrait()
checkKeyword()
checkOperator()
checkPrimitive()
checkType()
prepend()
append()
clear()
clearTrustedCode()
clearPrependedCode()
clearAppendedCode()
clearCode()
getPreparedTime()
getExecutionTime()
getTime()
getMemoryUsage()
validate()
prepare()
execute()
setErrorHandler()
getErrorHandler()
unsetErrorHandler()
getLastError()
error()
setExceptionHandler()
getExceptionHandler()
unsetExceptionHandler()
getLastException()
exception()
setValidationErrorHandler()
getValidationErrorHandler()
unsetValidationErrorHandler()
getLastValidationError()
validationError()
getSandbox()
getIterator()
$superglobals
$magic_constants
$defined_funcs
$arg_funcs
$sandboxed_string_funcs
$name
$validate_functions
$validate_variables
$validate_globals
$validate_superglobals
$validate_constants
$validate_magic_constants
$validate_namespaces
$validate_aliases
$validate_classes
$validate_interfaces
$validate_traits
$validate_keywords
$validate_operators
$validate_primitives
$validate_types
$error_level
$time_limit
$allow_includes
$sandbox_includes
$restore_error_level
$convert_errors
$capture_output
$auto_whitelist_trusted_code
$auto_whitelist_functions
$auto_whitelist_constants
$auto_whitelist_globals
$auto_whitelist_classes
$auto_whitelist_interfaces
$auto_whitelist_traits
$auto_define_vars
$overwrite_defined_funcs
$overwrite_func_get_args
$overwrite_sandboxed_string_funcs
$overwrite_superglobals
$allow_functions
$allow_closures
$allow_variables
$allow_static_variables
$allow_objects
$allow_constants
$allow_globals
$allow_namespaces
$allow_aliases
$allow_classes
$allow_interfaces
$allow_traits
$allow_generators
$allow_escaping
$allow_casting
$allow_error_suppressing
$allow_references
$allow_backticks
$allow_halting
SANDBOX_PREFIX
IMPORT_ALL
IMPORT_OPTIONS
IMPORT_DEFINITIONS
IMPORT_WHITELIST
IMPORT_BLACKLIST
IMPORT_TRUSTED_CODE
IMPORT_CODE
normalizeFunc()
normalizeSuperglobal()
normalizeMagicConst()
normalizeNamespace()
normalizeAlias()
normalizeUse()
normalizeClass()
normalizeInterface()
normalizeTrait()
normalizeKeyword()
normalizeOperator()
normalizePrimitive()
normalizeType()
prepareVars()
prepareConsts()
prepareNamespaces()
prepareAliases()
prepareUses()
disassemble()
autoWhitelist()
autoDefine()
$definitions
$whitelist
$blacklist
$validation
$includes
$sandboxes
$prepended_code
$appended_code
$prepare_time
$execution_time
$memory_usage
$preparsed_code
$parsed_ast
$prepared_code
$prepared_ast
$generated_code
$error_handler
$error_handler_types
$last_error
$exception_handler
$last_exception
$validation_error_handler
$last_validation_error
N/A
No private methods found
No private properties found
N/A

Constants

SANDBOX_PREFIX

SANDBOX_PREFIX

IMPORT_ALL

IMPORT_ALL

IMPORT_OPTIONS

IMPORT_OPTIONS

IMPORT_DEFINITIONS

IMPORT_DEFINITIONS

IMPORT_WHITELIST

IMPORT_WHITELIST

IMPORT_BLACKLIST

IMPORT_BLACKLIST

IMPORT_TRUSTED_CODE

IMPORT_TRUSTED_CODE

IMPORT_CODE

IMPORT_CODE

Properties

$superglobals

$superglobals : array

Type

array — A static array of superglobal names used for redefining superglobal values

$magic_constants

$magic_constants : array

Type

array — A static array of magic constant names used for redefining magic constant values

$defined_funcs

$defined_funcs : array

Type

array — A static array of defined_* and declared_* functions names used for redefining defined_* and declared_* values

$arg_funcs

$arg_funcs : array

Type

array — A static array of func_get_args, func_get_arg, and func_num_args used for redefining those functions

$sandboxed_string_funcs

$sandboxed_string_funcs : array

Type

array — A static array of var_dump, print_r and var_export, intval, floatval, is_string, is_object, is_scalar and is_callable for redefining those functions

$name

$name : string

Type

string — The randomly generated name of the PHPSandbox variable passed to the generated closure

$validate_functions

$validate_functions : boolean

Type

boolean — Flag to indicate whether the sandbox should validate functions

$validate_variables

$validate_variables : boolean

Type

boolean — Flag to indicate whether the sandbox should validate variables

$validate_globals

$validate_globals : boolean

Type

boolean — Flag to indicate whether the sandbox should validate globals

$validate_superglobals

$validate_superglobals : boolean

Type

boolean — Flag to indicate whether the sandbox should validate superglobals

$validate_constants

$validate_constants : boolean

Type

boolean — Flag to indicate whether the sandbox should validate constants

$validate_magic_constants

$validate_magic_constants : boolean

Type

boolean — Flag to indicate whether the sandbox should validate magic constants

$validate_namespaces

$validate_namespaces : boolean

Type

boolean — Flag to indicate whether the sandbox should validate namespaces

$validate_aliases

$validate_aliases : boolean

Type

boolean — Flag to indicate whether the sandbox should validate aliases (aka use)

$validate_classes

$validate_classes : boolean

Type

boolean — Flag to indicate whether the sandbox should validate classes

$validate_interfaces

$validate_interfaces : boolean

Type

boolean — Flag to indicate whether the sandbox should validate interfaces

$validate_traits

$validate_traits : boolean

Type

boolean — Flag to indicate whether the sandbox should validate traits

$validate_keywords

$validate_keywords : boolean

Type

boolean — Flag to indicate whether the sandbox should validate keywords

$validate_operators

$validate_operators : boolean

Type

boolean — Flag to indicate whether the sandbox should validate operators

$validate_primitives

$validate_primitives : boolean

Type

boolean — Flag to indicate whether the sandbox should validate primitives

$validate_types

$validate_types : boolean

Type

boolean — Flag to indicate whether the sandbox should validate types

$error_level

$error_level : integer

Type

integer — The error_reporting level to set the PHPSandbox scope to when executing the generated closure, if set to null it will use parent scope error level.

$time_limit

$time_limit : integer

Type

integer — Integer value of maximum number of seconds the sandbox should be allowed to execute

$allow_includes

$allow_includes : boolean

Type

boolean — Flag to indicate whether the sandbox should allow included files

$sandbox_includes

$sandbox_includes : boolean

Type

boolean — Flag to indicate whether the sandbox should automatically sandbox included files

$restore_error_level

$restore_error_level : boolean

Type

boolean — Flag to indicate whether the sandbox should return error_reporting to its previous level after execution

$convert_errors

$convert_errors : boolean

Type

boolean — Flag to indicate whether the sandbox should convert errors to exceptions

$capture_output

$capture_output : boolean

Type

boolean — Flag whether to return output via an output buffer

$auto_whitelist_trusted_code

$auto_whitelist_trusted_code : boolean

Type

boolean — Should PHPSandbox automagically whitelist prepended and appended code?

$auto_whitelist_functions

$auto_whitelist_functions : boolean

Type

boolean — Should PHPSandbox automagically whitelist functions created in sandboxed code if $allow_functions is true?

$auto_whitelist_constants

$auto_whitelist_constants : boolean

Type

boolean — Should PHPSandbox automagically whitelist constants created in sandboxed code if $allow_constants is true?

$auto_whitelist_globals

$auto_whitelist_globals : boolean

Type

boolean — Should PHPSandbox automagically whitelist global variables created in sandboxed code if $allow_globals is true? (Used to whitelist them in the variables list)

$auto_whitelist_classes

$auto_whitelist_classes : boolean

Type

boolean — Should PHPSandbox automagically whitelist classes created in sandboxed code if $allow_classes is true?

$auto_whitelist_interfaces

$auto_whitelist_interfaces : boolean

Type

boolean — Should PHPSandbox automagically whitelist interfaces created in sandboxed code if $allow_interfaces is true?

$auto_whitelist_traits

$auto_whitelist_traits : boolean

Type

boolean — Should PHPSandbox automagically whitelist traits created in sandboxed code if $allow_traits is true?

$auto_define_vars

$auto_define_vars : boolean

Type

boolean — Should PHPSandbox automagically define variables passed to prepended, appended and prepared code closures?

$overwrite_defined_funcs

$overwrite_defined_funcs : boolean

Type

boolean — Should PHPSandbox overwrite get_define_functions, get_defined_vars, get_defined_constants, get_declared_classes, get_declared_interfaces and get_declared_traits?

$overwrite_func_get_args

$overwrite_func_get_args : boolean

Type

boolean — Should PHPSandbox overwrite func_get_args, func_get_arg and func_num_args?

$overwrite_sandboxed_string_funcs

$overwrite_sandboxed_string_funcs : boolean

Type

boolean — Should PHPSandbox overwrite functions to help hide SandboxedStrings?

$overwrite_superglobals

$overwrite_superglobals : boolean

Type

boolean — Should PHPSandbox overwrite $_GET, $_POST, $_COOKIE, $_FILES, $_ENV, $_REQUEST, $_SERVER, $_SESSION and $GLOBALS superglobals? If so, unless alternate superglobal values have been defined they will return as empty arrays.

$allow_functions

$allow_functions : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to declare functions?

$allow_closures

$allow_closures : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to declare closures?

$allow_variables

$allow_variables : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to create variables?

$allow_static_variables

$allow_static_variables : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to create static variables?

$allow_objects

$allow_objects : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to create objects of allow classes (e.g. new keyword)?

$allow_constants

$allow_constants : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to define constants?

$allow_globals

$allow_globals : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to use global keyword to access variables in the global scope?

$allow_namespaces

$allow_namespaces : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to declare namespaces (utilizing the defineNamespace function?)

$allow_aliases

$allow_aliases : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to use namespaces and declare namespace aliases (utilizing the defineAlias function?)

$allow_classes

$allow_classes : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to declare classes?

$allow_interfaces

$allow_interfaces : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to declare interfaces?

$allow_traits

$allow_traits : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to declare traits?

$allow_generators

$allow_generators : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to create generators?

$allow_escaping

$allow_escaping : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to escape to HTML?

$allow_casting

$allow_casting : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to cast types? (This will still be subject to allowed classes)

$allow_error_suppressing

$allow_error_suppressing : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to suppress errors (e.g. the @ operator?)

$allow_references

$allow_references : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to assign references?

$allow_backticks

$allow_backticks : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to use backtick execution? (e.g. $var = \`ping google.com\`; This will also be disabled if shell_exec is not whitelisted or if it is blacklisted, and will be converted to a defined shell_exec function call if one is defined)

$allow_halting

$allow_halting : boolean

Type

boolean — Should PHPSandbox allow sandboxed code to halt the PHP compiler?

$definitions

$definitions : array

Type

array — Array of defined functions, superglobals, etc. If an array type contains elements, then it overwrites its external counterpart

$whitelist

$whitelist : array

Type

array — Array of whitelisted functions, classes, etc. If an array type contains elements, then it overrides its blacklist counterpart

$blacklist

$blacklist : array

Type

array — Array of blacklisted functions, classes, etc. Any whitelisted array types override their counterpart in this array

$validation

$validation : array

Type

array — Array of custom validation functions

$includes

$includes : array

Type

array — Array of sandboxed included files

$sandboxes

$sandboxes : array<mixed,\PHPSandbox\PHPSandbox>

Type

array<mixed,\PHPSandbox\PHPSandbox> — Array of PHPSandboxes

$prepended_code

$prepended_code : string

Type

string — String of prepended code, will be automagically whitelisted for functions, variables, globals, constants, classes, interfaces and traits if $auto_whitelist_trusted_code is true

$appended_code

$appended_code : string

Type

string — String of appended code, will be automagically whitelisted for functions, variables, globals, constants, classes, interfaces and traits if $auto_whitelist_trusted_code is true

$prepare_time

$prepare_time : float

Type

float — Float of the number of microseconds it took to prepare the sandbox

$execution_time

$execution_time : float

Type

float — Float of the number of microseconds it took to execute the sandbox

$memory_usage

$memory_usage : integer

Type

integer — Int of the number of bytes the sandbox allocates during execution

$preparsed_code

$preparsed_code : string

Type

string — String of preparsed code, for debugging and serialization purposes

$parsed_ast

$parsed_ast : array

Type

array — Array of parsed code broken down into AST tokens, for debugging and serialization purposes

$prepared_code

$prepared_code : string

Type

string — String of prepared code, for debugging and serialization purposes

$prepared_ast

$prepared_ast : array

Type

array — Array of prepared code broken down into AST tokens, for debugging and serialization purposes

$generated_code

$generated_code : string

Type

string — String of generated code, for debugging and serialization purposes

$error_handler

$error_handler : null|callable

Type

null|callable — Callable that handles any errors when set

$error_handler_types

$error_handler_types : integer

Type

integer — Integer value of the error types to handle (default is E_ALL)

$last_error

$last_error : array

Type

array — The last error thrown by the sandbox

$exception_handler

$exception_handler : null|callable

Type

null|callable — Callable that handles any thrown exceptions when set

$last_exception

$last_exception : \Exception

Type

\Exception — The last exception thrown by the sandbox

$validation_error_handler

$validation_error_handler : null|callable

Type

null|callable — Callable that handles any thrown validation errors when set

$last_validation_error

$last_validation_error : \Exception|\PHPSandbox\Error

Type

\Exception|\PHPSandbox\Error — The last validation error thrown by the sandbox

Methods

__construct()

__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

Parameters

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

Examples

= new PHPSandbox\PHPSandbox; You can pass optional arrays of predefined functions, variables, etc. to the sandbox through the constructor
** File not found : $sandbox **

create()

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

Parameters

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

Returns

$this —

The returned PHPSandbox variable

Examples

= PHPSandbox\PHPSandbox::create();
** File not found : $sandbox **

__invoke()

__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

Parameters

\Closure|callable|string $code

The closure, callable or string of code to execute

Returns

mixed —

The output of the executed sandboxed code

Examples

= new PHPSandbox\PHPSandbox; $sandbox(function(){ echo 'Hello world!'; });
** File not found : $sandbox **

__sleep()

__sleep() : array

PHPSandbox __sleep magic method

Returns

array —

An array of property keys to be serialized

Examples

= new PHPSandbox\PHPSandbox; serialize($sandbox);
** File not found : $sandbox **

__wakeup()

__wakeup() 

PHPSandbox __wakeup magic method

Examples

= unserialize($sandbox_string);
** File not found : $sandbox **

import()

import(array|string  $template, integer  $import_flag) : $this

Import JSON template into sandbox

Parameters

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

\PHPSandbox\Error

Throws exception if JSON template could not be imported

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> 'echo "Hello World!";']);
** File not found : $sandbox->import(['code' **
** File not found : $sandbox->import(file_get_contents("template.json")); **

importJSON()

importJSON(array|string  $template, integer  $import_flag) : $this

Import JSON template into sandbox

Parameters

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

\PHPSandbox\Error

Throws exception if JSON template could not be imported

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> 'echo "Hello World!";']);
** File not found : $sandbox->importJSON(['code' **
** File not found : $sandbox->importJSON(file_get_contents("template.json")); **

getName()

getName() : string

Get name of PHPSandbox variable

Returns

string —

The name of the PHPSandbox variable

setOption()

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.

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> true]);
** File not found : $sandbox->setOption(['allow_functions' **
'allow_classes'], true);
** File not found : $sandbox->setOption(['allow_functions', **
true);
** File not found : $sandbox->setOption('allow_functions', **

setOptions()

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.

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> true]);
** File not found : $sandbox->setOption(['allow_functions' **
'allow_classes'], true);
** File not found : $sandbox->setOption(['allow_functions', **

resetOptions()

resetOptions() : $this

Reset PHPSandbox options to their default values

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->resetOptions(); **

getOption()

getOption(string  $option) : boolean|integer|null

Get PHPSandbox option

You pass a string $option name to get its associated value

Parameters

string $option

String of $option name to get

Returns

boolean|integer|null —

Returns the value of the requested option

Examples

** File not found : $sandbox->getOption('allow_functions'); **

setValidator()

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

Parameters

string $type

String of $type name to set validator for

callable $callable

Callable that validates the passed element

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

function($function, PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setValidator('function', **

getValidator()

getValidator(string  $type) : callable|null

Get validation callable for specified $type

Parameters

string $type

String of $type to return

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getValidator('function'); **

unsetValidator()

unsetValidator(string  $type) : \PHPSandbox\PHPSandbox

Unset validation callable for specified $type

Parameters

string $type

String of $type to unset

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetValidator('function'); **

setFuncValidator()

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!

Parameters

callable $callable

Callable that validates the normalized passed function name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setFuncValidator(function($function, **

getFuncValidator()

getFuncValidator() : callable|null

Get validation for functions

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getFuncValidator(); **

unsetFuncValidator()

unsetFuncValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for functions

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetFuncValidator(); **

setVarValidator()

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

Parameters

callable $callable

Callable that validates the passed variable name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setVarValidator(function($variable, **

getVarValidator()

getVarValidator() : callable|null

Get validation callable for variables

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getVarValidator(); **

unsetVarValidator()

unsetVarValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for variables

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetVarValidator(); **

setGlobalValidator()

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

Parameters

callable $callable

Callable that validates the passed global name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setGlobalValidator(function($global, **

getGlobalValidator()

getGlobalValidator() : callable|null

Get validation callable for globals

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getGlobalValidator(); **

unsetGlobalValidator()

unsetGlobalValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for globals

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetGlobalValidator(); **

setSuperglobalValidator()

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 _

Parameters

callable $callable

Callable that validates the passed superglobal name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setSuperglobalValidator(function($superglobal, **

getSuperglobalValidator()

getSuperglobalValidator() : callable|null

Get validation callable for superglobals

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getSuperglobalValidator(); **

unsetSuperglobalValidator()

unsetSuperglobalValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for superglobals

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetSuperglobalValidator(); **

setConstValidator()

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

Parameters

callable $callable

Callable that validates the passed constant name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setConstValidator(function($constant, **

getConstValidator()

getConstValidator() : callable|null

Get validation callable for constants

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getConstValidator(); **

unsetConstValidator()

unsetConstValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for constants

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetConstValidator(); **

setMagicConstValidator()

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 __

Parameters

callable $callable

Callable that validates the passed magic constant name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setMagicConstValidator(function($magic_constant, **

getMagicConstValidator()

getMagicConstValidator() : callable|null

Get validation callable for magic constants

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getMagicConstValidator(); **

unsetMagicConstValidator()

unsetMagicConstValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for magic constants

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetMagicConstValidator(); **

setNamespaceValidator()

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

Parameters

callable $callable

Callable that validates the passed namespace name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setNamespaceValidator(function($namespace, **

getNamespaceValidator()

getNamespaceValidator() : callable|null

Get validation callable for namespaces

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getNamespaceValidator(); **

unsetNamespaceValidator()

unsetNamespaceValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for namespaces

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetNamespaceValidator(); **

setAliasValidator()

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

Parameters

callable $callable

Callable that validates the passed alias name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setAliasValidator(function($alias, **

getAliasValidator()

getAliasValidator() : callable|null

Get validation callable for aliases

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getAliasValidator(); **

unsetAliasValidator()

unsetAliasValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for aliases

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetAliasValidator(); **

setUseValidator()

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

Parameters

callable $callable

Callable that validates the passed use (aka alias) name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setUseValidator(function($use, **

getUseValidator()

getUseValidator() : callable|null

Get validation callable for uses (aka aliases)

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getUseValidator(); **

unsetUseValidator()

unsetUseValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for uses (aka aliases)

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetUseValidator(); **

setClassValidator()

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

Parameters

callable $callable

Callable that validates the passed class name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setClassValidator(function($class, **

getClassValidator()

getClassValidator() : callable|null

Get validation callable for classes

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getClassValidator(); **

unsetClassValidator()

unsetClassValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for classes

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetClassValidator(); **

setInterfaceValidator()

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

Parameters

callable $callable

Callable that validates the passed interface name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setInterfaceValidator(function($interface, **

getInterfaceValidator()

getInterfaceValidator() : callable|null

Get validation callable for interfaces

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getInterfaceValidator(); **

unsetInterfaceValidator()

unsetInterfaceValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for interfaces

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetInterfaceValidator(); **

setTraitValidator()

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

Parameters

callable $callable

Callable that validates the passed trait name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setTraitValidator(function($trait, **

getTraitValidator()

getTraitValidator() : callable|null

Get validation callable for traits

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getTraitValidator(); **

unsetTraitValidator()

unsetTraitValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for traits

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetTraitValidator(); **

setKeywordValidator()

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

Parameters

callable $callable

Callable that validates the passed keyword name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setKeywordValidator(function($keyword, **

getKeywordValidator()

getKeywordValidator() : callable|null

Get validation callable for keywords

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getKeywordValidator(); **

unsetKeywordValidator()

unsetKeywordValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for keywords

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetKeywordValidator(); **

setOperatorValidator()

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

Parameters

callable $callable

Callable that validates the passed operator name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setOperatorValidator(function($operator, **

getOperatorValidator()

getOperatorValidator() : callable|null

Get validation callable for operators

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getOperatorValidator(); **

unsetOperatorValidator()

unsetOperatorValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for operators

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetOperatorValidator(); **

setPrimitiveValidator()

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

Parameters

callable $callable

Callable that validates the passed primitive name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setPrimitiveValidator(function($primitive, **

getPrimitiveValidator()

getPrimitiveValidator() : callable|null

Get validation callable for primitives

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getPrimitiveValidator(); **

unsetPrimitiveValidator()

unsetPrimitiveValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for primitives

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetPrimitiveValidator(); **

setTypeValidator()

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

Parameters

callable $callable

Callable that validates the passed type name

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

Examples

PHPSandbox $sandbox){ return true; });
** File not found : $sandbox->setTypeValidator(function($type, **

getTypeValidator()

getTypeValidator() : callable|null

Get validation callable for types

Returns

callable|null

Examples

//return callable
** File not found : $sandbox->getTypeValidator(); **

unsetTypeValidator()

unsetTypeValidator() : $this

Unset validation callable for types

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

//clear custom validation
** File not found : $sandbox->unsetTypeValidator(); **

setPrependedCode()

setPrependedCode(string  $prepended_code = '') : $this

Set PHPSandbox prepended code

Parameters

string $prepended_code

Sets a string of the prepended code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

setAppendedCode()

setAppendedCode(string  $appended_code = '') : $this

Set PHPSandbox appended code

Parameters

string $appended_code

Sets a string of the appended code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

setPreparsedCode()

setPreparsedCode(string  $preparsed_code = '') : $this

Set PHPSandbox preparsed code

Parameters

string $preparsed_code

Sets a string of the preparsed code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

setParsedAST()

setParsedAST(array  $parsed_ast = array()) : $this

Set PHPSandbox parsed AST array

Parameters

array $parsed_ast

Sets an array of the parsed AST code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

setPreparedCode()

setPreparedCode(string  $prepared_code = '') : $this

Set PHPSandbox prepared code

Parameters

string $prepared_code

Sets a string of the prepared code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

setPreparedAST()

setPreparedAST(array  $prepared_ast = array()) : $this

Set PHPSandbox prepared AST array

Parameters

array $prepared_ast

Sets an array of the prepared AST code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

setGeneratedCode()

setGeneratedCode(string  $generated_code = '') : $this

Set PHPSandbox generated code

Parameters

string $generated_code

Sets a string of the generated code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

setCode()

setCode(string  $generated_code = '') : $this

Set PHPSandbox generated code

Parameters

string $generated_code

Sets a string of the generated code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

getPrependedCode()

getPrependedCode() : string

Get PHPSandbox prepended code

Returns

string —

Returns a string of the prepended code

getAppendedCode()

getAppendedCode() : string

Get PHPSandbox appended code

Returns

string —

Returns a string of the appended code

getPreparsedCode()

getPreparsedCode() : string

Get PHPSandbox preparsed code

Returns

string —

Returns a string of the preparsed code

getParsedAST()

getParsedAST() : array

Get PHPSandbox parsed AST array

Returns

array —

Returns an array of the parsed AST code

getPreparedCode()

getPreparedCode() : string

Get PHPSandbox prepared code

Returns

string —

Returns a string of the prepared code

getPreparedAST()

getPreparedAST() : array

Get PHPSandbox prepared AST array

Returns

array —

Returns an array of the prepared AST code

getGeneratedCode()

getGeneratedCode() : string

Get PHPSandbox generated code

Returns

string —

Returns a string of the generated code

getCode()

getCode() : string

Get PHPSandbox generated code

Returns

string —

Returns a string of the generated code

_get_defined_functions()

_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.

Parameters

array $functions

Array result from get_defined_functions() is passed here

Returns

array —

Returns the redefined functions array

_get_defined_vars()

_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.

Parameters

array $variables

Array result from get_defined_vars() is passed here

Returns

array —

Returns the redefined variables array

_get_superglobal()

_get_superglobal(string  $name) : array

Get PHPSandbox redefined superglobal. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

Requested superglobal name (e.g. _GET, _POST, etc.)

Returns

array —

Returns the redefined superglobal

_get_magic_const()

_get_magic_const(string  $name) : array

Get PHPSandbox redefined magic constant. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

Requested magic constant name (e.g. FILE, LINE, etc.)

Returns

array —

Returns the redefined magic constant

_get_defined_constants()

_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.

Parameters

array $constants

Array result from get_defined_constants() is passed here

Returns

array —

Returns the redefined constants

_get_declared_classes()

_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.

Parameters

array $classes

Array result from get_declared_classes() is passed here

Returns

array —

Returns the redefined classes

_get_declared_interfaces()

_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.

Parameters

array $interfaces

Array result from get_declared_interfaces() is passed here

Returns

array —

Returns the redefined interfaces

_get_declared_traits()

_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.

Parameters

array $traits

Array result from get_declared_traits() is passed here

Returns

array —

Returns the redefined traits

_func_get_args()

_func_get_args(array  $arguments = array()) : array

Get PHPSandbox redefined function arguments array

Parameters

array $arguments

Array result from func_get_args() is passed here

Returns

array —

Returns the redefined arguments array

_func_get_arg()

_func_get_arg(array  $arguments = array(), integer  $index) : array

Get PHPSandbox redefined function argument

Parameters

array $arguments

Array result from func_get_args() is passed here

integer $index

Requested func_get_arg index is passed here

Returns

array —

Returns the redefined argument

_func_num_args()

_func_num_args(array  $arguments = array()) : integer

Get PHPSandbox redefined number of function arguments

Parameters

array $arguments

Array result from func_get_args() is passed here

Returns

integer —

Returns the redefined number of function arguments

_var_dump()

_var_dump() : array

Get PHPSandbox redefined var_dump

Returns

array —

Returns the redefined var_dump

_print_r()

_print_r() : array

Get PHPSandbox redefined print_r

Returns

array —

Returns the redefined print_r

_var_export()

_var_export() : array

Get PHPSandbox redefined var_export

Returns

array —

Returns the redefined var_export

_intval()

_intval(mixed  $value) : integer

Return integer value of SandboxedString or mixed value

Parameters

mixed $value

Value to return as integer

Returns

integer —

Returns the integer value

_floatval()

_floatval(mixed  $value) : float

Return float value of SandboxedString or mixed value

Parameters

mixed $value

Value to return as float

Returns

float —

Returns the float value

_boolval()

_boolval(mixed  $value) : boolean

Return boolean value of SandboxedString or mixed value

Parameters

mixed $value

Value to return as boolean

Returns

boolean —

Returns the boolean value

_arrayval()

_arrayval(mixed  $value) : array

Return array value of SandboxedString or mixed value

Parameters

mixed $value

Value to return as array

Returns

array —

Returns the array value

_objectval()

_objectval(mixed  $value) : object

Return object value of SandboxedString or mixed value

Parameters

mixed $value

Value to return as object

Returns

object —

Returns the object value

_is_string()

_is_string(mixed  $value) : boolean

Return is_string value of SandboxedString or mixed value

Parameters

mixed $value

Value to check if is_string

Returns

boolean —

Returns the is_string value

_is_object()

_is_object(mixed  $value) : boolean

Return is_object value of SandboxedString or mixed value

Parameters

mixed $value

Value to check if is_object

Returns

boolean —

Returns the is_object value

_is_scalar()

_is_scalar(mixed  $value) : boolean

Return is_scalar value of SandboxedString or mixed value

Parameters

mixed $value

Value to check if is_scalar

Returns

boolean —

Returns the is_scalar value

_is_callable()

_is_callable(mixed  $value) : boolean

Return is_callable value of SandboxedString or mixed value

Parameters

mixed $value

Value to check if is_callable

Returns

boolean —

Returns the is_callable value

_get_included_files()

_get_included_files() : array

Return get_included_files() and sandboxed included files

Returns

array —

Returns array of get_included_files() and sandboxed included files

_include()

_include(string  $file) : mixed

Sandbox included file

Parameters

string $file

Included file to sandbox

Returns

mixed —

Returns value passed from included file

_include_once()

_include_once(string  $file) : mixed

Sandbox included once file

Parameters

string $file

Included once file to sandbox

Returns

mixed —

Returns value passed from included once file

_require()

_require(string  $file) : mixed

Sandbox required file

Parameters

string $file

Required file to sandbox

Returns

mixed —

Returns value passed from required file

_require_once()

_require_once(string  $file) : mixed

Sandbox required once file

Parameters

string $file

Required once file to sandbox

Returns

mixed —

Returns value passed from required once file

call_func()

call_func() : mixed

Get PHPSandbox redefined function. This is an internal PHPSandbox function but requires public access to work.

Throws

\PHPSandbox\Error

Will throw exception if invalid function requested

Returns

mixed —

Returns the redefined function result

define()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'test', function(){ echo 'test'; });
** File not found : $sandbox->define('functions', **
=> ['test' => function(){ echo 'test'; }]]);
** File not found : $sandbox->define(['functions' **

undefine()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'test');
** File not found : $sandbox->undefine('functions', **
=> ['test']]);
** File not found : $sandbox->undefine(['functions' **

defineFunc()

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

Parameters

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

\PHPSandbox\Error

Throws exception if unnamed or uncallable $function is defined

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

function(){ echo 'test'; });
** File not found : $sandbox->defineFunc('test', **
=> function(){ echo 'test'; }]]);
** File not found : $sandbox->defineFunc(['test' **
=> [function(){ echo 'test'; }, true]]);
** File not found : $sandbox->defineFunc(['test' **

defineFuncs()

defineFuncs(array  $functions = array()) : $this

Define PHPSandbox functions by array

You can pass an associative array of functions to define

Parameters

array $functions

Associative array of $functions to define

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> function(){ echo 'test'; }]);
** File not found : $sandbox->defineFuncs(['test' **

hasDefinedFuncs()

hasDefinedFuncs() : integer

Query whether PHPSandbox instance has defined functions

Returns

integer —

Returns the number of functions this instance has defined

Examples

//returns number of defined functions, or zero if none defined
** File not found : $sandbox->hasDefinedFuncs(); **

isDefinedFunc()

isDefinedFunc(string  $name) : boolean

Check if PHPSandbox instance has $name function defined

Parameters

string $name

String of function $name to query

Returns

boolean —

Returns true if PHPSandbox instance has defined function, false otherwise

Examples

** File not found : $sandbox->isDefinedFunc('test'); **

undefineFunc()

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

Parameters

string|array $name

String of function name or array of function names to undefine

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->undefineFunc('test'); **
'test2']);
** File not found : $sandbox->undefineFunc(['test', **

undefineFuncs()

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

Parameters

array $functions

Array of function names to undefine. Passing an empty array or no argument will result in undefining all functions

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'test2']);
** File not found : $sandbox->undefineFuncs(['test', **
//WILL UNDEFINE ALL FUNCTIONS!
** File not found : $sandbox->undefineFuncs(); **

defineVar()

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

Parameters

string|array $name

String of variable $name or associative array to define

mixed $value

Value to define variable to

Throws

\PHPSandbox\Error

Throws exception if unnamed variable is defined

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

);
** File not found : $sandbox->defineVar('test', **
=> 1]);
** File not found : $sandbox->defineVar(['test' **

defineVars()

defineVars(array  $variables = array()) : $this

Define PHPSandbox variables by array

You can pass an associative array of variables to define

Parameters

array $variables

Associative array of $variables to define

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> 1]);
** File not found : $sandbox->defineVars(['test' **

hasDefinedVars()

hasDefinedVars() : integer

Query whether PHPSandbox instance has defined variables

Returns

integer —

Returns the number of variables this instance has defined

Examples

//returns number of defined variables, or zero if none defined
** File not found : $sandbox->hasDefinedVars(); **

isDefinedVar()

isDefinedVar(string  $name) : boolean

Check if PHPSandbox instance has $name variable defined

Parameters

string $name

String of variable $name to query

Returns

boolean —

Returns true if PHPSandbox instance has defined variable, false otherwise

Examples

** File not found : $sandbox->isDefinedVar('test'); **

undefineVar()

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

Parameters

string|array $name

String of variable name or an array of variable names to undefine

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->undefineVar('test'); **
'test2']);
** File not found : $sandbox->undefineVar(['test', **

undefineVars()

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

Parameters

array $variables

Array of variable names to undefine. Passing an empty array or no argument will result in undefining all variables

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'test2']);
** File not found : $sandbox->undefineVars(['test', **
//WILL UNDEFINE ALL VARIABLES!
** File not found : $sandbox->undefineVars(); **

defineSuperglobal()

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

Parameters

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

\PHPSandbox\Error

Throws exception if unnamed superglobal is defined

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

['page' => 1]);
** File not found : $sandbox->defineSuperglobal('_GET', **
=> ['page' => 1]]);
** File not found : $sandbox->defineSuperglobal(['_GET' **
'page', 1);
** File not found : $sandbox->defineSuperglobal('_GET', **

defineSuperglobals()

defineSuperglobals(array  $superglobals = array()) : $this

Define PHPSandbox superglobals by array

You can pass an associative array of superglobals to define

Parameters

array $superglobals

Associative array of $superglobals to define

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> ['page' => 1]]);
** File not found : $sandbox->defineSuperglobals(['_GET' **

hasDefinedSuperglobals()

hasDefinedSuperglobals(string|null  $name = null) : integer|boolean

Query whether PHPSandbox instance has defined superglobals, or if superglobal $name has defined keys

Parameters

string|null $name

String of superglobal $name to check for keys

Returns

integer|boolean —

Returns the number of superglobals or superglobal keys this instance has defined, or false if invalid superglobal name specified

Examples

//returns number of defined superglobals, or zero if none defined
** File not found : $sandbox->hasDefinedSuperglobals(); **
//returns number of defined superglobal _GET keys, or zero if none defined
** File not found : $sandbox->hasDefinedSuperglobals('_GET'); **

isDefinedSuperglobal()

isDefinedSuperglobal(string  $name, string|null  $key = null) : boolean

Check if PHPSandbox instance has $name superglobal defined, or if superglobal $name key is defined

Parameters

string $name

String of superglobal $name to query

string|null $key

String of key to to query in superglobal

Returns

boolean —

Returns true if PHPSandbox instance has defined superglobal, false otherwise

Examples

** File not found : $sandbox->isDefinedSuperglobal('_GET'); **
'page');
** File not found : $sandbox->isDefinedSuperglobal('_GET', **

undefineSuperglobal()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->undefineSuperglobal('_GET'); **
'page');
** File not found : $sandbox->undefineSuperglobal('_GET', **
'_POST']);
** File not found : $sandbox->undefineSuperglobal(['_GET', **

undefineSuperglobals()

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

Parameters

array $superglobals

Associative array of superglobal names and keys or array of superglobal names to undefine

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'_POST']);
** File not found : $sandbox->undefineSuperglobals(['_GET', **
=> 'page', '_POST' => 'page']);
** File not found : $sandbox->undefineSuperglobals(['_GET' **
//WILL UNDEFINE ALL SUPERGLOBALS!
** File not found : $sandbox->undefineSuperglobals(); **

defineConst()

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

Parameters

string|array $name

String of constant $name or associative array to define

mixed $value

Value to define constant to

Throws

\PHPSandbox\Error

Throws exception if unnamed constant is defined

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

);
** File not found : $sandbox->defineConst('TEST', **
=> 1]);
** File not found : $sandbox->defineConst(['TEST' **

defineConsts()

defineConsts(array  $constants = array()) : $this

Define PHPSandbox constants by array

You can pass an associative array of constants to define

Parameters

array $constants

Associative array of $constants to define

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> 1]);
** File not found : $sandbox->defineConsts(['test' **

hasDefinedConsts()

hasDefinedConsts() : integer

Query whether PHPSandbox instance has defined constants

Returns

integer —

Returns the number of constants this instance has defined

Examples

//returns number of defined constants, or zero if none defined
** File not found : $sandbox->hasDefinedConsts(); **

isDefinedConst()

isDefinedConst(string  $name) : boolean

Check if PHPSandbox instance has $name constant defined

Parameters

string $name

String of constant $name to query

Returns

boolean —

Returns true if PHPSandbox instance has defined constant, false otherwise

Examples

** File not found : $sandbox->isDefinedConst('test'); **

undefineConst()

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

Parameters

string|array $name

String of constant name or array of constant names to undefine

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->undefineConst('test'); **
'test2']);
** File not found : $sandbox->undefineConst(['test', **

undefineConsts()

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

Parameters

array $constants

Array of constant names to undefine. Passing an empty array or no argument will result in undefining all constants

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'test2']);
** File not found : $sandbox->undefineConsts(['test', **
//WILL UNDEFINE ALL CONSTANTS!
** File not found : $sandbox->undefineConsts(); **

defineMagicConst()

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

Parameters

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

\PHPSandbox\Error

Throws exception if unnamed magic constant is defined

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

);
** File not found : $sandbox->defineMagicConst('__LINE__', **
=> 1]);
** File not found : $sandbox->defineMagicConst(['__LINE__' **

defineMagicConsts()

defineMagicConsts(array  $magic_constants = array()) : $this

Define PHPSandbox magic constants by array

You can pass an associative array of magic constants to define

Parameters

array $magic_constants

Associative array of $magic_constants to define

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> 1]);
** File not found : $sandbox->defineMagicConsts(['__LINE__' **

hasDefinedMagicConsts()

hasDefinedMagicConsts() : integer

Query whether PHPSandbox instance has defined magic constants

Returns

integer —

Returns the number of magic constants this instance has defined

Examples

//returns number of defined magic constants, or zero if none defined
** File not found : $sandbox->hasDefinedMagicConsts(); **

isDefinedMagicConst()

isDefinedMagicConst(string  $name) : boolean

Check if PHPSandbox instance has $name magic constant defined

Parameters

string $name

String of magic constant $name to query

Returns

boolean —

Returns true if PHPSandbox instance has defined magic constant, false otherwise

Examples

** File not found : $sandbox->isDefinedMagicConst('__LINE__'); **

undefineMagicConst()

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

Parameters

string|array $name

String of magic constant name, or array of magic constant names to undefine

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->undefineMagicConst('__LINE__'); **
'__FILE__']);
** File not found : $sandbox->undefineMagicConst(['__LINE__', **

undefineMagicConsts()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'__FILE__']);
** File not found : $sandbox->undefineMagicConsts(['__LINE__', **
//WILL UNDEFINE ALL MAGIC CONSTANTS!
** File not found : $sandbox->undefineMagicConsts(); **

defineNamespace()

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

Parameters

string|array $name

String of namespace $name, or an array of namespace names to define

Throws

\PHPSandbox\Error

Throws exception if unnamed namespace is defined

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->defineNamespace('Foo'); **
'Bar']);
** File not found : $sandbox->defineNamespace(['Foo', **

defineNamespaces()

defineNamespaces(array  $namespaces = array()) : $this

Define PHPSandbox namespaces by array

You can pass an array of namespaces to define

Parameters

array $namespaces

Array of $namespaces to define

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Bar']);
** File not found : $sandbox->defineNamespaces(['Foo', **

hasDefinedNamespaces()

hasDefinedNamespaces() : integer

Query whether PHPSandbox instance has defined namespaces

Returns

integer —

Returns the number of namespaces this instance has defined

Examples

//returns number of defined namespaces, or zero if none defined
** File not found : $sandbox->hasDefinedNamespaces(); **

isDefinedNamespace()

isDefinedNamespace(string  $name) : boolean

Check if PHPSandbox instance has $name namespace defined

Parameters

string $name

String of namespace $name to query

Returns

boolean —

Returns true if PHPSandbox instance has defined namespace, false otherwise

Examples

** File not found : $sandbox->isDefinedNamespace('Foo'); **

getDefinedNamespace()

getDefinedNamespace(string  $name) : string

Get defined namespace of $name

Parameters

string $name

String of namespace $name to get

Throws

\PHPSandbox\Error

Throws an exception if an invalid namespace name is requested

Returns

string —

Returns string of defined namespace value

Examples

** File not found : $sandbox->getDefinedNamespace('Test'); **

undefineNamespace()

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

Parameters

string|array $name

String of namespace $name, or an array of namespace names to undefine

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->undefineNamespace('Foo'); **
'Bar']);
** File not found : $sandbox->undefineNamespace(['Foo', **

undefineNamespaces()

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

Parameters

array $namespaces

Array of namespace names to undefine. Passing an empty array or no argument will result in undefining all namespaces

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Bar']);
** File not found : $sandbox->undefineNamespaces(['Foo', **
//WILL UNDEFINE ALL NAMESPACES!
** File not found : $sandbox->undefineNamespaces(); **

defineAlias()

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

Parameters

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

\PHPSandbox\Error

Throws exception if unnamed namespace is used

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

//use Foo;
** File not found : $sandbox->defineAlias('Foo'); **
'Bar'); //use Foo as Bar;
** File not found : $sandbox->defineAlias('Foo', **
'Bar']); //use Foo; use Bar;
** File not found : $sandbox->defineAlias(['Foo', **
=> 'Bar']); //use Foo as Bar;
** File not found : $sandbox->defineAlias(['Foo' **

defineAliases()

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

Parameters

array $aliases

Array of namespaces to use, or an associative array of namespaces and their aliases to use

Throws

\PHPSandbox\Error

Throws exception if unnamed namespace is used

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Bar']); //use Foo; use Bar;
** File not found : $sandbox->defineAliases(['Foo', **
=> 'Bar']); //use Foo as Bar;
** File not found : $sandbox->defineAliases(['Foo' **

hasDefinedAliases()

hasDefinedAliases() : integer

Query whether PHPSandbox instance has defined aliases

Returns

integer —

Returns the number of aliases this instance has defined

Examples

//returns number of defined aliases, or zero if none defined
** File not found : $sandbox->hasDefinedAliases(); **

isDefinedAlias()

isDefinedAlias(string  $name) : boolean

Check if PHPSandbox instance has $name alias defined

Parameters

string $name

String of alias $name to query

Returns

boolean —

Returns true if PHPSandbox instance has defined aliases, false otherwise

Examples

** File not found : $sandbox->isDefinedAlias('Foo'); **

undefineAlias()

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

Parameters

string|array $name

String of alias name, or array of alias names to undefine

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->undefineAlias('Foo'); **
'Bar']);
** File not found : $sandbox->undefineAlias(['Foo', **

undefineAliases()

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

Parameters

array $aliases

Array of alias names to undefine. Passing an empty array or no argument will result in undefining all aliases

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Bar']);
** File not found : $sandbox->undefineAliases(['Foo', **
//WILL UNDEFINE ALL ALIASES!
** File not found : $sandbox->undefineAliases(); **

defineUse()

defineUse(string|array  $name, string|null  $alias = null) : $this

Define PHPSandbox use (or alias)

Parameters

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

\PHPSandbox\Error

Throws exception if unnamed namespace is used

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

//use Foo;
** File not found : $sandbox->defineUse('Foo'); **
'Bar'); //use Foo as Bar;
** File not found : $sandbox->defineUse('Foo', **
'Bar']); //use Foo; use Bar;
** File not found : $sandbox->defineUse(['Foo', **
=> 'Bar']); //use Foo as Bar;
** File not found : $sandbox->defineUse(['Foo' **

defineUses()

defineUses(array  $uses = array()) : $this

Define PHPSandbox uses (or aliases) by array

Parameters

array $uses

Array of namespaces to use, or an associative array of namespaces and their aliases to use

Throws

\PHPSandbox\Error

Throws exception if unnamed namespace is used

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Bar']); //use Foo; use Bar;
** File not found : $sandbox->defineUses(['Foo', **
=> 'Bar']); //use Foo as Bar;
** File not found : $sandbox->defineUses(['Foo' **

hasDefinedUses()

hasDefinedUses() : integer

Query whether PHPSandbox instance has defined uses (or aliases)

Returns

integer —

Returns the number of uses (or aliases) this instance has defined

Examples

//returns number of defined uses (or aliases) or zero if none defined
** File not found : $sandbox->hasDefinedUses(); **

isDefinedUse()

isDefinedUse(string  $name) : boolean

Check if PHPSandbox instance has $name uses (or alias) defined

Parameters

string $name

String of use (or alias) $name to query

Returns

boolean —

Returns true if PHPSandbox instance has defined uses (or aliases) and false otherwise

Examples

** File not found : $sandbox->isDefinedUse('Foo'); **

undefineUse()

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

Parameters

string|array $name

String of use (or alias) name, or array of use (or alias) names to undefine

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->undefineUse('Foo'); **
'Bar']);
** File not found : $sandbox->undefineUse(['Foo', **

undefineUses()

undefineUses(array  $uses = array()) : $this

Undefine PHPSandbox uses (or aliases) by array

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Bar']);
** File not found : $sandbox->undefineUses(['Foo', **
//WILL UNDEFINE ALL USES (OR ALIASES!)
** File not found : $sandbox->undefineUses(); **

defineClass()

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

Parameters

string|array $name

String of class $name or associative array to define

mixed $value

Value to define class to

Throws

\PHPSandbox\Error

Throws exception if unnamed class is defined

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Test2');
** File not found : $sandbox->defineClass('Test', **
=> 'Test2']);
** File not found : $sandbox->defineClass(['Test' **

defineClasses()

defineClasses(array  $classes = array()) : $this

Define PHPSandbox classes by array

You can pass an associative array of classes to define

Parameters

array $classes

Associative array of $classes to define

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> 'Test2']);
** File not found : $sandbox->defineClasses(['Test' **

hasDefinedClasses()

hasDefinedClasses() : integer

Query whether PHPSandbox instance has defined classes

Returns

integer —

Returns the number of classes this instance has defined

Examples

//returns number of defined classes, or zero if none defined
** File not found : $sandbox->hasDefinedClasses(); **

isDefinedClass()

isDefinedClass(string  $name) : boolean

Check if PHPSandbox instance has $name class defined

Parameters

string $name

String of class $name to query

Returns

boolean —

Returns true if PHPSandbox instance has defined class, false otherwise

Examples

** File not found : $sandbox->isDefinedClass('Test'); **

getDefinedClass()

getDefinedClass(string  $name) : string

Get defined class of $name

Parameters

string $name

String of class $name to get

Throws

\PHPSandbox\Error

Throws an exception if an invalid class name is requested

Returns

string —

Returns string of defined class value

Examples

** File not found : $sandbox->getDefinedClass('Test'); **

undefineClass()

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

Parameters

string|array $name

String of class name or an array of class names to undefine

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->undefineClass('Test'); **
'Test2']);
** File not found : $sandbox->undefineClass(['Test', **

undefineClasses()

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

Parameters

array $classes

Array of class names to undefine. Passing an empty array or no argument will result in undefining all classes

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Test2']);
** File not found : $sandbox->undefineClasses(['Test', **
//WILL UNDEFINE ALL CLASSES!
** File not found : $sandbox->undefineClasses(); **

defineInterface()

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

Parameters

string|array $name

String of interface $name or associative array to define

mixed $value

Value to define interface to

Throws

\PHPSandbox\Error

Throws exception if unnamed interface is defined

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Test2');
** File not found : $sandbox->defineInterface('Test', **
=> 'Test2']);
** File not found : $sandbox->defineInterface(['Test' **

defineInterfaces()

defineInterfaces(array  $interfaces = array()) : $this

Define PHPSandbox interfaces by array

You can pass an associative array of interfaces to define

Parameters

array $interfaces

Associative array of $interfaces to define

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> 'Test2']);
** File not found : $sandbox->defineInterfaces(['Test' **

hasDefinedInterfaces()

hasDefinedInterfaces() : integer

Query whether PHPSandbox instance has defined interfaces

Returns

integer —

Returns the number of interfaces this instance has defined

Examples

//returns number of defined interfaces, or zero if none defined
** File not found : $sandbox->hasDefinedInterfaces(); **

isDefinedInterface()

isDefinedInterface(string  $name) : boolean

Check if PHPSandbox instance has $name interface defined

Parameters

string $name

String of interface $name to query

Returns

boolean —

Returns true if PHPSandbox instance has defined interface, false otherwise

Examples

** File not found : $sandbox->isDefinedInterface('Test'); **

getDefinedInterface()

getDefinedInterface(string  $name) : string

Get defined interface of $name

Parameters

string $name

String of interface $name to get

Throws

\PHPSandbox\Error

Throws an exception if an invalid interface name is requested

Returns

string —

Returns string of defined interface value

Examples

** File not found : $sandbox->getDefinedInterface('Test'); **

undefineInterface()

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

Parameters

string|array $name

String of interface name or an array of interface names to undefine

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->undefineInterface('Test'); **
'Test2']);
** File not found : $sandbox->undefineInterface(['Test', **

undefineInterfaces()

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

Parameters

array $interfaces

Array of interface names to undefine. Passing an empty array or no argument will result in undefining all interfaces

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Test2']);
** File not found : $sandbox->undefineInterfaces(['Test', **
//WILL UNDEFINE ALL INTERFACES!
** File not found : $sandbox->undefineInterfaces(); **

defineTrait()

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

Parameters

string|array $name

String of trait $name or associative array to define

mixed $value

Value to define trait to

Throws

\PHPSandbox\Error

Throws exception if unnamed trait is defined

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Test2');
** File not found : $sandbox->defineTrait('Test', **
=> 'Test2']);
** File not found : $sandbox->defineTrait(['Test' **

defineTraits()

defineTraits(array  $traits = array()) : $this

Define PHPSandbox traits by array

You can pass an associative array of traits to define

Parameters

array $traits

Associative array of $traits to define

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> 'Test2']);
** File not found : $sandbox->defineTraits(['Test' **

hasDefinedTraits()

hasDefinedTraits() : integer

Query whether PHPSandbox instance has defined traits

Returns

integer —

Returns the number of traits this instance has defined

Examples

//returns number of defined traits, or zero if none defined
** File not found : $sandbox->hasDefinedTraits(); **

isDefinedTrait()

isDefinedTrait(string  $name) : boolean

Check if PHPSandbox instance has $name trait defined

Parameters

string $name

String of trait $name to query

Returns

boolean —

Returns true if PHPSandbox instance has defined trait, false otherwise

Examples

** File not found : $sandbox->isDefinedTrait('Test'); **

getDefinedTrait()

getDefinedTrait(string  $name) : string

Get defined trait of $name

Parameters

string $name

String of trait $name to get

Throws

\PHPSandbox\Error

Throws an exception if an invalid trait name is requested

Returns

string —

Returns string of defined trait value

Examples

** File not found : $sandbox->getDefinedTrait('Test'); **

undefineTrait()

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

Parameters

string|array $name

String of trait name or an array of trait names to undefine

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->undefineTrait('Test'); **
'Test2']);
** File not found : $sandbox->undefineTrait(['Test', **

undefineTraits()

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

Parameters

array $traits

Array of trait names to undefine. Passing an empty array or no argument will result in undefining all traits

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

'Test2']);
** File not found : $sandbox->undefineTraits(['Test', **
//WILL UNDEFINE ALL TRAITS!
** File not found : $sandbox->undefineTraits(); **

whitelist()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> ['test']]);
** File not found : $sandbox->whitelist(['functions' **
['test']);
** File not found : $sandbox->whitelist('functions', **
'test');
** File not found : $sandbox->whitelist('functions', **

blacklist()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> ['test']]);
** File not found : $sandbox->blacklist(['functions' **
['test']);
** File not found : $sandbox->blacklist('functions', **
'test');
** File not found : $sandbox->blacklist('functions', **

dewhitelist()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> ['test']]);
** File not found : $sandbox->dewhitelist(['functions' **
['test']);
** File not found : $sandbox->dewhitelist('functions', **
'test');
** File not found : $sandbox->dewhitelist('functions', **

deblacklist()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

=> ['test']]);
** File not found : $sandbox->deblacklist(['functions' **
['test']);
** File not found : $sandbox->deblacklist('functions', **
'test');
** File not found : $sandbox->deblacklist('functions', **

hasWhitelist()

hasWhitelist(string  $type) : integer

Query whether PHPSandbox instance has whitelist type

Parameters

string $type

The whitelist type to query

Returns

integer —

Returns the number of whitelists this instance has defined

Examples

//returns number of whitelisted functions, or zero if none whitelisted
** File not found : $sandbox->hasWhitelist('functions'); **

hasBlacklist()

hasBlacklist(string  $type) : integer

Query whether PHPSandbox instance has blacklist type.

Parameters

string $type

The blacklist type to query

Returns

integer —

Returns the number of blacklists this instance has defined

Examples

//returns number of blacklisted functions, or zero if none blacklisted
** File not found : $sandbox->hasBlacklist('functions'); **

isWhitelisted()

isWhitelisted(string  $type, string  $name) : boolean

Check if PHPSandbox instance has whitelist type and name set

Parameters

string $type

String of whitelist $type to query

string $name

String of whitelist $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted $type and $name, false otherwise

Examples

'test');
** File not found : $sandbox->isWhitelisted('functions', **

isBlacklisted()

isBlacklisted(string  $type, string  $name) : boolean

Check if PHPSandbox instance has blacklist type and name set

Parameters

string $type

String of blacklist $type to query

string $name

String of blacklist $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted $type and $name, false otherwise

Examples

'test');
** File not found : $sandbox->isBlacklisted('functions', **

hasWhitelistedFuncs()

hasWhitelistedFuncs() : integer

Query whether PHPSandbox instance has whitelisted functions.

Returns

integer —

Returns the number of whitelisted functions this instance has defined

Examples

//returns number of whitelisted functions, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedFuncs(); **

hasBlacklistedFuncs()

hasBlacklistedFuncs() : integer

Query whether PHPSandbox instance has blacklisted functions.

Returns

integer —

Returns the number of blacklisted functions this instance has defined

Examples

//returns number of blacklisted functions, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedFuncs(); **

isWhitelistedFunc()

isWhitelistedFunc(string  $name) : boolean

Check if PHPSandbox instance has whitelisted function name set

Parameters

string $name

String of function $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted function $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedFunc('test'); **

isBlacklistedFunc()

isBlacklistedFunc(string  $name) : boolean

Check if PHPSandbox instance has blacklisted function name set

Parameters

string $name

String of function $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted function $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedFunc('test'); **

hasWhitelistedVars()

hasWhitelistedVars() : integer

Query whether PHPSandbox instance has whitelisted variables.

Returns

integer —

Returns the number of whitelisted variables this instance has defined

Examples

//returns number of whitelisted variables, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedVars(); **

hasBlacklistedVars()

hasBlacklistedVars() : integer

Query whether PHPSandbox instance has blacklisted variables.

Returns

integer —

Returns the number of blacklisted variables this instance has defined

Examples

//returns number of blacklisted variables, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedVars(); **

isWhitelistedVar()

isWhitelistedVar(string  $name) : boolean

Check if PHPSandbox instance has whitelisted variable name set

Parameters

string $name

String of variable $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted variable $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedVar('test'); **

isBlacklistedVar()

isBlacklistedVar(string  $name) : boolean

Check if PHPSandbox instance has blacklisted variable name set

Parameters

string $name

String of variable $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted variable $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedVar('test'); **

hasWhitelistedGlobals()

hasWhitelistedGlobals() : integer

Query whether PHPSandbox instance has whitelisted globals.

Returns

integer —

Returns the number of whitelisted globals this instance has defined

Examples

//returns number of whitelisted globals, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedGlobals(); **

hasBlacklistedGlobals()

hasBlacklistedGlobals() : integer

Query whether PHPSandbox instance has blacklisted globals.

Returns

integer —

Returns the number of blacklisted globals this instance has defined

Examples

//returns number of blacklisted globals, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedGlobals(); **

isWhitelistedGlobal()

isWhitelistedGlobal(string  $name) : boolean

Check if PHPSandbox instance has whitelisted global name set

Parameters

string $name

String of global $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted global $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedGlobal('test'); **

isBlacklistedGlobal()

isBlacklistedGlobal(string  $name) : boolean

Check if PHPSandbox instance has blacklisted global name set

Parameters

string $name

String of global $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted global $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedGlobal('test'); **

hasWhitelistedSuperglobals()

hasWhitelistedSuperglobals(string  $name = null) : integer

Query whether PHPSandbox instance has whitelisted superglobals, or superglobal keys

Parameters

string $name

The whitelist superglobal key to query

Returns

integer —

Returns the number of whitelisted superglobals or superglobal keys this instance has defined

Examples

//returns number of whitelisted superglobals, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedSuperglobals(); **
//returns number of whitelisted superglobal keys, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedSuperglobals('_GET'); **

hasBlacklistedSuperglobals()

hasBlacklistedSuperglobals(string  $name = null) : integer

Query whether PHPSandbox instance has blacklisted superglobals, or superglobal keys

Parameters

string $name

The blacklist superglobal key to query

Returns

integer —

Returns the number of blacklisted superglobals or superglobal keys this instance has defined

Examples

//returns number of blacklisted superglobals, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedSuperglobals(); **
//returns number of blacklisted superglobal keys, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedSuperglobals('_GET'); **

isWhitelistedSuperglobal()

isWhitelistedSuperglobal(string  $name, string  $key = null) : boolean

Check if PHPSandbox instance has whitelisted superglobal or superglobal key set

Parameters

string $name

String of whitelisted superglobal $name to query

string $key

String of whitelisted superglobal $key to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted superglobal key or superglobal, false otherwise

Examples

** File not found : $sandbox->isWhitelistedSuperglobal('_GET'); **
'page');
** File not found : $sandbox->isWhitelistedSuperglobal('_GET', **

isBlacklistedSuperglobal()

isBlacklistedSuperglobal(string  $name, string  $key = null) : boolean

Check if PHPSandbox instance has blacklisted superglobal or superglobal key set

Parameters

string $name

String of blacklisted superglobal $name to query

string $key

String of blacklisted superglobal $key to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted superglobal key or superglobal, false otherwise

Examples

** File not found : $sandbox->isBlacklistedSuperglobal('_GET'); **
'page');
** File not found : $sandbox->isBlacklistedSuperglobal('_GET', **

hasWhitelistedConsts()

hasWhitelistedConsts() : integer

Query whether PHPSandbox instance has whitelisted constants.

Returns

integer —

Returns the number of whitelisted constants this instance has defined

Examples

//returns number of whitelisted constants, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedConsts(); **

hasBlacklistedConsts()

hasBlacklistedConsts() : integer

Query whether PHPSandbox instance has blacklisted constants.

Returns

integer —

Returns the number of blacklisted constants this instance has defined

Examples

//returns number of blacklisted constants, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedConsts(); **

isWhitelistedConst()

isWhitelistedConst(string  $name) : boolean

Check if PHPSandbox instance has whitelisted constant name set

Parameters

string $name

String of constant $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted constant $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedConst('TEST'); **

isBlacklistedConst()

isBlacklistedConst(string  $name) : boolean

Check if PHPSandbox instance has blacklisted constant name set

Parameters

string $name

String of constant $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted constant $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedConst('TEST'); **

hasWhitelistedMagicConsts()

hasWhitelistedMagicConsts() : integer

Query whether PHPSandbox instance has whitelisted magic constants.

Returns

integer —

Returns the number of whitelisted magic constants this instance has defined

Examples

//returns number of whitelisted magic constants, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedMagicConsts(); **

hasBlacklistedMagicConsts()

hasBlacklistedMagicConsts() : integer

Query whether PHPSandbox instance has blacklisted magic constants.

Returns

integer —

Returns the number of blacklisted magic constants this instance has defined

Examples

//returns number of blacklisted magic constants, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedMagicConsts(); **

isWhitelistedMagicConst()

isWhitelistedMagicConst(string  $name) : boolean

Check if PHPSandbox instance has whitelisted magic constant name set

Parameters

string $name

String of magic constant $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted magic constant $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedMagicConst('__LINE__'); **

isBlacklistedMagicConst()

isBlacklistedMagicConst(string  $name) : boolean

Check if PHPSandbox instance has blacklisted magic constant name set

Parameters

string $name

String of magic constant $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted magic constant $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedMagicConst('__LINE__'); **

hasWhitelistedNamespaces()

hasWhitelistedNamespaces() : integer

Query whether PHPSandbox instance has whitelisted namespaces.

Returns

integer —

Returns the number of whitelisted namespaces this instance has defined

Examples

//returns number of whitelisted namespaces, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedNamespaces(); **

hasBlacklistedNamespaces()

hasBlacklistedNamespaces() : integer

Query whether PHPSandbox instance has blacklisted namespaces.

Returns

integer —

Returns the number of blacklisted namespaces this instance has defined

Examples

//returns number of blacklisted namespaces, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedNamespaces(); **

isWhitelistedNamespace()

isWhitelistedNamespace(string  $name) : boolean

Check if PHPSandbox instance has whitelisted namespace name set

Parameters

string $name

String of namespace $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted namespace $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedNamespace('Test'); **

isBlacklistedNamespace()

isBlacklistedNamespace(string  $name) : boolean

Check if PHPSandbox instance has blacklisted namespace name set

Parameters

string $name

String of namespace $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted namespace $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedNamespace('Test'); **

hasWhitelistedAliases()

hasWhitelistedAliases() : integer

Query whether PHPSandbox instance has whitelisted aliases.

Returns

integer —

Returns the number of whitelisted aliases this instance has defined

Examples

//returns number of whitelisted aliases, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedAliases(); **

hasBlacklistedAliases()

hasBlacklistedAliases() : integer

Query whether PHPSandbox instance has blacklisted aliases.

Returns

integer —

Returns the number of blacklisted aliases this instance has defined

Examples

//returns number of blacklisted aliases, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedAliases(); **

isWhitelistedAlias()

isWhitelistedAlias(string  $name) : boolean

Check if PHPSandbox instance has whitelisted alias name set

Parameters

string $name

String of alias $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted alias $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedAlias('Test'); **

isBlacklistedAlias()

isBlacklistedAlias(string  $name) : boolean

Check if PHPSandbox instance has blacklisted alias name set

Parameters

string $name

String of alias $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted alias $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedAlias('Test'); **

hasWhitelistedUses()

hasWhitelistedUses() : integer

Query whether PHPSandbox instance has whitelisted uses (or aliases.)

Returns

integer —

Returns the number of whitelisted uses (or aliases) this instance has defined

Examples

//returns number of whitelisted uses (or aliases) or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedUses(); **

hasBlacklistedUses()

hasBlacklistedUses() : integer

Query whether PHPSandbox instance has blacklisted uses (or aliases.)

Returns

integer —

Returns the number of blacklisted uses (or aliases) this instance has defined

Examples

//returns number of blacklisted uses (or aliases) or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedUses(); **

isWhitelistedUse()

isWhitelistedUse(string  $name) : boolean

Check if PHPSandbox instance has whitelisted use (or alias) name set

Parameters

string $name

String of use (or alias) $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted use (or alias) $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedUse('Test'); **

isBlacklistedUse()

isBlacklistedUse(string  $name) : boolean

Check if PHPSandbox instance has blacklisted use (or alias) name set

Parameters

string $name

String of use (or alias) $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted use (or alias) $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedUse('Test'); **

hasWhitelistedClasses()

hasWhitelistedClasses() : integer

Query whether PHPSandbox instance has whitelisted classes.

Returns

integer —

Returns the number of whitelisted classes this instance has defined

Examples

//returns number of whitelisted classes, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistClasses(); **

hasBlacklistedClasses()

hasBlacklistedClasses() : integer

Query whether PHPSandbox instance has blacklisted classes.

Returns

integer —

Returns the number of blacklisted classes this instance has defined

Examples

//returns number of blacklisted classes, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedClasses(); **

isWhitelistedClass()

isWhitelistedClass(string  $name) : boolean

Check if PHPSandbox instance has whitelisted class name set

Parameters

string $name

String of class $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted class $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedClass('Test'); **

isBlacklistedClass()

isBlacklistedClass(string  $name) : boolean

Check if PHPSandbox instance has blacklisted class name set

Parameters

string $name

String of class $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted class $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedClass('Test'); **

hasWhitelistedInterfaces()

hasWhitelistedInterfaces() : integer

Query whether PHPSandbox instance has whitelisted interfaces.

Returns

integer —

Returns the number of whitelisted interfaces this instance has defined

Examples

//returns number of whitelisted interfaces, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedInterfaces(); **

hasBlacklistedInterfaces()

hasBlacklistedInterfaces() : integer

Query whether PHPSandbox instance has blacklisted interfaces.

Returns

integer —

Returns the number of blacklisted interfaces this instance has defined

Examples

//returns number of blacklisted interfaces, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedInterfaces(); **

isWhitelistedInterface()

isWhitelistedInterface(string  $name) : boolean

Check if PHPSandbox instance has whitelisted interface name set

Parameters

string $name

String of interface $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted interface $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedInterface('Test'); **

isBlacklistedInterface()

isBlacklistedInterface(string  $name) : boolean

Check if PHPSandbox instance has blacklisted interface name set

Parameters

string $name

String of interface $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted interface $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedInterface('Test'); **

hasWhitelistedTraits()

hasWhitelistedTraits() : integer

Query whether PHPSandbox instance has whitelisted traits.

Returns

integer —

Returns the number of whitelisted traits this instance has defined

Examples

//returns number of whitelisted traits, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedTraits(); **

hasBlacklistedTraits()

hasBlacklistedTraits() : integer

Query whether PHPSandbox instance has blacklisted traits.

Returns

integer —

Returns the number of blacklisted traits this instance has defined

Examples

//returns number of blacklisted traits, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedTraits(); **

isWhitelistedTrait()

isWhitelistedTrait(string  $name) : boolean

Check if PHPSandbox instance has whitelisted trait name set

Parameters

string $name

String of trait $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted trait $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedTrait('Test'); **

isBlacklistedTrait()

isBlacklistedTrait(string  $name) : boolean

Check if PHPSandbox instance has blacklisted trait name set

Parameters

string $name

String of trait $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted trait $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedTrait('Test'); **

hasWhitelistKeywords()

hasWhitelistKeywords() : integer

Query whether PHPSandbox instance has whitelisted keywords.

Returns

integer —

Returns the number of whitelisted keywords this instance has defined

Examples

//returns number of whitelisted keywords, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistKeywords(); **

hasBlacklistedKeywords()

hasBlacklistedKeywords() : integer

Query whether PHPSandbox instance has blacklisted keywords.

Returns

integer —

Returns the number of blacklisted keywords this instance has defined

Examples

//returns number of blacklisted keywords, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedKeywords(); **

isWhitelistedKeyword()

isWhitelistedKeyword(string  $name) : boolean

Check if PHPSandbox instance has whitelisted keyword name set

Parameters

string $name

String of keyword $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted keyword $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedKeyword('echo'); **

isBlacklistedKeyword()

isBlacklistedKeyword(string  $name) : boolean

Check if PHPSandbox instance has blacklisted keyword name set

Parameters

string $name

String of keyword $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted keyword $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedKeyword('echo'); **

hasWhitelistedOperators()

hasWhitelistedOperators() : integer

Query whether PHPSandbox instance has whitelisted operators.

Returns

integer —

Returns the number of whitelisted operators this instance has defined

Examples

//returns number of whitelisted operators, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistOperators(); **

hasBlacklistedOperators()

hasBlacklistedOperators() : integer

Query whether PHPSandbox instance has blacklisted operators.

Returns

integer —

Returns the number of blacklisted operators this instance has defined

Examples

//returns number of blacklisted operators, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistOperators(); **

isWhitelistedOperator()

isWhitelistedOperator(string  $name) : boolean

Check if PHPSandbox instance has whitelisted operator name set

Parameters

string $name

String of operator $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted operator $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedOperator('+'); **

isBlacklistedOperator()

isBlacklistedOperator(string  $name) : boolean

Check if PHPSandbox instance has blacklisted operator name set

Parameters

string $name

String of operator $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted operator $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedOperator('+'); **

hasWhitelistedPrimitives()

hasWhitelistedPrimitives() : integer

Query whether PHPSandbox instance has whitelisted primitives.

Returns

integer —

Returns the number of whitelisted primitives this instance has defined

Examples

//returns number of whitelisted primitives, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedPrimitives(); **

hasBlacklistedPrimitives()

hasBlacklistedPrimitives() : integer

Query whether PHPSandbox instance has blacklisted primitives.

Returns

integer —

Returns the number of blacklisted primitives this instance has defined

Examples

//returns number of blacklisted primitives, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedPrimitives(); **

isWhitelistedPrimitive()

isWhitelistedPrimitive(string  $name) : boolean

Check if PHPSandbox instance has whitelisted primitive name set

Parameters

string $name

String of primitive $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted primitive $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedPrimitive('array'); **

isBlacklistedPrimitive()

isBlacklistedPrimitive(string  $name) : boolean

Check if PHPSandbox instance has blacklisted primitive name set

Parameters

string $name

String of primitive $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted primitive $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedPrimitive('array'); **

hasWhitelistedTypes()

hasWhitelistedTypes() : integer

Query whether PHPSandbox instance has whitelisted types.

Returns

integer —

Returns the number of whitelisted types this instance has defined

Examples

//returns number of whitelisted types, or zero if none whitelisted
** File not found : $sandbox->hasWhitelistedTypes(); **

hasBlacklistedTypes()

hasBlacklistedTypes() : integer

Query whether PHPSandbox instance has blacklisted types.

Returns

integer —

Returns the number of blacklisted types this instance has defined

Examples

//returns number of blacklisted types, or zero if none blacklisted
** File not found : $sandbox->hasBlacklistedTypes(); **

isWhitelistedType()

isWhitelistedType(string  $name) : boolean

Check if PHPSandbox instance has whitelisted type name set

Parameters

string $name

String of type $name to query

Returns

boolean —

Returns true if PHPSandbox instance has whitelisted type $name, false otherwise

Examples

** File not found : $sandbox->isWhitelistedType('array'); **

isBlacklistedType()

isBlacklistedType(string  $name) : boolean

Check if PHPSandbox instance has blacklisted type name set

Parameters

string $name

String of type $name to query

Returns

boolean —

Returns true if PHPSandbox instance has blacklisted type $name, false otherwise

Examples

** File not found : $sandbox->isBlacklistedType('array'); **

whitelistFunc()

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

Parameters

string|array $name

String of function name, or array of function names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistFunc('var_dump'); **
'print_r');
** File not found : $sandbox->whitelistFunc('var_dump', **
'print_r']);
** File not found : $sandbox->whitelistFunc(['var_dump', **

blacklistFunc()

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

Parameters

string|array $name

String of function name, or array of function names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistFunc('var_dump'); **
'print_r']);
** File not found : $sandbox->blacklistFunc(['var_dump', **

dewhitelistFunc()

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

Parameters

string|array $name

String of function name or array of function names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistFunc('var_dump'); **
'print_r']);
** File not found : $sandbox->dewhitelistFunc(['var_dump', **

deblacklistFunc()

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

Parameters

string|array $name

String of function name or array of function names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistFunc('var_dump'); **
'print_r']);
** File not found : $sandbox->deblacklistFunc(['var_dump', **

whitelistVar()

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

Parameters

string|array $name

String of variable name or array of variable names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistVar('a'); **
'b']);
** File not found : $sandbox->whitelistVar(['a', **

blacklistVar()

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

Parameters

string|array $name

String of variable name or array of variable names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistVar('a'); **
'b']);
** File not found : $sandbox->blacklistVar(['a', **

dewhitelistVar()

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

Parameters

string|array $name

String of variable name or array of variable names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistVar('a'); **
'b']);
** File not found : $sandbox->dewhitelistVar(['a', **

deblacklistVar()

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

Parameters

string|array $name

String of variable name or array of variable names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistVar('a'); **
'b']);
** File not found : $sandbox->deblacklistVar(['a', **

whitelistGlobal()

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

Parameters

string|array $name

String of global name or array of global names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistGlobal('a'); **
'b']);
** File not found : $sandbox->whitelistGlobal(['a', **

blacklistGlobal()

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

Parameters

string|array $name

String of global name or array of global names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistGlobal('a'); **
'b']);
** File not found : $sandbox->blacklistGlobal(['a', **

dewhitelistGlobal()

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

Parameters

string|array $name

String of global name or array of global names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistGlobal('a'); **
'b']);
** File not found : $sandbox->dewhitelistGlobal(['a', **

deblacklistGlobal()

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

Parameters

string|array $name

String of global name or array of global names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistGlobal('a'); **
'b']);
** File not found : $sandbox->deblacklistGlobal(['a', **

whitelistSuperglobal()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistSuperglobal('_GET'); **
'page');
** File not found : $sandbox->whitelistSuperglobal('_GET', **
'_POST']);
** File not found : $sandbox->whitelistSuperglobal(['_GET', **
=> 'page']);
** File not found : $sandbox->whitelistSuperglobal(['_GET' **

blacklistSuperglobal()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistSuperglobal('_GET'); **
'page');
** File not found : $sandbox->blacklistSuperglobal('_GET', **
'_POST']);
** File not found : $sandbox->blacklistSuperglobal(['_GET', **
=> 'page']);
** File not found : $sandbox->blacklistSuperglobal(['_GET' **

dewhitelistSuperglobal()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistSuperglobal('_GET'); **
'page');
** File not found : $sandbox->dewhitelistSuperglobal('_GET', **
'_POST']);
** File not found : $sandbox->dewhitelistSuperglobal(['_GET', **
=> 'page']);
** File not found : $sandbox->dewhitelistSuperglobal(['_GET' **

deblacklistSuperglobal()

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

Parameters

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

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistSuperglobal('_GET'); **
'page');
** File not found : $sandbox->deblacklistSuperglobal('_GET', **
'_POST']);
** File not found : $sandbox->deblacklistSuperglobal(['_GET', **
=> 'page']);
** File not found : $sandbox->deblacklistSuperglobal(['_GET' **

whitelistConst()

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

Parameters

string|array $name

String of constant name or array of constant names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistConst('FOO'); **
'BAR']);
** File not found : $sandbox->whitelistConst(['FOO', **

blacklistConst()

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

Parameters

string|array $name

String of constant name or array of constant names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistConst('FOO'); **
'BAR']);
** File not found : $sandbox->blacklistConst(['FOO', **

dewhitelistConst()

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

Parameters

string|array $name

String of constant name or array of constant names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistConst('FOO'); **
'BAR']);
** File not found : $sandbox->dewhitelistConst(['FOO', **

deblacklistConst()

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

Parameters

string|array $name

String of constant name or array of constant names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistConst('FOO'); **
'BAR']);
** File not found : $sandbox->deblacklistConst(['FOO', **

whitelistMagicConst()

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

Parameters

string|array $name

String of magic constant name or array of magic constant names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistMagicConst('__LINE__'); **
'__FILE__']);
** File not found : $sandbox->whitelistMagicConst(['__LINE__', **

blacklistMagicConst()

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

Parameters

string|array $name

String of magic constant name or array of magic constant names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistMagicConst('__LINE__'); **
'__FILE__']);
** File not found : $sandbox->blacklistMagicConst(['__LINE__', **

dewhitelistMagicConst()

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

Parameters

string|array $name

String of magic constant name or array of magic constant names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistMagicConst('__LINE__'); **
'__FILE__']);
** File not found : $sandbox->dewhitelistMagicConst(['__LINE__', **

deblacklistMagicConst()

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

Parameters

string|array $name

String of magic constant name or array of magic constant names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistMagicConst('__LINE__'); **
'__FILE__']);
** File not found : $sandbox->deblacklistMagicConst(['__LINE__', **

whitelistNamespace()

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

Parameters

string|array $name

String of namespace name or array of namespace names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistNamespace('Foo'); **
'Bar']);
** File not found : $sandbox->whitelistNamespace(['Foo', **

blacklistNamespace()

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

Parameters

string|array $name

String of namespace name or array of namespace names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistNamespace('Foo'); **
'Bar']);
** File not found : $sandbox->blacklistNamespace(['Foo', **

dewhitelistNamespace()

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

Parameters

string|array $name

String of namespace name or array of namespace names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistNamespace('Foo'); **
'Bar']);
** File not found : $sandbox->dewhitelistNamespace(['Foo', **

deblacklistNamespace()

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

Parameters

string|array $name

String of namespace name or array of namespace names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistNamespace('Foo'); **
'Bar']);
** File not found : $sandbox->deblacklistNamespace(['Foo', **

whitelistAlias()

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

Parameters

string|array $name

String of alias names or array of alias names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistAlias('Foo'); **
'Bar']);
** File not found : $sandbox->whitelistAlias(['Foo', **

blacklistAlias()

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

Parameters

string|array $name

String of alias name or array of alias names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistAlias('Foo'); **
'Bar']);
** File not found : $sandbox->blacklistAlias(['Foo', **

dewhitelistAlias()

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

Parameters

string|array $name

String of alias name or array of alias names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistAlias('Foo'); **
'Bar']);
** File not found : $sandbox->dewhitelistAlias(['Foo', **

deblacklistAlias()

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

Parameters

string|array $name

String of alias name or array of alias names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistAlias('Foo'); **
'Bar']);
** File not found : $sandbox->deblacklistAlias(['Foo', **

whitelistUse()

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

Parameters

string|array $name

String of use (or alias) name or array of use (or alias) names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistUse('Foo'); **
'Bar']);
** File not found : $sandbox->whitelistUse(['Foo', **

blacklistUse()

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

Parameters

string|array $name

String of use (or alias) name or array of use (or alias) names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistUse('Foo'); **
'Bar']);
** File not found : $sandbox->blacklistUse(['Foo', **

dewhitelistUse()

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

Parameters

string|array $name

String of use (or alias) name or array of use (or alias) names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistUse('Foo'); **
'Bar']);
** File not found : $sandbox->dewhitelistUse(['Foo', **

deblacklistUse()

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

Parameters

string|array $name

String of use (or alias) name or array of use (or alias) names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistUse('Foo'); **
'Bar']);
** File not found : $sandbox->deblacklistUse(['Foo', **

whitelistClass()

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

Parameters

string|array $name

String of class name or array of class names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistClass('Foo'); **
'Bar']);
** File not found : $sandbox->whitelistClass(['Foo', **

blacklistClass()

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

Parameters

string|array $name

String of class name or array of class names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistClass('Foo'); **
'Bar']);
** File not found : $sandbox->blacklistClass(['Foo', **

dewhitelistClass()

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

Parameters

string|array $name

String of class name or array of class names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistClass('Foo'); **
'Bar']);
** File not found : $sandbox->dewhitelistClass(['Foo', **

deblacklistClass()

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

Parameters

string|array $name

String of class name or array of class names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistClass('Foo'); **
'Bar']);
** File not found : $sandbox->deblacklistClass(['Foo', **

whitelistInterface()

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

Parameters

string|array $name

String of interface name or array of interface names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistInterface('Foo'); **
'Bar']);
** File not found : $sandbox->whitelistInterface(['Foo', **

blacklistInterface()

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

Parameters

string|array $name

String of interface name or array of interface names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistInterface('Foo'); **
'Bar']);
** File not found : $sandbox->blacklistInterface(['Foo', **

dewhitelistInterface()

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

Parameters

string|array $name

String of interface name or array of interface names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistInterface('Foo'); **
'Bar']);
** File not found : $sandbox->dewhitelistInterface(['Foo', **

deblacklistInterface()

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

Parameters

string|array $name

String of interface name or array of interface names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistInterface('Foo'); **
'Bar']);
** File not found : $sandbox->deblacklistInterface(['Foo', **

whitelistTrait()

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

Parameters

string|array $name

String of trait name or array of trait names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistTrait('Foo'); **
'Bar']);
** File not found : $sandbox->whitelistTrait(['Foo', **

blacklistTrait()

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

Parameters

string|array $name

String of trait name or array of trait names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistTrait('Foo'); **
'Bar']);
** File not found : $sandbox->blacklistTrait(['Foo', **

dewhitelistTrait()

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

Parameters

string|array $name

String of trait name or array of trait names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistTrait('Foo'); **
'Bar']);
** File not found : $sandbox->dewhitelistTrait(['Foo', **

deblacklistTrait()

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

Parameters

string|array $name

String of trait name or array of trait names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistTrait('Foo'); **
'Bar']);
** File not found : $sandbox->deblacklistTrait(['Foo', **

whitelistKeyword()

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

Parameters

string|array $name

String of keyword name or array of keyword names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistKeyword('echo'); **
'eval']);
** File not found : $sandbox->whitelistKeyword(['echo', **

blacklistKeyword()

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

Parameters

string|array $name

String of keyword name or array of keyword names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistKeyword('echo'); **
'eval']);
** File not found : $sandbox->blacklistKeyword(['echo', **

dewhitelistKeyword()

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

Parameters

string|array $name

String of keyword name or array of keyword names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistKeyword('echo'); **
'eval']);
** File not found : $sandbox->dewhitelistKeyword(['echo', **

deblacklistKeyword()

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

Parameters

string|array $name

String of keyword name or array of keyword names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistKeyword('echo'); **
'eval']);
** File not found : $sandbox->deblacklistKeyword(['echo', **

whitelistOperator()

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

Parameters

string|array $name

String of operator name or array of operator names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistOperator('+'); **
'-']);
** File not found : $sandbox->whitelistOperator(['+', **

blacklistOperator()

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

Parameters

string|array $name

String of operator name or array of operator names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistOperator('+'); **
'-']);
** File not found : $sandbox->blacklistOperator(['+', **

dewhitelistOperator()

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

Parameters

string|array $name

String of operator name or array of operator names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistOperator('+'); **
'-']);
** File not found : $sandbox->dewhitelistOperator(['+', **

deblacklistOperator()

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

Parameters

string|array $name

String of operator name or array of operator names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistOperator('+'); **
'-']);
** File not found : $sandbox->deblacklistOperator(['+', **

whitelistPrimitive()

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

Parameters

string|array $name

String of primitive name or array of primitive names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistPrimitive('int'); **
'float']);
** File not found : $sandbox->whitelistPrimitive(['int', **

blacklistPrimitive()

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

Parameters

string|array $name

String of primitive name or array of primitive names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistPrimitive('int'); **
'float']);
** File not found : $sandbox->blacklistPrimitive(['int', **

dewhitelistPrimitive()

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

Parameters

string|array $name

String of primitive name or array of primitive names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistPrimitive('int'); **
'float']);
** File not found : $sandbox->dewhitelistPrimitive(['int', **

deblacklistPrimitive()

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

Parameters

string|array $name

String of primitive name or array of primitive names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistPrimitive('int'); **
'float']);
** File not found : $sandbox->deblacklistPrimitive(['int', **

whitelistType()

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

Parameters

string|array $name

String of type name or array of type names to whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->whitelistType('PHPSandbox'); **
'PhpParser']);
** File not found : $sandbox->whitelistType(['PHPSandbox', **

blacklistType()

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

Parameters

string|array $name

String of type name or array of type names to blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->blacklistType('PHPSandbox'); **
'PhpParser']);
** File not found : $sandbox->blacklistType(['PHPSandbox', **

dewhitelistType()

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

Parameters

string|array $name

String of type name or array of type names to remove from whitelist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->dewhitelistType('PHPSandbox'); **
'PhpParser']);
** File not found : $sandbox->dewhitelistType(['PHPSandbox', **

deblacklistType()

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

Parameters

string|array $name

String of type name or array of type names to remove from blacklist

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->deblacklistType('PHPSandbox'); **
'PhpParser']);
** File not found : $sandbox->deblacklistType(['PHPSandbox', **

checkFunc()

checkFunc(string  $name) : boolean

Check function name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the function name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if function is valid, this is also used for testing closures

checkVar()

checkVar(string  $name) : boolean

Check variable name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the variable name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if variable is valid

checkGlobal()

checkGlobal(string  $name) : boolean

Check global name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the global name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if global is valid

checkSuperglobal()

checkSuperglobal(string  $name) : boolean

Check superglobal name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the superglobal name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if superglobal is valid

checkConst()

checkConst(string  $name) : boolean

Check constant name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the constant name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if constant is valid

checkMagicConst()

checkMagicConst(string  $name) : boolean

Check magic constant name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the magic constant name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if magic constant is valid

checkNamespace()

checkNamespace(string  $name) : boolean

Check namespace name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the namespace name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if namespace is valid

checkAlias()

checkAlias(string  $name) : boolean

Check alias name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the alias name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if alias is valid

checkUse()

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.

Parameters

string $name

String of the use (or alias) name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if use (or alias) is valid

checkClass()

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.

Parameters

string $name

String of the class name to check

boolean $extends

Flag whether this is an extended class

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if class is valid

checkInterface()

checkInterface(string  $name) : boolean

Check interface name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the interface name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if interface is valid

checkTrait()

checkTrait(string  $name) : boolean

Check trait name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the trait name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if trait is valid

checkKeyword()

checkKeyword(string  $name) : boolean

Check keyword name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the keyword name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if keyword is valid

checkOperator()

checkOperator(string  $name) : boolean

Check operator name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the type operator to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if operator is valid

checkPrimitive()

checkPrimitive(string  $name) : boolean

Check primitive name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the primitive name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if primitive is valid

checkType()

checkType(string  $name) : boolean

Check type name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.

Parameters

string $name

String of the type name to check

Throws

\PHPSandbox\Error

Throws exception if validation error occurs

Returns

boolean —

Returns true if type is valid

prepend()

prepend(string|callable  $code) : $this

Prepend trusted code

Parameters

string|callable $code

String or callable of trusted $code to prepend to generated code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

append()

append(string|callable  $code) : $this

Append trusted code

Parameters

string|callable $code

String or callable of trusted $code to append to generated code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

clear()

clear() : $this

Clear all trusted and sandboxed code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

clearTrustedCode()

clearTrustedCode() : $this

Clear all trusted code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

clearPrependedCode()

clearPrependedCode() : $this

Clear all prepended trusted code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

clearAppendedCode()

clearAppendedCode() : $this

Clear all appended trusted code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

clearCode()

clearCode() : $this

Clear generated code

Returns

$this —

Returns the PHPSandbox instance for fluent querying

getPreparedTime()

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

Parameters

integer|null $round

The number of digits to round the return value

Returns

float —

The amount of time in microseconds it took to prepare the sandboxed code

Examples

** File not found : $sandbox->getPreparedTime(); **
** File not found : $sandbox->getPreparedTime(3); **

getExecutionTime()

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

Parameters

integer|null $round

The number of digits to round the return value

Returns

float —

The amount of time in microseconds it took to execute the sandboxed code

Examples

** File not found : $sandbox->getExecutionTime(); **
** File not found : $sandbox->getExecutionTime(3); **

getTime()

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

Parameters

integer|null $round

The number of digits to round the return value

Returns

float —

The amount of time in microseconds it took to prepare and execute the sandboxed code

Examples

** File not found : $sandbox->getTime(); **
** File not found : $sandbox->getTime(3); **

getMemoryUsage()

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

Parameters

integer|null $round

The number of digits to round the return value

Returns

integer —

The amount of bytes in memory it took to prepare and execute the sandboxed code

Examples

** File not found : $sandbox->getMemoryUsage(); **
** File not found : $sandbox->getMemoryUsage(3); **

validate()

validate(callable|string  $code) : $this

Validate passed callable for execution

Parameters

callable|string $code

The callable or string of code to validate

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

echo "Hello World!"; ?>');
** File not found : $sandbox->validate('<?php **

prepare()

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

Parameters

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

\PHPSandbox\Error

Throws exception if error occurs in parsing, validation or whitelisting

Returns

string —

The generated code (this can also be accessed via $sandbox->generated_code)

Examples

var_dump('Hello world!'); });
** File not found : $sandbox->prepare(function(){ **

execute()

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.

Parameters

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

\PHPSandbox\Error

Throws exception if error occurs in parsing, validation or whitelisting or if generated closure is invalid

Returns

mixed —

The output from the executed sandboxed code

Examples

var_dump('Hello world!'); });
** File not found : $sandbox->execute(function(){ **

setErrorHandler()

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!

Parameters

callable $handler

Callable to handle thrown Errors

integer $error_types

Integer flag of the error types to handle (default is E_ALL)

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

$errstr, $errfile, $errline, $errcontext, PHPSandbox $s){ return false; }, E_ALL); //ignore all errors, INSECURE
** File not found : $sandbox->setErrorHandler(function($errno, **

getErrorHandler()

getErrorHandler() : null|callable

Get error handler

This function returns the sandbox error handler.

Returns

null|callable

Examples

//callable
** File not found : $sandbox->getErrorHandler(); **

unsetErrorHandler()

unsetErrorHandler() : $this

Unset error handler

This function unsets the sandbox error handler.

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->unsetErrorHandler(); **

getLastError()

getLastError() : array

Gets the last sandbox error

Returns

array

error()

error(integer  $errno, string  $errstr, string  $errfile, integer  $errline, array  $errcontext) : mixed

Invoke sandbox error handler

Parameters

integer $errno

Error number

string $errstr

Error message

string $errfile

Error file

integer $errline

Error line number

array $errcontext

Error context array

Returns

mixed

Examples

"Unknown error");
** File not found : $sandbox->error(0, **

setExceptionHandler()

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!

Parameters

callable $handler

Callable to handle thrown exceptions

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

$e, PHPSandbox $s){}); //ignore all thrown exceptions, INSECURE
** File not found : $sandbox->setExceptionHandler(function(Exception **

getExceptionHandler()

getExceptionHandler() : null|callable

Get exception handler

This function returns the sandbox exception handler.

Returns

null|callable

Examples

//callable
** File not found : $sandbox->getExceptionHandler(); **

unsetExceptionHandler()

unsetExceptionHandler() : $this

Unset exception handler

This function unsets the sandbox exception handler.

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->unsetExceptionHandler(); **

getLastException()

getLastException() : \Exception|\PHPSandbox\Error

Gets the last exception thrown by the sandbox

Returns

\Exception|\PHPSandbox\Error

exception()

exception(\Exception  $exception) : mixed

Invoke sandbox exception handler

Parameters

\Exception $exception

Error number

Throws

\Exception

Returns

mixed

Examples

Exception("Unknown error!", 0));
** File not found : $sandbox->exception(new **

setValidationErrorHandler()

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!

Parameters

callable $handler

Callable to handle thrown validation Errors

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

$e, PHPSandbox $s){}); //ignore all thrown Errors, INSECURE
** File not found : $sandbox->setValidationErrorHandler(function(Error **

getValidationErrorHandler()

getValidationErrorHandler() : null|callable

Get validation error handler

This function returns the sandbox validation error handler.

Returns

null|callable

Examples

//callable
** File not found : $sandbox->getValidationErrorHandler(); **

unsetValidationErrorHandler()

unsetValidationErrorHandler() : $this

Unset validation error handler

This function unsets the sandbox validation error handler.

Returns

$this —

Returns the PHPSandbox instance for fluent querying

Examples

** File not found : $sandbox->unsetValidationErrorHandler(); **