\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()
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()
clearPrepended()
clearPrependedCode()
clearAppend()
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()
__call()
define_func()
define_funcs()
has_defined_funcs()
is_defined_func()
undefine_func()
undefine_funcs()
define_var()
define_vars()
has_defined_vars()
is_defined_var()
undefine_var()
undefine_vars()
define_superglobal()
define_superglobals()
has_defined_superglobals()
is_defined_superglobal()
undefine_superglobal()
undefine_superglobals()
define_const()
define_consts()
has_defined_consts()
is_defined_const()
undefine_const()
undefine_consts()
define_magic_const()
define_magic_consts()
has_defined_magic_consts()
is_defined_magic_const()
undefine_magic_const()
undefine_magic_consts()
define_namespace()
define_namespaces()
has_defined_namespaces()
is_defined_namespace()
get_defined_namespace()
undefine_namespace()
undefine_namespaces()
define_alias()
define_aliases()
has_defined_aliases()
is_defined_alias()
undefine_alias()
undefine_aliases()
define_use()
define_uses()
has_defined_uses()
is_defined_use()
undefine_use()
undefine_uses()
define_class()
define_classes()
has_defined_classes()
is_defined_class()
get_defined_class()
undefine_class()
undefine_classes()
define_interface()
define_interfaces()
has_defined_interfaces()
is_defined_interface()
get_defined_interface()
undefine_interface()
undefine_interfaces()
define_trait()
define_traits()
has_defined_traits()
is_defined_trait()
get_defined_trait()
undefine_trait()
undefine_traits()
has_whitelist()
has_blacklist()
is_whitelisted()
is_blacklisted()
has_whitelist_funcs()
has_blacklist_funcs()
is_whitelisted_func()
is_blacklisted_func()
has_whitelist_vars()
has_blacklist_vars()
is_whitelisted_var()
is_blacklisted_var()
has_whitelist_globals()
has_blacklist_globals()
is_whitelisted_global()
is_blacklisted_global()
has_whitelist_superglobals()
has_blacklist_superglobals()
is_whitelisted_superglobal()
is_blacklisted_superglobal()
has_whitelist_consts()
has_blacklist_consts()
is_whitelisted_const()
is_blacklisted_const()
has_whitelist_magic_consts()
has_blacklist_magic_consts()
is_whitelisted_magic_const()
is_blacklisted_magic_const()
has_whitelist_namespaces()
has_blacklist_namespaces()
is_whitelisted_namespace()
is_blacklisted_namespace()
has_whitelist_aliases()
has_blacklist_aliases()
is_whitelisted_alias()
is_blacklisted_alias()
has_whitelist_uses()
has_blacklist_uses()
is_whitelisted_use()
is_blacklisted_use()
has_whitelist_classes()
has_blacklist_classes()
is_whitelisted_class()
is_blacklisted_class()
has_whitelist_interfaces()
has_blacklist_interfaces()
is_whitelisted_interface()
is_blacklisted_interface()
has_whitelist_traits()
has_blacklist_traits()
is_whitelisted_trait()
is_blacklisted_trait()
has_whitelist_keywords()
has_blacklist_keywords()
is_whitelisted_keyword()
is_blacklisted_keyword()
has_whitelist_operators()
has_blacklist_operators()
is_whitelisted_operator()
is_blacklisted_operator()
has_whitelist_primitives()
has_blacklist_primitives()
is_whitelisted_primitive()
is_blacklisted_primitive()
has_whitelist_types()
has_blacklist_types()
is_whitelisted_type()
is_blacklisted_type()
whitelist_func()
blacklist_func()
dewhitelist_func()
deblacklist_func()
whitelist_var()
blacklist_var()
dewhitelist_var()
deblacklist_var()
whitelist_global()
blacklist_global()
dewhitelist_global()
deblacklist_global()
whitelist_superglobal()
blacklist_superglobal()
dewhitelist_superglobal()
deblacklist_superglobal()
whitelist_const()
blacklist_const()
dewhitelist_const()
deblacklist_const()
whitelist_magic_const()
blacklist_magic_const()
dewhitelist_magic_const()
deblacklist_magic_const()
whitelist_namespace()
blacklist_namespace()
dewhitelist_namespace()
deblacklist_namespace()
whitelist_alias()
blacklist_alias()
dewhitelist_alias()
deblacklist_alias()
whitelist_use()
blacklist_use()
dewhitelist_use()
deblacklist_use()
whitelist_class()
blacklist_class()
dewhitelist_class()
deblacklist_class()
whitelist_interface()
blacklist_interface()
dewhitelist_interface()
deblacklist_interface()
whitelist_trait()
blacklist_trait()
dewhitelist_trait()
deblacklist_trait()
whitelist_keyword()
blacklist_keyword()
dewhitelist_keyword()
deblacklist_keyword()
whitelist_operator()
blacklist_operator()
dewhitelist_operator()
deblacklist_operator()
whitelist_primitive()
blacklist_primitive()
dewhitelist_primitive()
deblacklist_primitive()
whitelist_type()
blacklist_type()
dewhitelist_type()
deblacklist_type()
check_func()
check_var()
check_global()
check_superglobal()
check_const()
check_magic_const()
check_namespace()
check_alias()
check_use()
check_class()
check_interface()
check_trait()
check_keyword()
check_operator()
check_primitive()
check_type()
clear_trusted_code()
clear_prepend()
clear_append()
clear_code()
get_prepared_time()
get_execution_time()
get_time()
set_error_handler()
get_error_handler()
unset_error_handler()
get_last_error()
set_exception_handler()
get_exception_handler()
unset_exception_handler()
get_last_exception()
set_validation_error_handler()
get_validation_error_handler()
unset_validation_error_handler()
get_last_validation_error()
validation_error()
normalize_func()
normalize_superglobal()
normalize_magic_const()
normalize_namespace()
normalize_alias()
normalize_use()
normalize_class()
normalize_interface()
normalize_trait()
normalize_keyword()
normalize_operator()
normalize_primitive()
normalize_type()
prepare_vars()
prepare_consts()
prepare_namespaces()
prepare_aliases()
prepare_uses()
auto_whitelist()
auto_define()
$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

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

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

__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

__sleep()

__sleep() : array

PHPSandbox __sleep magic method

Returns

array —

An array of property keys to be serialized

import()

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

PHPSandbox __wakeup magic method

  • 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

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

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

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

resetOptions()

resetOptions() : $this

Reset PHPSandbox options to their default values

Returns

$this —

Returns the PHPSandbox instance for fluent querying

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

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

getValidator()

getValidator(string  $type) : callable|null

Get validation callable for specified $type

Parameters

string $type

String of $type to return

Returns

callable|null

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

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

getFuncValidator()

getFuncValidator() : callable|null

Get validation for functions

Returns

callable|null

unsetFuncValidator()

unsetFuncValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for functions

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getVarValidator()

getVarValidator() : callable|null

Get validation callable for variables

Returns

callable|null

unsetVarValidator()

unsetVarValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for variables

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getGlobalValidator()

getGlobalValidator() : callable|null

Get validation callable for globals

Returns

callable|null

unsetGlobalValidator()

unsetGlobalValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for globals

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getSuperglobalValidator()

getSuperglobalValidator() : callable|null

Get validation callable for superglobals

Returns

callable|null

unsetSuperglobalValidator()

unsetSuperglobalValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for superglobals

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getConstValidator()

getConstValidator() : callable|null

Get validation callable for constants

Returns

callable|null

unsetConstValidator()

unsetConstValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for constants

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getMagicConstValidator()

getMagicConstValidator() : callable|null

Get validation callable for magic constants

Returns

callable|null

unsetMagicConstValidator()

unsetMagicConstValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for magic constants

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getNamespaceValidator()

getNamespaceValidator() : callable|null

Get validation callable for namespaces

Returns

callable|null

unsetNamespaceValidator()

unsetNamespaceValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for namespaces

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getAliasValidator()

getAliasValidator() : callable|null

Get validation callable for aliases

Returns

callable|null

unsetAliasValidator()

unsetAliasValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for aliases

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getUseValidator()

getUseValidator() : callable|null

Get validation callable for uses (aka aliases)

Returns

callable|null

unsetUseValidator()

unsetUseValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for uses (aka aliases)

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getClassValidator()

getClassValidator() : callable|null

Get validation callable for classes

Returns

callable|null

unsetClassValidator()

unsetClassValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for classes

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getInterfaceValidator()

getInterfaceValidator() : callable|null

Get validation callable for interfaces

Returns

callable|null

unsetInterfaceValidator()

unsetInterfaceValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for interfaces

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getTraitValidator()

getTraitValidator() : callable|null

Get validation callable for traits

Returns

callable|null

unsetTraitValidator()

unsetTraitValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for traits

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getKeywordValidator()

getKeywordValidator() : callable|null

Get validation callable for keywords

Returns

callable|null

unsetKeywordValidator()

unsetKeywordValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for keywords

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getOperatorValidator()

getOperatorValidator() : callable|null

Get validation callable for operators

Returns

callable|null

unsetOperatorValidator()

unsetOperatorValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for operators

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getPrimitiveValidator()

getPrimitiveValidator() : callable|null

Get validation callable for primitives

Returns

callable|null

unsetPrimitiveValidator()

unsetPrimitiveValidator() : \PHPSandbox\PHPSandbox

Unset validation callable for primitives

Returns

\PHPSandbox\PHPSandbox

Returns the PHPSandbox instance for fluent querying

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

getTypeValidator()

getTypeValidator() : callable|null

Get validation callable for types

Returns

callable|null

unsetTypeValidator()

unsetTypeValidator() : $this

Unset validation callable for types

Returns

$this —

Returns the PHPSandbox instance for fluent querying

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

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

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

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

hasDefinedFuncs()

hasDefinedFuncs() : integer

Query whether PHPSandbox instance has defined functions

Returns

integer —

Returns the number of functions this instance has defined

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

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

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

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

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

hasDefinedVars()

hasDefinedVars() : integer

Query whether PHPSandbox instance has defined variables

Returns

integer —

Returns the number of variables this instance has defined

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

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

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

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

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

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

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

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

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

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

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

hasDefinedConsts()

hasDefinedConsts() : integer

Query whether PHPSandbox instance has defined constants

Returns

integer —

Returns the number of constants this instance has defined

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

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

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

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

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

hasDefinedMagicConsts()

hasDefinedMagicConsts() : integer

Query whether PHPSandbox instance has defined magic constants

Returns

integer —

Returns the number of magic constants this instance has defined

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

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

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

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

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

hasDefinedNamespaces()

hasDefinedNamespaces() : integer

Query whether PHPSandbox instance has defined namespaces

Returns

integer —

Returns the number of namespaces this instance has defined

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

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

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

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

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

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

hasDefinedAliases()

hasDefinedAliases() : integer

Query whether PHPSandbox instance has defined aliases

Returns

integer —

Returns the number of aliases this instance has defined

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

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

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

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

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

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

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

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

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

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

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

hasDefinedClasses()

hasDefinedClasses() : integer

Query whether PHPSandbox instance has defined classes

Returns

integer —

Returns the number of classes this instance has defined

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

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

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

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

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

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

hasDefinedInterfaces()

hasDefinedInterfaces() : integer

Query whether PHPSandbox instance has defined interfaces

Returns

integer —

Returns the number of interfaces this instance has defined

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

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

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

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

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

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

hasDefinedTraits()

hasDefinedTraits() : integer

Query whether PHPSandbox instance has defined traits

Returns

integer —

Returns the number of traits this instance has defined

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

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

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

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

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

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

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

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

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

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

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

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

hasWhitelistedFuncs()

hasWhitelistedFuncs() : integer

Query whether PHPSandbox instance has whitelisted functions.

Returns

integer —

Returns the number of whitelisted functions this instance has defined

hasBlacklistedFuncs()

hasBlacklistedFuncs() : integer

Query whether PHPSandbox instance has blacklisted functions.

Returns

integer —

Returns the number of blacklisted functions this instance has defined

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

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

hasWhitelistedVars()

hasWhitelistedVars() : integer

Query whether PHPSandbox instance has whitelisted variables.

Returns

integer —

Returns the number of whitelisted variables this instance has defined

hasBlacklistedVars()

hasBlacklistedVars() : integer

Query whether PHPSandbox instance has blacklisted variables.

Returns

integer —

Returns the number of blacklisted variables this instance has defined

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

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

hasWhitelistedGlobals()

hasWhitelistedGlobals() : integer

Query whether PHPSandbox instance has whitelisted globals.

Returns

integer —

Returns the number of whitelisted globals this instance has defined

hasBlacklistedGlobals()

hasBlacklistedGlobals() : integer

Query whether PHPSandbox instance has blacklisted globals.

Returns

integer —

Returns the number of blacklisted globals this instance has defined

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

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

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

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

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

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

hasWhitelistedConsts()

hasWhitelistedConsts() : integer

Query whether PHPSandbox instance has whitelisted constants.

Returns

integer —

Returns the number of whitelisted constants this instance has defined

hasBlacklistedConsts()

hasBlacklistedConsts() : integer

Query whether PHPSandbox instance has blacklisted constants.

Returns

integer —

Returns the number of blacklisted constants this instance has defined

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

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

hasWhitelistedMagicConsts()

hasWhitelistedMagicConsts() : integer

Query whether PHPSandbox instance has whitelisted magic constants.

Returns

integer —

Returns the number of whitelisted magic constants this instance has defined

hasBlacklistedMagicConsts()

hasBlacklistedMagicConsts() : integer

Query whether PHPSandbox instance has blacklisted magic constants.

Returns

integer —

Returns the number of blacklisted magic constants this instance has defined

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

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

hasWhitelistedNamespaces()

hasWhitelistedNamespaces() : integer

Query whether PHPSandbox instance has whitelisted namespaces.

Returns

integer —

Returns the number of whitelisted namespaces this instance has defined

hasBlacklistedNamespaces()

hasBlacklistedNamespaces() : integer

Query whether PHPSandbox instance has blacklisted namespaces.

Returns

integer —

Returns the number of blacklisted namespaces this instance has defined

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

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

hasWhitelistedAliases()

hasWhitelistedAliases() : integer

Query whether PHPSandbox instance has whitelisted aliases.

Returns

integer —

Returns the number of whitelisted aliases this instance has defined

hasBlacklistedAliases()

hasBlacklistedAliases() : integer

Query whether PHPSandbox instance has blacklisted aliases.

Returns

integer —

Returns the number of blacklisted aliases this instance has defined

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

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

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

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

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

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

hasWhitelistedClasses()

hasWhitelistedClasses() : integer

Query whether PHPSandbox instance has whitelisted classes.

Returns

integer —

Returns the number of whitelisted classes this instance has defined

hasBlacklistedClasses()

hasBlacklistedClasses() : integer

Query whether PHPSandbox instance has blacklisted classes.

Returns

integer —

Returns the number of blacklisted classes this instance has defined

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

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

hasWhitelistedInterfaces()

hasWhitelistedInterfaces() : integer

Query whether PHPSandbox instance has whitelisted interfaces.

Returns

integer —

Returns the number of whitelisted interfaces this instance has defined

hasBlacklistedInterfaces()

hasBlacklistedInterfaces() : integer

Query whether PHPSandbox instance has blacklisted interfaces.

Returns

integer —

Returns the number of blacklisted interfaces this instance has defined

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

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

hasWhitelistedTraits()

hasWhitelistedTraits() : integer

Query whether PHPSandbox instance has whitelisted traits.

Returns

integer —

Returns the number of whitelisted traits this instance has defined

hasBlacklistedTraits()

hasBlacklistedTraits() : integer

Query whether PHPSandbox instance has blacklisted traits.

Returns

integer —

Returns the number of blacklisted traits this instance has defined

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

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

hasWhitelistKeywords()

hasWhitelistKeywords() : integer

Query whether PHPSandbox instance has whitelisted keywords.

Returns

integer —

Returns the number of whitelisted keywords this instance has defined

hasBlacklistedKeywords()

hasBlacklistedKeywords() : integer

Query whether PHPSandbox instance has blacklisted keywords.

Returns

integer —

Returns the number of blacklisted keywords this instance has defined

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

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

hasWhitelistedOperators()

hasWhitelistedOperators() : integer

Query whether PHPSandbox instance has whitelisted operators.

Returns

integer —

Returns the number of whitelisted operators this instance has defined

hasBlacklistedOperators()

hasBlacklistedOperators() : integer

Query whether PHPSandbox instance has blacklisted operators.

Returns

integer —

Returns the number of blacklisted operators this instance has defined

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

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

hasWhitelistedPrimitives()

hasWhitelistedPrimitives() : integer

Query whether PHPSandbox instance has whitelisted primitives.

Returns

integer —

Returns the number of whitelisted primitives this instance has defined

hasBlacklistedPrimitives()

hasBlacklistedPrimitives() : integer

Query whether PHPSandbox instance has blacklisted primitives.

Returns

integer —

Returns the number of blacklisted primitives this instance has defined

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

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

hasWhitelistedTypes()

hasWhitelistedTypes() : integer

Query whether PHPSandbox instance has whitelisted types.

Returns

integer —

Returns the number of whitelisted types this instance has defined

hasBlacklistedTypes()

hasBlacklistedTypes() : integer

Query whether PHPSandbox instance has blacklisted types.

Returns

integer —

Returns the number of blacklisted types this instance has defined

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

clearPrepended()

clearPrepended() : $this

Clear all prepended 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

clearAppend()

clearAppend() : $this

Clear all appended 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

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

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

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

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

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)

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

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!

}, E_ALL); //ignore all errors, INSECURE

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

getErrorHandler()

getErrorHandler() : null|callable

Get error handler

This function returns the sandbox error handler.

Returns

null|callable

unsetErrorHandler()

unsetErrorHandler() : $this

Unset error handler

This function unsets the sandbox error handler.

Returns

$this —

Returns the PHPSandbox instance for fluent querying

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

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

getExceptionHandler()

getExceptionHandler() : null|callable

Get exception handler

This function returns the sandbox exception handler.

Returns

null|callable

unsetExceptionHandler()

unsetExceptionHandler() : $this

Unset exception handler

This function unsets the sandbox exception handler.

Returns

$this —

Returns the PHPSandbox instance for fluent querying

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

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

getValidationErrorHandler()

getValidationErrorHandler() : null|callable

Get validation error handler

This function returns the sandbox validation error handler.

Returns

null|callable

unsetValidationErrorHandler()

unsetValidationErrorHandler() : $this

Unset validation error handler

This function unsets the sandbox validation error handler.

Returns

$this —

Returns the PHPSandbox instance for fluent querying

getLastValidationError()

getLastValidationError() : \Exception|\PHPSandbox\Error

Gets the last validation error thrown by the sandbox

Returns

\Exception|\PHPSandbox\Error

validationError()

validationError(\Exception|\PHPSandbox\Error|string  $error, integer  $code, \PhpParser\Node|null  $node = null, mixed  $data = null, \Exception|\PHPSandbox\Error|null  $previous = null) : mixed

Invoke sandbox error validation handler if it exists, throw Error otherwise

Parameters

\Exception|\PHPSandbox\Error|string $error

Error to throw if Error is not handled, or error message string

integer $code

The error code

\PhpParser\Node|null $node

The error parser node

mixed $data

The error data

\Exception|\PHPSandbox\Error|null $previous

The previous Error thrown

Throws

\Exception|\PHPSandbox\Error

Returns

mixed

getSandbox()

getSandbox(string  $name) : null|\PHPSandbox\PHPSandbox

Get a named PHPSandbox instance (used to retrieve the sandbox instance from within sandboxed code)

Parameters

string $name

The name of the PHPSandbox instance to retrieve

Returns

null|\PHPSandbox\PHPSandbox

getIterator()

getIterator() : array

Get an iterator of all the public PHPSandbox properties

Returns

array

__call()

__call(string  $method, array  $arguments) : mixed

Magic method to provide API compatibility for v1.* code

Parameters

string $method

The method name to call

array $arguments

The method arguments to call

Returns

mixed

define_func()

define_func() : void

define_funcs()

define_funcs() : void

has_defined_funcs()

has_defined_funcs() : void

is_defined_func()

is_defined_func() : void

undefine_func()

undefine_func() : void

undefine_funcs()

undefine_funcs() : void

define_var()

define_var() : void

define_vars()

define_vars() : void

has_defined_vars()

has_defined_vars() : void

is_defined_var()

is_defined_var() : void

undefine_var()

undefine_var() : void

undefine_vars()

undefine_vars() : void

define_superglobal()

define_superglobal() : void

define_superglobals()

define_superglobals() : void

has_defined_superglobals()

has_defined_superglobals() : void

is_defined_superglobal()

is_defined_superglobal() : void

undefine_superglobal()

undefine_superglobal() : void

undefine_superglobals()

undefine_superglobals() : void

define_const()

define_const() : void

define_consts()

define_consts() : void

has_defined_consts()

has_defined_consts() : void

is_defined_const()

is_defined_const() : void

undefine_const()

undefine_const() : void

undefine_consts()

undefine_consts() : void

define_magic_const()

define_magic_const() : void

define_magic_consts()

define_magic_consts() : void

has_defined_magic_consts()

has_defined_magic_consts() : void

is_defined_magic_const()

is_defined_magic_const() : void

undefine_magic_const()

undefine_magic_const() : void

undefine_magic_consts()

undefine_magic_consts() : void

define_namespace()

define_namespace() : void

define_namespaces()

define_namespaces() : void

has_defined_namespaces()

has_defined_namespaces() : void

is_defined_namespace()

is_defined_namespace() : void

get_defined_namespace()

get_defined_namespace() : void

undefine_namespace()

undefine_namespace() : void

undefine_namespaces()

undefine_namespaces() : void

define_alias()

define_alias() : void

define_aliases()

define_aliases() : void

has_defined_aliases()

has_defined_aliases() : void

is_defined_alias()

is_defined_alias() : void

undefine_alias()

undefine_alias() : void

undefine_aliases()

undefine_aliases() : void

define_use()

define_use() : void

define_uses()

define_uses() : void

has_defined_uses()

has_defined_uses() : void

is_defined_use()

is_defined_use() : void

undefine_use()

undefine_use() : void

undefine_uses()

undefine_uses() : void

define_class()

define_class() : void

define_classes()

define_classes() : void

has_defined_classes()

has_defined_classes() : void

is_defined_class()

is_defined_class() : void

get_defined_class()

get_defined_class() : void

undefine_class()

undefine_class() : void

undefine_classes()

undefine_classes() : void

define_interface()

define_interface() : void

define_interfaces()

define_interfaces() : void

has_defined_interfaces()

has_defined_interfaces() : void

is_defined_interface()

is_defined_interface() : void

get_defined_interface()

get_defined_interface() : void

undefine_interface()

undefine_interface() : void

undefine_interfaces()

undefine_interfaces() : void

define_trait()

define_trait() : void

define_traits()

define_traits() : void

has_defined_traits()

has_defined_traits() : void

is_defined_trait()

is_defined_trait() : void

get_defined_trait()

get_defined_trait() : void

undefine_trait()

undefine_trait() : void

undefine_traits()

undefine_traits() : void

has_whitelist()

has_whitelist() : void

has_blacklist()

has_blacklist() : void

is_whitelisted()

is_whitelisted() : void

is_blacklisted()

is_blacklisted() : void

has_whitelist_funcs()

has_whitelist_funcs() : void

has_blacklist_funcs()

has_blacklist_funcs() : void

is_whitelisted_func()

is_whitelisted_func() : void

is_blacklisted_func()

is_blacklisted_func() : void

has_whitelist_vars()

has_whitelist_vars() : void

has_blacklist_vars()

has_blacklist_vars() : void

is_whitelisted_var()

is_whitelisted_var() : void

is_blacklisted_var()

is_blacklisted_var() : void

has_whitelist_globals()

has_whitelist_globals() : void

has_blacklist_globals()

has_blacklist_globals() : void

is_whitelisted_global()

is_whitelisted_global() : void

is_blacklisted_global()

is_blacklisted_global() : void

has_whitelist_superglobals()

has_whitelist_superglobals() : void

has_blacklist_superglobals()

has_blacklist_superglobals() : void

is_whitelisted_superglobal()

is_whitelisted_superglobal() : void

is_blacklisted_superglobal()

is_blacklisted_superglobal() : void

has_whitelist_consts()

has_whitelist_consts() : void

has_blacklist_consts()

has_blacklist_consts() : void

is_whitelisted_const()

is_whitelisted_const() : void

is_blacklisted_const()

is_blacklisted_const() : void

has_whitelist_magic_consts()

has_whitelist_magic_consts() : void

has_blacklist_magic_consts()

has_blacklist_magic_consts() : void

is_whitelisted_magic_const()

is_whitelisted_magic_const() : void

is_blacklisted_magic_const()

is_blacklisted_magic_const() : void

has_whitelist_namespaces()

has_whitelist_namespaces() : void

has_blacklist_namespaces()

has_blacklist_namespaces() : void

is_whitelisted_namespace()

is_whitelisted_namespace() : void

is_blacklisted_namespace()

is_blacklisted_namespace() : void

has_whitelist_aliases()

has_whitelist_aliases() : void

has_blacklist_aliases()

has_blacklist_aliases() : void

is_whitelisted_alias()

is_whitelisted_alias() : void

is_blacklisted_alias()

is_blacklisted_alias() : void

has_whitelist_uses()

has_whitelist_uses() : void

has_blacklist_uses()

has_blacklist_uses() : void

is_whitelisted_use()

is_whitelisted_use() : void

is_blacklisted_use()

is_blacklisted_use() : void

has_whitelist_classes()

has_whitelist_classes() : void

has_blacklist_classes()

has_blacklist_classes() : void

is_whitelisted_class()

is_whitelisted_class() : void

is_blacklisted_class()

is_blacklisted_class() : void

has_whitelist_interfaces()

has_whitelist_interfaces() : void

has_blacklist_interfaces()

has_blacklist_interfaces() : void

is_whitelisted_interface()

is_whitelisted_interface() : void

is_blacklisted_interface()

is_blacklisted_interface() : void

has_whitelist_traits()

has_whitelist_traits() : void

has_blacklist_traits()

has_blacklist_traits() : void

is_whitelisted_trait()

is_whitelisted_trait() : void

is_blacklisted_trait()

is_blacklisted_trait() : void

has_whitelist_keywords()

has_whitelist_keywords() : void

has_blacklist_keywords()

has_blacklist_keywords() : void

is_whitelisted_keyword()

is_whitelisted_keyword() : void

is_blacklisted_keyword()

is_blacklisted_keyword() : void

has_whitelist_operators()

has_whitelist_operators() : void

has_blacklist_operators()

has_blacklist_operators() : void

is_whitelisted_operator()

is_whitelisted_operator() : void

is_blacklisted_operator()

is_blacklisted_operator() : void

has_whitelist_primitives()

has_whitelist_primitives() : void

has_blacklist_primitives()

has_blacklist_primitives() : void

is_whitelisted_primitive()

is_whitelisted_primitive() : void

is_blacklisted_primitive()

is_blacklisted_primitive() : void

has_whitelist_types()

has_whitelist_types() : void

has_blacklist_types()

has_blacklist_types() : void

is_whitelisted_type()

is_whitelisted_type() : void

is_blacklisted_type()

is_blacklisted_type() : void

whitelist_func()

whitelist_func() : void

blacklist_func()

blacklist_func() : void

dewhitelist_func()

dewhitelist_func() : void

deblacklist_func()

deblacklist_func() : void

whitelist_var()

whitelist_var() : void

blacklist_var()

blacklist_var() : void

dewhitelist_var()

dewhitelist_var() : void

deblacklist_var()

deblacklist_var() : void

whitelist_global()

whitelist_global() : void

blacklist_global()

blacklist_global() : void

dewhitelist_global()

dewhitelist_global() : void

deblacklist_global()

deblacklist_global() : void

whitelist_superglobal()

whitelist_superglobal() : void

blacklist_superglobal()

blacklist_superglobal() : void

dewhitelist_superglobal()

dewhitelist_superglobal() : void

deblacklist_superglobal()

deblacklist_superglobal() : void

whitelist_const()

whitelist_const() : void

blacklist_const()

blacklist_const() : void

dewhitelist_const()

dewhitelist_const() : void

deblacklist_const()

deblacklist_const() : void

whitelist_magic_const()

whitelist_magic_const() : void

blacklist_magic_const()

blacklist_magic_const() : void

dewhitelist_magic_const()

dewhitelist_magic_const() : void

deblacklist_magic_const()

deblacklist_magic_const() : void

whitelist_namespace()

whitelist_namespace() : void

blacklist_namespace()

blacklist_namespace() : void

dewhitelist_namespace()

dewhitelist_namespace() : void

deblacklist_namespace()

deblacklist_namespace() : void

whitelist_alias()

whitelist_alias() : void

blacklist_alias()

blacklist_alias() : void

dewhitelist_alias()

dewhitelist_alias() : void

deblacklist_alias()

deblacklist_alias() : void

whitelist_use()

whitelist_use() : void

blacklist_use()

blacklist_use() : void

dewhitelist_use()

dewhitelist_use() : void

deblacklist_use()

deblacklist_use() : void

whitelist_class()

whitelist_class() : void

blacklist_class()

blacklist_class() : void

dewhitelist_class()

dewhitelist_class() : void

deblacklist_class()

deblacklist_class() : void

whitelist_interface()

whitelist_interface() : void

blacklist_interface()

blacklist_interface() : void

dewhitelist_interface()

dewhitelist_interface() : void

deblacklist_interface()

deblacklist_interface() : void

whitelist_trait()

whitelist_trait() : void

blacklist_trait()

blacklist_trait() : void

dewhitelist_trait()

dewhitelist_trait() : void

deblacklist_trait()

deblacklist_trait() : void

whitelist_keyword()

whitelist_keyword() : void

blacklist_keyword()

blacklist_keyword() : void

dewhitelist_keyword()

dewhitelist_keyword() : void

deblacklist_keyword()

deblacklist_keyword() : void

whitelist_operator()

whitelist_operator() : void

blacklist_operator()

blacklist_operator() : void

dewhitelist_operator()

dewhitelist_operator() : void

deblacklist_operator()

deblacklist_operator() : void

whitelist_primitive()

whitelist_primitive() : void

blacklist_primitive()

blacklist_primitive() : void

dewhitelist_primitive()

dewhitelist_primitive() : void

deblacklist_primitive()

deblacklist_primitive() : void

whitelist_type()

whitelist_type() : void

blacklist_type()

blacklist_type() : void

dewhitelist_type()

dewhitelist_type() : void

deblacklist_type()

deblacklist_type() : void

check_func()

check_func() : void

check_var()

check_var() : void

check_global()

check_global() : void

check_superglobal()

check_superglobal() : void

check_const()

check_const() : void

check_magic_const()

check_magic_const() : void

check_namespace()

check_namespace() : void

check_alias()

check_alias() : void

check_use()

check_use() : void

check_class()

check_class() : void

check_interface()

check_interface() : void

check_trait()

check_trait() : void

check_keyword()

check_keyword() : void

check_operator()

check_operator() : void

check_primitive()

check_primitive() : void

check_type()

check_type() : void

clear_trusted_code()

clear_trusted_code() : void

clear_prepend()

clear_prepend() : void

clear_append()

clear_append() : void

clear_code()

clear_code() : void

get_prepared_time()

get_prepared_time() : void

get_execution_time()

get_execution_time() : void

get_time()

get_time() : void

set_error_handler()

set_error_handler() : void

get_error_handler()

get_error_handler() : void

unset_error_handler()

unset_error_handler() : void

get_last_error()

get_last_error() : void

set_exception_handler()

set_exception_handler() : void

get_exception_handler()

get_exception_handler() : void

unset_exception_handler()

unset_exception_handler() : void

get_last_exception()

get_last_exception() : void

set_validation_error_handler()

set_validation_error_handler() : void

get_validation_error_handler()

get_validation_error_handler() : void

unset_validation_error_handler()

unset_validation_error_handler() : void

get_last_validation_error()

get_last_validation_error() : void

validation_error()

validation_error() : void

normalize_func()

normalize_func() : void

normalize_superglobal()

normalize_superglobal() : void

normalize_magic_const()

normalize_magic_const() : void

normalize_namespace()

normalize_namespace() : void

normalize_alias()

normalize_alias() : void

normalize_use()

normalize_use() : void

normalize_class()

normalize_class() : void

normalize_interface()

normalize_interface() : void

normalize_trait()

normalize_trait() : void

normalize_keyword()

normalize_keyword() : void

normalize_operator()

normalize_operator() : void

normalize_primitive()

normalize_primitive() : void

normalize_type()

normalize_type() : void

prepare_vars()

prepare_vars() : void

prepare_consts()

prepare_consts() : void

prepare_namespaces()

prepare_namespaces() : void

prepare_aliases()

prepare_aliases() : void

prepare_uses()

prepare_uses() : void

auto_whitelist()

auto_whitelist() : void

auto_define()

auto_define() : void

normalizeFunc()

normalizeFunc(string|array  $name) : string|array

Normalize function name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the function $name, or array of strings to normalize

Returns

string|array —

Returns the normalized function string or an array of normalized strings

normalizeSuperglobal()

normalizeSuperglobal(string|array  $name) : string|array

Normalize superglobal name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the superglobal $name, or array of strings to normalize

Returns

string|array —

Returns the normalized superglobal string or an array of normalized strings

normalizeMagicConst()

normalizeMagicConst(string|array  $name) : string|array

Normalize magic constant name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the magic constant $name, or array of strings to normalize

Returns

string|array —

Returns the normalized magic constant string or an array of normalized strings

normalizeNamespace()

normalizeNamespace(string|array  $name) : string|array

Normalize namespace name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the namespace $name, or array of strings to normalize

Returns

string|array —

Returns the normalized namespace string or an array of normalized strings

normalizeAlias()

normalizeAlias(string|array  $name) : string|array

Normalize alias name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the alias $name, or array of strings to normalize

Returns

string|array —

Returns the normalized alias string or an array of normalized strings

normalizeUse()

normalizeUse(string|array  $name) : string|array

Normalize use (or alias) name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the use (or alias) $name, or array of strings to normalize

Returns

string|array —

Returns the normalized use (or alias) string or an array of normalized strings

normalizeClass()

normalizeClass(string|array  $name) : string|array

Normalize class name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the class $name to normalize

Returns

string|array —

Returns the normalized class string or an array of normalized strings

normalizeInterface()

normalizeInterface(string|array  $name) : string|array

Normalize interface name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the interface $name, or array of strings to normalize

Returns

string|array —

Returns the normalized interface string or an array of normalized strings

normalizeTrait()

normalizeTrait(string|array  $name) : string|array

Normalize trait name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the trait $name, or array of strings to normalize

Returns

string|array —

Returns the normalized trait string or an array of normalized strings

normalizeKeyword()

normalizeKeyword(string|array  $name) : string|array

Normalize keyword name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the keyword $name, or array of strings to normalize

Returns

string|array —

Returns the normalized keyword string or an array of normalized strings

normalizeOperator()

normalizeOperator(string|array  $name) : string|array

Normalize operator name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the operator $name, or array of strings to normalize

Returns

string|array —

Returns the normalized operator string or an array of normalized strings

normalizePrimitive()

normalizePrimitive(string|array  $name) : string|array

Normalize primitive name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the primitive $name, or array of strings to normalize

Returns

string|array —

Returns the normalized primitive string or an array of normalized strings

normalizeType()

normalizeType(string|array  $name) : string|array

Normalize type name. This is an internal PHPSandbox function.

Parameters

string|array $name

String of the type $name, or array of strings to normalize

Returns

string|array —

Returns the normalized type string or an array of normalized strings

prepareVars()

prepareVars() : string

Prepare defined variables for execution

Throws

\PHPSandbox\Error

Throws exception if variable preparation error occurs

Returns

string —

Prepared string of variable output

prepareConsts()

prepareConsts() 

Prepare defined constants for execution

prepareNamespaces()

prepareNamespaces() 

Prepare defined namespaces for execution

prepareAliases()

prepareAliases() 

Prepare defined aliases for execution

prepareUses()

prepareUses() 

Prepare defined uses (or aliases) for execution

disassemble()

disassemble(callable  $closure) : string

Disassemble callable to string

Parameters

callable $closure

The callable to disassemble

Throws

\PHPSandbox\Error

Throw exception if callable is passed and FunctionParser library is missing

Returns

string —

Return the disassembled code string

autoWhitelist()

autoWhitelist(string  $code, boolean  $appended = false) : mixed

Automatically whitelisted trusted code

Parameters

string $code

String of trusted $code to automatically whitelist

boolean $appended

Flag if this code ir prended or appended (true = appended)

Throws

\PHPSandbox\Error

Throw exception if code cannot be parsed for whitelisting

Returns

mixed —

Return result of error handler if $code could not be parsed

autoDefine()

autoDefine(\FunctionParser\FunctionParser  $disassembled_closure) 

Automatically define variables passed to disassembled closure

Parameters

\FunctionParser\FunctionParser $disassembled_closure