PHP Class PhpSandbox\PHPSandbox

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
Author: Elijah Horton ([email protected])
Inheritance: implements IteratorAggregate
Afficher le fichier Open project: Corveda/PHPSandbox Class Usage Examples

Méthodes publiques

Свойство Type Description
$allow_aliases Should PHPSandbox allow sandboxed code to use namespaces and declare namespace aliases (utilizing the defineAlias function?)
$allow_backticks 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_casting Should PHPSandbox allow sandboxed code to cast types? (This will still be subject to allowed classes)
$allow_classes Should PHPSandbox allow sandboxed code to declare classes?
$allow_closures Should PHPSandbox allow sandboxed code to declare closures?
$allow_constants Should PHPSandbox allow sandboxed code to define constants?
$allow_error_suppressing Should PHPSandbox allow sandboxed code to suppress errors (e.g. the @ operator?)
$allow_escaping Should PHPSandbox allow sandboxed code to escape to HTML?
$allow_functions Should PHPSandbox allow sandboxed code to declare functions?
$allow_generators Should PHPSandbox allow sandboxed code to create generators?
$allow_globals Should PHPSandbox allow sandboxed code to use global keyword to access variables in the global scope?
$allow_halting Should PHPSandbox allow sandboxed code to halt the PHP compiler?
$allow_includes Flag to indicate whether the sandbox should allow included files
$allow_interfaces Should PHPSandbox allow sandboxed code to declare interfaces?
$allow_namespaces Should PHPSandbox allow sandboxed code to declare namespaces (utilizing the defineNamespace function?)
$allow_objects Should PHPSandbox allow sandboxed code to create objects of allow classes (e.g. new keyword)?
$allow_references Should PHPSandbox allow sandboxed code to assign references?
$allow_static_variables Should PHPSandbox allow sandboxed code to create static variables?
$allow_traits Should PHPSandbox allow sandboxed code to declare traits?
$allow_variables Should PHPSandbox allow sandboxed code to create variables?
$arg_funcs A static array of func_get_args, func_get_arg, and func_num_args used for redefining those functions
$auto_define_vars Should PHPSandbox automagically define variables passed to prepended, appended and prepared code closures?
$auto_whitelist_classes Should PHPSandbox automagically whitelist classes created in sandboxed code if $allow_classes is true?
$auto_whitelist_constants Should PHPSandbox automagically whitelist constants created in sandboxed code if $allow_constants is true?
$auto_whitelist_functions Should PHPSandbox automagically whitelist functions created in sandboxed code if $allow_functions is true?
$auto_whitelist_globals 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_interfaces Should PHPSandbox automagically whitelist interfaces created in sandboxed code if $allow_interfaces is true?
$auto_whitelist_traits Should PHPSandbox automagically whitelist traits created in sandboxed code if $allow_traits is true?
$auto_whitelist_trusted_code Should PHPSandbox automagically whitelist prepended and appended code?
$capture_output Flag whether to return output via an output buffer
$convert_errors Flag to indicate whether the sandbox should convert errors to exceptions
$defined_funcs A static array of defined_* and declared_* functions names used for redefining defined_* and declared_* values
$error_level 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.
$magic_constants A static array of magic constant names used for redefining magic constant values
$name The randomly generated name of the PHPSandbox variable passed to the generated closure
$overwrite_defined_funcs 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 Should PHPSandbox overwrite func_get_args, func_get_arg and func_num_args?
$overwrite_sandboxed_string_funcs Should PHPSandbox overwrite functions to help hide SandboxedStrings?
$overwrite_superglobals 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.
$restore_error_level Flag to indicate whether the sandbox should return error_reporting to its previous level after execution
$sandbox_includes Flag to indicate whether the sandbox should automatically sandbox included files
$sandboxed_string_funcs 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
$superglobals A static array of superglobal names used for redefining superglobal values
$time_limit Integer value of maximum number of seconds the sandbox should be allowed to execute
$validate_aliases Flag to indicate whether the sandbox should validate aliases (aka use)
$validate_classes Flag to indicate whether the sandbox should validate classes
$validate_constants Flag to indicate whether the sandbox should validate constants
$validate_functions Flag to indicate whether the sandbox should validate functions
$validate_globals Flag to indicate whether the sandbox should validate globals
$validate_interfaces Flag to indicate whether the sandbox should validate interfaces
$validate_keywords Flag to indicate whether the sandbox should validate keywords
$validate_magic_constants Flag to indicate whether the sandbox should validate magic constants
$validate_namespaces Flag to indicate whether the sandbox should validate namespaces
$validate_operators Flag to indicate whether the sandbox should validate operators
$validate_primitives Flag to indicate whether the sandbox should validate primitives
$validate_superglobals Flag to indicate whether the sandbox should validate superglobals
$validate_traits Flag to indicate whether the sandbox should validate traits
$validate_types Flag to indicate whether the sandbox should validate types
$validate_variables Flag to indicate whether the sandbox should validate variables

Protected Properties

Свойство Type Description
$appended_code String of appended code, will be automagically whitelisted for functions, variables, globals, constants, classes, interfaces and traits if $auto_whitelist_trusted_code is true
$blacklist Array of blacklisted functions, classes, etc. Any whitelisted array types override their counterpart in this array
$definitions Array of defined functions, superglobals, etc. If an array type contains elements, then it overwrites its external counterpart
$error_handler Callable that handles any errors when set
$error_handler_types Integer value of the error types to handle (default is E_ALL)
$exception_handler Callable that handles any thrown exceptions when set
$execution_time Float of the number of microseconds it took to execute the sandbox
$generated_code String of generated code, for debugging and serialization purposes
$includes Array of sandboxed included files
$last_error The last error thrown by the sandbox
$last_exception The last exception thrown by the sandbox
$last_validation_error The last validation error thrown by the sandbox
$memory_usage Int of the number of bytes the sandbox allocates during execution
$parsed_ast Array of parsed code broken down into AST tokens, for debugging and serialization purposes
$prepare_time Float of the number of microseconds it took to prepare the sandbox
$prepared_ast Array of prepared code broken down into AST tokens, for debugging and serialization purposes
$prepared_code String of prepared code, for debugging and serialization purposes
$preparsed_code String of preparsed code, for debugging and serialization purposes
$prepended_code String of prepended code, will be automagically whitelisted for functions, variables, globals, constants, classes, interfaces and traits if $auto_whitelist_trusted_code is true
$sandboxes Array of PHPSandboxes
$validation Array of custom validation functions
$validation_error_handler Callable that handles any thrown validation errors when set
$whitelist Array of whitelisted functions, classes, etc. If an array type contains elements, then it overrides its blacklist counterpart

Méthodes publiques

Méthode Description
__call ( string $method, array $arguments ) : mixed Magic method to provide API compatibility for v1.* code
__construct ( array $options = [], array $functions = [], array $variables = [], array $constants = [], array $namespaces = [], array $aliases = [], array $superglobals = [], array $magic_constants = [], array $classes = [], array $interfaces = [], array $traits = [] ) PHPSandbox class constructor
__invoke ( Closure | callable | string $code ) : mixed PHPSandbox __invoke magic method
__sleep ( ) : array PHPSandbox __sleep magic method
_arrayval ( mixed $value ) : array Return array value of SandboxedString or mixed value
_boolval ( mixed $value ) : boolean Return boolean value of SandboxedString or mixed value
_floatval ( mixed $value ) : float Return float value of SandboxedString or mixed value
_func_get_arg ( array $arguments = [], integer $index ) : array Get PHPSandbox redefined function argument
_func_get_args ( array $arguments = [] ) : array Get PHPSandbox redefined function arguments array
_func_num_args ( array $arguments = [] ) : integer Get PHPSandbox redefined number of function arguments
_get_declared_classes ( array $classes = [] ) : array Get PHPSandbox redefined classes in place of get_declared_classes(). This is an internal PHPSandbox function but requires public access to work.
_get_declared_interfaces ( array $interfaces = [] ) : array Get PHPSandbox redefined interfaces in place of get_declared_interfaces(). This is an internal PHPSandbox function but requires public access to work.
_get_declared_traits ( array $traits = [] ) : array Get PHPSandbox redefined traits in place of get_declared_traits(). This is an internal PHPSandbox function but requires public access to work.
_get_defined_constants ( array $constants = [] ) : array Get PHPSandbox redefined constants in place of get_defined_constants(). This is an internal PHPSandbox function but requires public access to work.
_get_defined_functions ( array $functions = [] ) : array Get PHPSandbox redefined functions in place of get_defined_functions(). This is an internal PHPSandbox function but requires public access to work.
_get_defined_vars ( array $variables = [] ) : array Get PHPSandbox redefined variables in place of get_defined_vars(). This is an internal PHPSandbox function but requires public access to work.
_get_included_files ( ) : array Return get_included_files() and sandboxed included files
_get_magic_const ( string $name ) : array Get PHPSandbox redefined magic constant. This is an internal PHPSandbox function but requires public access to work.
_get_superglobal ( string $name ) : array Get PHPSandbox redefined superglobal. This is an internal PHPSandbox function but requires public access to work.
_include ( string $file ) : mixed Sandbox included file
_include_once ( string $file ) : mixed Sandbox included once file
_intval ( mixed $value ) : integer Return integer value of SandboxedString or mixed value
_is_callable ( mixed $value ) : boolean Return is_callable value of SandboxedString or mixed value
_is_object ( mixed $value ) : boolean Return is_object value of SandboxedString or mixed value
_is_scalar ( mixed $value ) : boolean Return is_scalar value of SandboxedString or mixed value
_is_string ( mixed $value ) : boolean Return is_string value of SandboxedString or mixed value
_objectval ( mixed $value ) : object Return object value of SandboxedString or mixed value
_print_r ( ) : array Get PHPSandbox redefined print_r
_require ( string $file ) : mixed Sandbox required file
_require_once ( string $file ) : mixed Sandbox required once file
_var_dump ( ) : array Get PHPSandbox redefined var_dump
_var_export ( ) : array Get PHPSandbox redefined var_export
append ( string | callable $code ) Append trusted code
blacklist ( string | array $type, string | array | null $name = null ) Blacklist PHPSandbox definitions, such as functions, constants, classes, etc. to set
blacklistAlias ( string | array $name ) Blacklist alias
blacklistClass ( string | array $name ) Blacklist class
blacklistConst ( string | array $name ) Blacklist constant
blacklistFunc ( string | array $name ) Blacklist function
blacklistGlobal ( string | array $name ) Blacklist global
blacklistInterface ( string | array $name ) Blacklist interface
blacklistKeyword ( string | array $name ) Blacklist keyword
blacklistMagicConst ( string | array $name ) Blacklist magic constant
blacklistNamespace ( string | array $name ) Blacklist namespace
blacklistOperator ( string | array $name ) Blacklist operator
blacklistPrimitive ( string | array $name ) Blacklist primitive
blacklistSuperglobal ( string | array $name, string $key = null ) 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
blacklistTrait ( string | array $name ) Blacklist trait
blacklistType ( string | array $name ) Blacklist type
blacklistUse ( string | array $name ) Blacklist use (or alias)
blacklistVar ( string | array $name ) Blacklist variable
call_func ( ) : mixed Get PHPSandbox redefined function. This is an internal PHPSandbox function but requires public access to work.
checkAlias ( string $name ) : boolean Check alias name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
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.
checkConst ( string $name ) : boolean Check constant name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
checkFunc ( string $name ) : boolean Check function name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
checkGlobal ( string $name ) : boolean Check global name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
checkInterface ( string $name ) : boolean Check interface name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
checkKeyword ( string $name ) : boolean Check keyword name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
checkMagicConst ( string $name ) : boolean Check magic constant name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
checkNamespace ( string $name ) : boolean Check namespace name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
checkOperator ( string $name ) : boolean Check operator name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
checkPrimitive ( string $name ) : boolean Check primitive name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
checkSuperglobal ( string $name ) : boolean Check superglobal name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
checkTrait ( string $name ) : boolean Check trait name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
checkType ( string $name ) : boolean Check type name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
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.
checkVar ( string $name ) : boolean Check variable name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
clear ( ) Clear all trusted and sandboxed code
clearAppend ( ) Clear all appended trusted code
clearAppendedCode ( ) Clear all appended trusted code
clearCode ( ) Clear generated code
clearPrepended ( ) Clear all prepended trusted code
clearPrependedCode ( ) Clear all prepended trusted code
clearTrustedCode ( ) Clear all trusted code
create ( array $options = [], array $functions = [], array $variables = [], array $constants = [], array $namespaces = [], array $aliases = [], array $superglobals = [], array $magic_constants = [], array $classes = [], array $interfaces = [], array $traits = [] ) PHPSandbox static factory method
deblacklist ( string | array $type, string | array | null $name ) Remove PHPSandbox definitions, such as functions, constants, classes, etc. from blacklist
deblacklistAlias ( string | array $name ) Remove alias from blacklist
deblacklistClass ( string | array $name ) Remove class from blacklist
deblacklistConst ( string | array $name ) Remove constant from blacklist
deblacklistFunc ( string | array $name ) Remove function from blacklist
deblacklistGlobal ( string | array $name ) Remove global from blacklist
deblacklistInterface ( string | array $name ) Remove interface from blacklist
deblacklistKeyword ( string | array $name ) Remove keyword from blacklist
deblacklistMagicConst ( string | array $name ) Remove magic constant from blacklist
deblacklistNamespace ( string | array $name ) Remove namespace from blacklist
deblacklistOperator ( string | array $name ) Remove operator from blacklist
deblacklistPrimitive ( string | array $name ) Remove primitive from blacklist
deblacklistSuperglobal ( string | array $name, string $key = null ) 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
deblacklistTrait ( string | array $name ) Remove trait from blacklist
deblacklistType ( string | array $name ) Remove type from blacklist
deblacklistUse ( string | array $name ) Remove use (or alias) from blacklist
deblacklistVar ( string | array $name ) Remove function from blacklist
define ( string | array $type, string | array | null $name = null, mixed | null $value = null ) Define PHPSandbox definitions, such as functions, constants, namespaces, etc.
defineAlias ( string | array $name, string | null $alias = null ) Define PHPSandbox alias
defineAliases ( array $aliases = [] ) Define PHPSandbox aliases by array
defineClass ( string | array $name, mixed $value ) Define PHPSandbox class
defineClasses ( array $classes = [] ) Define PHPSandbox classes by array
defineConst ( string | array $name, mixed $value ) Define PHPSandbox constant
defineConsts ( array $constants = [] ) Define PHPSandbox constants by array
defineFunc ( string | array $name, callable $function, boolean $pass_sandbox = false ) Define PHPSandbox function
defineFuncs ( array $functions = [] ) Define PHPSandbox functions by array
defineInterface ( string | array $name, mixed $value ) Define PHPSandbox interface
defineInterfaces ( array $interfaces = [] ) Define PHPSandbox interfaces by array
defineMagicConst ( string | array $name, mixed $value ) Define PHPSandbox magic constant
defineMagicConsts ( array $magic_constants = [] ) Define PHPSandbox magic constants by array
defineNamespace ( string | array $name ) Define PHPSandbox namespace
defineNamespaces ( array $namespaces = [] ) Define PHPSandbox namespaces by array
defineSuperglobal ( string | array $name, mixed $value ) Define PHPSandbox superglobal
defineSuperglobals ( array $superglobals = [] ) Define PHPSandbox superglobals by array
defineTrait ( string | array $name, mixed $value ) Define PHPSandbox trait
defineTraits ( array $traits = [] ) Define PHPSandbox traits by array
defineUse ( string | array $name, string | null $alias = null ) Define PHPSandbox use (or alias)
defineUses ( array $uses = [] ) Define PHPSandbox uses (or aliases) by array
defineVar ( string | array $name, mixed $value ) Define PHPSandbox variable
defineVars ( array $variables = [] ) Define PHPSandbox variables by array
dewhitelist ( string | array $type, string | array | null $name ) Remove PHPSandbox definitions, such as functions, constants, classes, etc. from whitelist
dewhitelistAlias ( string | array $name ) Remove alias from whitelist
dewhitelistClass ( string | array $name ) Remove class from whitelist
dewhitelistConst ( string | array $name ) Remove constant from whitelist
dewhitelistFunc ( string | array $name ) Remove function from whitelist
dewhitelistGlobal ( string | array $name ) Remove global from whitelist
dewhitelistInterface ( string | array $name ) Remove interface from whitelist
dewhitelistKeyword ( string | array $name ) Remove keyword from whitelist
dewhitelistMagicConst ( string | array $name ) Remove magic constant from whitelist
dewhitelistNamespace ( string | array $name ) Remove namespace from whitelist
dewhitelistOperator ( string | array $name ) Remove operator from whitelist
dewhitelistPrimitive ( string | array $name ) Remove primitive from whitelist
dewhitelistSuperglobal ( string | array $name, string $key = null ) 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
dewhitelistTrait ( string | array $name ) Remove trait from whitelist
dewhitelistType ( string | array $name ) Remove type from whitelist
dewhitelistUse ( string | array $name ) Remove use (or alias) from whitelist
dewhitelistVar ( string | array $name ) Remove variable from whitelist
error ( integer $errno, string $errstr, string $errfile, integer $errline, array $errcontext ) : mixed Invoke sandbox error handler
exception ( Exception $exception ) : mixed Invoke sandbox exception handler
execute ( callable | string $callable = null, boolean $skip_validation = false ) : mixed Prepare and execute callable and return output
getAliasValidator ( ) : callable | null Get validation callable for aliases
getAppendedCode ( ) : string Get PHPSandbox appended code
getClassValidator ( ) : callable | null Get validation callable for classes
getCode ( ) : string Get PHPSandbox generated code
getConstValidator ( ) : callable | null Get validation callable for constants
getDefinedClass ( string $name ) : string Get defined class of $name
getDefinedInterface ( string $name ) : string Get defined interface of $name
getDefinedNamespace ( string $name ) : string Get defined namespace of $name
getDefinedTrait ( string $name ) : string Get defined trait of $name
getErrorHandler ( ) : null | callable Get error handler
getExceptionHandler ( ) : null | callable Get exception handler
getExecutionTime ( integer | null $round ) : float Return the amount of time the sandbox spent executing the sandboxed code
getFuncValidator ( ) : callable | null Get validation for functions
getGeneratedCode ( ) : string Get PHPSandbox generated code
getGlobalValidator ( ) : callable | null Get validation callable for globals
getInterfaceValidator ( ) : callable | null Get validation callable for interfaces
getIterator ( ) : array Get an iterator of all the public PHPSandbox properties
getKeywordValidator ( ) : callable | null Get validation callable for keywords
getLastError ( ) : array Gets the last sandbox error
getLastException ( ) : Exception | Error Gets the last exception thrown by the sandbox
getLastValidationError ( ) : Exception | Error Gets the last validation error thrown by the sandbox
getMagicConstValidator ( ) : callable | null Get validation callable for magic constants
getMemoryUsage ( integer | null $round ) : integer Return the amount of bytes the sandbox allocated while preparing and executing the sandboxed code
getName ( ) : string Get name of PHPSandbox variable
getNamespaceValidator ( ) : callable | null Get validation callable for namespaces
getOperatorValidator ( ) : callable | null Get validation callable for operators
getOption ( string $option ) : boolean | integer | null Get PHPSandbox option
getParsedAST ( ) : array Get PHPSandbox parsed AST array
getPreparedAST ( ) : array Get PHPSandbox prepared AST array
getPreparedCode ( ) : string Get PHPSandbox prepared code
getPreparedTime ( integer | null $round ) : float Return the amount of time the sandbox spent preparing the sandboxed code
getPreparsedCode ( ) : string Get PHPSandbox preparsed code
getPrependedCode ( ) : string Get PHPSandbox prepended code
getPrimitiveValidator ( ) : callable | null Get validation callable for primitives
getSandbox ( string $name ) : null | PHPSandbox Get a named PHPSandbox instance (used to retrieve the sandbox instance from within sandboxed code)
getSuperglobalValidator ( ) : callable | null Get validation callable for superglobals
getTime ( integer | null $round ) : float Return the amount of time the sandbox spent preparing and executing the sandboxed code
getTraitValidator ( ) : callable | null Get validation callable for traits
getTypeValidator ( ) : callable | null Get validation callable for types
getUseValidator ( ) : callable | null Get validation callable for uses (aka aliases)
getValidationErrorHandler ( ) : null | callable Get validation error handler
getValidator ( string $type ) : callable | null Get validation callable for specified $type
getVarValidator ( ) : callable | null Get validation callable for variables
hasBlacklist ( string $type ) : integer Query whether PHPSandbox instance has blacklist type.
hasBlacklistedAliases ( ) : integer Query whether PHPSandbox instance has blacklisted aliases.
hasBlacklistedClasses ( ) : integer Query whether PHPSandbox instance has blacklisted classes.
hasBlacklistedConsts ( ) : integer Query whether PHPSandbox instance has blacklisted constants.
hasBlacklistedFuncs ( ) : integer Query whether PHPSandbox instance has blacklisted functions.
hasBlacklistedGlobals ( ) : integer Query whether PHPSandbox instance has blacklisted globals.
hasBlacklistedInterfaces ( ) : integer Query whether PHPSandbox instance has blacklisted interfaces.
hasBlacklistedKeywords ( ) : integer Query whether PHPSandbox instance has blacklisted keywords.
hasBlacklistedMagicConsts ( ) : integer Query whether PHPSandbox instance has blacklisted magic constants.
hasBlacklistedNamespaces ( ) : integer Query whether PHPSandbox instance has blacklisted namespaces.
hasBlacklistedOperators ( ) : integer Query whether PHPSandbox instance has blacklisted operators.
hasBlacklistedPrimitives ( ) : integer Query whether PHPSandbox instance has blacklisted primitives.
hasBlacklistedSuperglobals ( string $name = null ) : integer Query whether PHPSandbox instance has blacklisted superglobals, or superglobal keys
hasBlacklistedTraits ( ) : integer Query whether PHPSandbox instance has blacklisted traits.
hasBlacklistedTypes ( ) : integer Query whether PHPSandbox instance has blacklisted types.
hasBlacklistedUses ( ) : integer Query whether PHPSandbox instance has blacklisted uses (or aliases.)
hasBlacklistedVars ( ) : integer Query whether PHPSandbox instance has blacklisted variables.
hasDefinedAliases ( ) : integer Query whether PHPSandbox instance has defined aliases
hasDefinedClasses ( ) : integer Query whether PHPSandbox instance has defined classes
hasDefinedConsts ( ) : integer Query whether PHPSandbox instance has defined constants
hasDefinedFuncs ( ) : integer Query whether PHPSandbox instance has defined functions
hasDefinedInterfaces ( ) : integer Query whether PHPSandbox instance has defined interfaces
hasDefinedMagicConsts ( ) : integer Query whether PHPSandbox instance has defined magic constants
hasDefinedNamespaces ( ) : integer Query whether PHPSandbox instance has defined namespaces
hasDefinedSuperglobals ( string | null $name = null ) : integer | boolean Query whether PHPSandbox instance has defined superglobals, or if superglobal $name has defined keys
hasDefinedTraits ( ) : integer Query whether PHPSandbox instance has defined traits
hasDefinedUses ( ) : integer Query whether PHPSandbox instance has defined uses (or aliases)
hasDefinedVars ( ) : integer Query whether PHPSandbox instance has defined variables
hasWhitelist ( string $type ) : integer Query whether PHPSandbox instance has whitelist type
hasWhitelistKeywords ( ) : integer Query whether PHPSandbox instance has whitelisted keywords.
hasWhitelistedAliases ( ) : integer Query whether PHPSandbox instance has whitelisted aliases.
hasWhitelistedClasses ( ) : integer Query whether PHPSandbox instance has whitelisted classes.
hasWhitelistedConsts ( ) : integer Query whether PHPSandbox instance has whitelisted constants.
hasWhitelistedFuncs ( ) : integer Query whether PHPSandbox instance has whitelisted functions.
hasWhitelistedGlobals ( ) : integer Query whether PHPSandbox instance has whitelisted globals.
hasWhitelistedInterfaces ( ) : integer Query whether PHPSandbox instance has whitelisted interfaces.
hasWhitelistedMagicConsts ( ) : integer Query whether PHPSandbox instance has whitelisted magic constants.
hasWhitelistedNamespaces ( ) : integer Query whether PHPSandbox instance has whitelisted namespaces.
hasWhitelistedOperators ( ) : integer Query whether PHPSandbox instance has whitelisted operators.
hasWhitelistedPrimitives ( ) : integer Query whether PHPSandbox instance has whitelisted primitives.
hasWhitelistedSuperglobals ( string $name = null ) : integer Query whether PHPSandbox instance has whitelisted superglobals, or superglobal keys
hasWhitelistedTraits ( ) : integer Query whether PHPSandbox instance has whitelisted traits.
hasWhitelistedTypes ( ) : integer Query whether PHPSandbox instance has whitelisted types.
hasWhitelistedUses ( ) : integer Query whether PHPSandbox instance has whitelisted uses (or aliases.)
hasWhitelistedVars ( ) : integer Query whether PHPSandbox instance has whitelisted variables.
import ( array | string $template, integer $import_flag ) PHPSandbox __wakeup magic method
importJSON ( array | string $template, integer $import_flag ) Import JSON template into sandbox
isBlacklisted ( string $type, string $name ) : boolean Check if PHPSandbox instance has blacklist type and name set
isBlacklistedAlias ( string $name ) : boolean Check if PHPSandbox instance has blacklisted alias name set
isBlacklistedClass ( string $name ) : boolean Check if PHPSandbox instance has blacklisted class name set
isBlacklistedConst ( string $name ) : boolean Check if PHPSandbox instance has blacklisted constant name set
isBlacklistedFunc ( string $name ) : boolean Check if PHPSandbox instance has blacklisted function name set
isBlacklistedGlobal ( string $name ) : boolean Check if PHPSandbox instance has blacklisted global name set
isBlacklistedInterface ( string $name ) : boolean Check if PHPSandbox instance has blacklisted interface name set
isBlacklistedKeyword ( string $name ) : boolean Check if PHPSandbox instance has blacklisted keyword name set
isBlacklistedMagicConst ( string $name ) : boolean Check if PHPSandbox instance has blacklisted magic constant name set
isBlacklistedNamespace ( string $name ) : boolean Check if PHPSandbox instance has blacklisted namespace name set
isBlacklistedOperator ( string $name ) : boolean Check if PHPSandbox instance has blacklisted operator name set
isBlacklistedPrimitive ( string $name ) : boolean Check if PHPSandbox instance has blacklisted primitive name set
isBlacklistedSuperglobal ( string $name, string $key = null ) : boolean Check if PHPSandbox instance has blacklisted superglobal or superglobal key set
isBlacklistedTrait ( string $name ) : boolean Check if PHPSandbox instance has blacklisted trait name set
isBlacklistedType ( string $name ) : boolean Check if PHPSandbox instance has blacklisted type name set
isBlacklistedUse ( string $name ) : boolean Check if PHPSandbox instance has blacklisted use (or alias) name set
isBlacklistedVar ( string $name ) : boolean Check if PHPSandbox instance has blacklisted variable name set
isDefinedAlias ( string $name ) : boolean Check if PHPSandbox instance has $name alias defined
isDefinedClass ( string $name ) : boolean Check if PHPSandbox instance has $name class defined
isDefinedConst ( string $name ) : boolean Check if PHPSandbox instance has $name constant defined
isDefinedFunc ( string $name ) : boolean Check if PHPSandbox instance has $name function defined
isDefinedInterface ( string $name ) : boolean Check if PHPSandbox instance has $name interface defined
isDefinedMagicConst ( string $name ) : boolean Check if PHPSandbox instance has $name magic constant defined
isDefinedNamespace ( string $name ) : boolean Check if PHPSandbox instance has $name namespace defined
isDefinedSuperglobal ( string $name, string | null $key = null ) : boolean Check if PHPSandbox instance has $name superglobal defined, or if superglobal $name key is defined
isDefinedTrait ( string $name ) : boolean Check if PHPSandbox instance has $name trait defined
isDefinedUse ( string $name ) : boolean Check if PHPSandbox instance has $name uses (or alias) defined
isDefinedVar ( string $name ) : boolean Check if PHPSandbox instance has $name variable defined
isWhitelisted ( string $type, string $name ) : boolean Check if PHPSandbox instance has whitelist type and name set
isWhitelistedAlias ( string $name ) : boolean Check if PHPSandbox instance has whitelisted alias name set
isWhitelistedClass ( string $name ) : boolean Check if PHPSandbox instance has whitelisted class name set
isWhitelistedConst ( string $name ) : boolean Check if PHPSandbox instance has whitelisted constant name set
isWhitelistedFunc ( string $name ) : boolean Check if PHPSandbox instance has whitelisted function name set
isWhitelistedGlobal ( string $name ) : boolean Check if PHPSandbox instance has whitelisted global name set
isWhitelistedInterface ( string $name ) : boolean Check if PHPSandbox instance has whitelisted interface name set
isWhitelistedKeyword ( string $name ) : boolean Check if PHPSandbox instance has whitelisted keyword name set
isWhitelistedMagicConst ( string $name ) : boolean Check if PHPSandbox instance has whitelisted magic constant name set
isWhitelistedNamespace ( string $name ) : boolean Check if PHPSandbox instance has whitelisted namespace name set
isWhitelistedOperator ( string $name ) : boolean Check if PHPSandbox instance has whitelisted operator name set
isWhitelistedPrimitive ( string $name ) : boolean Check if PHPSandbox instance has whitelisted primitive name set
isWhitelistedSuperglobal ( string $name, string $key = null ) : boolean Check if PHPSandbox instance has whitelisted superglobal or superglobal key set
isWhitelistedTrait ( string $name ) : boolean Check if PHPSandbox instance has whitelisted trait name set
isWhitelistedType ( string $name ) : boolean Check if PHPSandbox instance has whitelisted type name set
isWhitelistedUse ( string $name ) : boolean Check if PHPSandbox instance has whitelisted use (or alias) name set
isWhitelistedVar ( string $name ) : boolean Check if PHPSandbox instance has whitelisted variable name set
prepare ( callable $code, boolean $skip_validation = false ) : string Prepare passed callable for execution
prepend ( string | callable $code ) Prepend trusted code
resetOptions ( ) Reset PHPSandbox options to their default values
setAliasValidator ( callable $callable ) : PHPSandbox Set validation callable for aliases
setAppendedCode ( string $appended_code = '' ) Set PHPSandbox appended code
setClassValidator ( callable $callable ) : PHPSandbox Set validation callable for classes
setCode ( string $generated_code = '' ) Set PHPSandbox generated code
setConstValidator ( callable $callable ) : PHPSandbox Set validation callable for constants
setErrorHandler ( callable $handler, integer $error_types = E_ALL ) Set callable to handle errors
setExceptionHandler ( callable $handler ) Set callable to handle thrown exceptions
setFuncValidator ( callable $callable ) : PHPSandbox Set validation callable for functions
setGeneratedCode ( string $generated_code = '' ) Set PHPSandbox generated code
setGlobalValidator ( callable $callable ) : PHPSandbox Set validation callable for globals
setInterfaceValidator ( callable $callable ) : PHPSandbox Set validation callable for interfaces
setKeywordValidator ( callable $callable ) : PHPSandbox Set validation callable for keywords
setMagicConstValidator ( callable $callable ) : PHPSandbox Set validation callable for magic constants
setNamespaceValidator ( callable $callable ) : PHPSandbox Set validation callable for namespaces
setOperatorValidator ( callable $callable ) : PHPSandbox Set validation callable for operators
setOption ( string | array $option, boolean | integer | null $value = null ) Set PHPSandbox option
setOptions ( array | string $options, boolean | integer | null $value = null ) Set PHPSandbox options by array
setParsedAST ( array $parsed_ast = [] ) Set PHPSandbox parsed AST array
setPreparedAST ( array $prepared_ast = [] ) Set PHPSandbox prepared AST array
setPreparedCode ( string $prepared_code = '' ) Set PHPSandbox prepared code
setPreparsedCode ( string $preparsed_code = '' ) Set PHPSandbox preparsed code
setPrependedCode ( string $prepended_code = '' ) Set PHPSandbox prepended code
setPrimitiveValidator ( callable $callable ) : PHPSandbox Set validation callable for primitives
setSuperglobalValidator ( callable $callable ) : PHPSandbox Set validation callable for superglobals
setTraitValidator ( callable $callable ) : PHPSandbox Set validation callable for traits
setTypeValidator ( callable $callable ) : PHPSandbox Set validation callable for types
setUseValidator ( callable $callable ) : PHPSandbox Set validation callable for uses (aka aliases)
setValidationErrorHandler ( callable $handler ) Set callable to handle thrown validation Errors
setValidator ( string $type, callable $callable ) : PHPSandbox Set validation callable for specified $type
setVarValidator ( callable $callable ) : PHPSandbox Set validation callable for variables
undefine ( string | array $type, string | array $name = null ) Undefine PHPSandbox definitions, such as functions, constants, namespaces, etc.
undefineAlias ( string | array $name ) Undefine PHPSandbox alias
undefineAliases ( array $aliases = [] ) Undefine PHPSandbox aliases by array
undefineClass ( string | array $name ) Undefine PHPSandbox class
undefineClasses ( array $classes = [] ) Undefine PHPSandbox classes by array
undefineConst ( string | array $name ) Undefine PHPSandbox constant
undefineConsts ( array $constants = [] ) Undefine PHPSandbox constants by array
undefineFunc ( string | array $name ) Undefine PHPSandbox function
undefineFuncs ( array $functions = [] ) Undefine PHPSandbox functions by array
undefineInterface ( string | array $name ) Undefine PHPSandbox interface
undefineInterfaces ( array $interfaces = [] ) Undefine PHPSandbox interfaces by array
undefineMagicConst ( string | array $name ) Undefine PHPSandbox magic constant
undefineMagicConsts ( array $magic_constants = [] ) Undefine PHPSandbox magic constants by array
undefineNamespace ( string | array $name ) Undefine PHPSandbox namespace
undefineNamespaces ( array $namespaces = [] ) Undefine PHPSandbox namespaces by array
undefineSuperglobal ( string | array $name, string | null $key = null ) Undefine PHPSandbox superglobal or superglobal key
undefineSuperglobals ( array $superglobals = [] ) Undefine PHPSandbox superglobals by array
undefineTrait ( string | array $name ) Undefine PHPSandbox trait
undefineTraits ( array $traits = [] ) Undefine PHPSandbox traits by array
undefineUse ( string | array $name ) Undefine PHPSandbox use (or alias)
undefineUses ( array $uses = [] ) Undefine PHPSandbox uses (or aliases) by array
undefineVar ( string | array $name ) Undefine PHPSandbox variable
undefineVars ( array $variables = [] ) Undefine PHPSandbox variables by array
unsetAliasValidator ( ) : PHPSandbox Unset validation callable for aliases
unsetClassValidator ( ) : PHPSandbox Unset validation callable for classes
unsetConstValidator ( ) : PHPSandbox Unset validation callable for constants
unsetErrorHandler ( ) Unset error handler
unsetExceptionHandler ( ) Unset exception handler
unsetFuncValidator ( ) : PHPSandbox Unset validation callable for functions
unsetGlobalValidator ( ) : PHPSandbox Unset validation callable for globals
unsetInterfaceValidator ( ) : PHPSandbox Unset validation callable for interfaces
unsetKeywordValidator ( ) : PHPSandbox Unset validation callable for keywords
unsetMagicConstValidator ( ) : PHPSandbox Unset validation callable for magic constants
unsetNamespaceValidator ( ) : PHPSandbox Unset validation callable for namespaces
unsetOperatorValidator ( ) : PHPSandbox Unset validation callable for operators
unsetPrimitiveValidator ( ) : PHPSandbox Unset validation callable for primitives
unsetSuperglobalValidator ( ) : PHPSandbox Unset validation callable for superglobals
unsetTraitValidator ( ) : PHPSandbox Unset validation callable for traits
unsetTypeValidator ( ) Unset validation callable for types
unsetUseValidator ( ) : PHPSandbox Unset validation callable for uses (aka aliases)
unsetValidationErrorHandler ( ) Unset validation error handler
unsetValidator ( string $type ) : PHPSandbox Unset validation callable for specified $type
unsetVarValidator ( ) : PHPSandbox Unset validation callable for variables
validate ( callable | string $code ) Validate passed callable for execution
validationError ( Exception | Error | string $error, integer $code, PhpParser\Node $node = null, mixed $data = null, Exception $previous = null ) : mixed Invoke sandbox error validation handler if it exists, throw Error otherwise
whitelist ( string | array $type, string | array | null $name = null ) Whitelist PHPSandbox definitions, such as functions, constants, classes, etc. to set
whitelistAlias ( string | array $name ) Whitelist alias
whitelistClass ( string | array $name ) Whitelist class
whitelistConst ( string | array $name ) Whitelist constant
whitelistFunc ( string | array $name ) Whitelist function
whitelistGlobal ( string | array $name ) Whitelist global
whitelistInterface ( string | array $name ) Whitelist interface
whitelistKeyword ( string | array $name ) Whitelist keyword
whitelistMagicConst ( string | array $name ) Whitelist magic constant
whitelistNamespace ( string | array $name ) Whitelist namespace
whitelistOperator ( string | array $name ) Whitelist operator
whitelistPrimitive ( string | array $name ) Whitelist primitive
whitelistSuperglobal ( string | array $name, string $key = null ) Whitelist superglobal or superglobal key
whitelistTrait ( string | array $name ) Whitelist trait
whitelistType ( string | array $name ) Whitelist type
whitelistUse ( string | array $name ) Whitelist use (or alias)
whitelistVar ( string | array $name ) Whitelist variable

Méthodes protégées

Méthode Description
autoDefine ( FunctionParser\FunctionParser $disassembled_closure ) Automatically define variables passed to disassembled closure
autoWhitelist ( string $code, boolean $appended = false ) : mixed Automatically whitelisted trusted code
disassemble ( callable $closure ) : string Disassemble callable to string
normalizeAlias ( string | array $name ) : string | array Normalize alias name. This is an internal PHPSandbox function.
normalizeClass ( string | array $name ) : string | array Normalize class name. This is an internal PHPSandbox function.
normalizeFunc ( string | array $name ) : string | array Normalize function name. This is an internal PHPSandbox function.
normalizeInterface ( string | array $name ) : string | array Normalize interface name. This is an internal PHPSandbox function.
normalizeKeyword ( string | array $name ) : string | array Normalize keyword name. This is an internal PHPSandbox function.
normalizeMagicConst ( string | array $name ) : string | array Normalize magic constant name. This is an internal PHPSandbox function.
normalizeNamespace ( string | array $name ) : string | array Normalize namespace name. This is an internal PHPSandbox function.
normalizeOperator ( string | array $name ) : string | array Normalize operator name. This is an internal PHPSandbox function.
normalizePrimitive ( string | array $name ) : string | array Normalize primitive name. This is an internal PHPSandbox function.
normalizeSuperglobal ( string | array $name ) : string | array Normalize superglobal name. This is an internal PHPSandbox function.
normalizeTrait ( string | array $name ) : string | array Normalize trait name. This is an internal PHPSandbox function.
normalizeType ( string | array $name ) : string | array Normalize type name. This is an internal PHPSandbox function.
normalizeUse ( string | array $name ) : string | array Normalize use (or alias) name. This is an internal PHPSandbox function.
prepareAliases ( ) Prepare defined aliases for execution
prepareConsts ( ) Prepare defined constants for execution
prepareNamespaces ( ) Prepare defined namespaces for execution
prepareUses ( ) Prepare defined uses (or aliases) for execution
prepareVars ( ) : string Prepare defined variables for execution

Method Details

__call() public méthode

Magic method to provide API compatibility for v1.* code
public __call ( string $method, array $arguments ) : mixed
$method string The method name to call
$arguments array The method arguments to call
Résultat mixed

__construct() public méthode

You can pass optional arrays of predefined functions, variables, etc. to the sandbox through the constructor
public __construct ( array $options = [], array $functions = [], array $variables = [], array $constants = [], array $namespaces = [], array $aliases = [], array $superglobals = [], array $magic_constants = [], array $classes = [], array $interfaces = [], array $traits = [] )
$options array Optional array of options to set for the sandbox
$functions array Optional array of functions to define for the sandbox
$variables array Optional array of variables to define for the sandbox
$constants array Optional array of constants to define for the sandbox
$namespaces array Optional array of namespaces to define for the sandbox
$aliases array Optional array of aliases to define for the sandbox
$superglobals array Optional array of superglobals to define for the sandbox
$magic_constants array Optional array of magic constants to define for the sandbox
$classes array Optional array of classes to define for the sandbox
$interfaces array Optional array of interfaces to define for the sandbox
$traits array Optional array of traits to define for the sandbox

__invoke() public méthode

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
public __invoke ( Closure | callable | string $code ) : mixed
$code Closure | callable | string The closure, callable or string of code to execute
Résultat mixed The output of the executed sandboxed code

__sleep() public méthode

PHPSandbox __sleep magic method
public __sleep ( ) : array
Résultat array An array of property keys to be serialized

_arrayval() public méthode

Return array value of SandboxedString or mixed value
public _arrayval ( mixed $value ) : array
$value mixed Value to return as array
Résultat array Returns the array value

_boolval() public méthode

Return boolean value of SandboxedString or mixed value
public _boolval ( mixed $value ) : boolean
$value mixed Value to return as boolean
Résultat boolean Returns the boolean value

_floatval() public méthode

Return float value of SandboxedString or mixed value
public _floatval ( mixed $value ) : float
$value mixed Value to return as float
Résultat float Returns the float value

_func_get_arg() public méthode

Get PHPSandbox redefined function argument
public _func_get_arg ( array $arguments = [], integer $index ) : array
$arguments array Array result from func_get_args() is passed here
$index integer Requested func_get_arg index is passed here
Résultat array Returns the redefined argument

_func_get_args() public méthode

Get PHPSandbox redefined function arguments array
public _func_get_args ( array $arguments = [] ) : array
$arguments array Array result from func_get_args() is passed here
Résultat array Returns the redefined arguments array

_func_num_args() public méthode

Get PHPSandbox redefined number of function arguments
public _func_num_args ( array $arguments = [] ) : integer
$arguments array Array result from func_get_args() is passed here
Résultat integer Returns the redefined number of function arguments

_get_declared_classes() public méthode

Get PHPSandbox redefined classes in place of get_declared_classes(). This is an internal PHPSandbox function but requires public access to work.
public _get_declared_classes ( array $classes = [] ) : array
$classes array Array result from get_declared_classes() is passed here
Résultat array Returns the redefined classes

_get_declared_interfaces() public méthode

Get PHPSandbox redefined interfaces in place of get_declared_interfaces(). This is an internal PHPSandbox function but requires public access to work.
public _get_declared_interfaces ( array $interfaces = [] ) : array
$interfaces array Array result from get_declared_interfaces() is passed here
Résultat array Returns the redefined interfaces

_get_declared_traits() public méthode

Get PHPSandbox redefined traits in place of get_declared_traits(). This is an internal PHPSandbox function but requires public access to work.
public _get_declared_traits ( array $traits = [] ) : array
$traits array Array result from get_declared_traits() is passed here
Résultat array Returns the redefined traits

_get_defined_constants() public méthode

Get PHPSandbox redefined constants in place of get_defined_constants(). This is an internal PHPSandbox function but requires public access to work.
public _get_defined_constants ( array $constants = [] ) : array
$constants array Array result from get_defined_constants() is passed here
Résultat array Returns the redefined constants

_get_defined_functions() public méthode

Get PHPSandbox redefined functions in place of get_defined_functions(). This is an internal PHPSandbox function but requires public access to work.
public _get_defined_functions ( array $functions = [] ) : array
$functions array Array result from get_defined_functions() is passed here
Résultat array Returns the redefined functions array

_get_defined_vars() public méthode

Get PHPSandbox redefined variables in place of get_defined_vars(). This is an internal PHPSandbox function but requires public access to work.
public _get_defined_vars ( array $variables = [] ) : array
$variables array Array result from get_defined_vars() is passed here
Résultat array Returns the redefined variables array

_get_included_files() public méthode

Return get_included_files() and sandboxed included files
public _get_included_files ( ) : array
Résultat array Returns array of get_included_files() and sandboxed included files

_get_magic_const() public méthode

Get PHPSandbox redefined magic constant. This is an internal PHPSandbox function but requires public access to work.
public _get_magic_const ( string $name ) : array
$name string Requested magic constant name (e.g. __FILE__, __LINE__, etc.)
Résultat array Returns the redefined magic constant

_get_superglobal() public méthode

Get PHPSandbox redefined superglobal. This is an internal PHPSandbox function but requires public access to work.
public _get_superglobal ( string $name ) : array
$name string Requested superglobal name (e.g. _GET, _POST, etc.)
Résultat array Returns the redefined superglobal

_include() public méthode

Sandbox included file
public _include ( string $file ) : mixed
$file string Included file to sandbox
Résultat mixed Returns value passed from included file

_include_once() public méthode

Sandbox included once file
public _include_once ( string $file ) : mixed
$file string Included once file to sandbox
Résultat mixed Returns value passed from included once file

_intval() public méthode

Return integer value of SandboxedString or mixed value
public _intval ( mixed $value ) : integer
$value mixed Value to return as integer
Résultat integer Returns the integer value

_is_callable() public méthode

Return is_callable value of SandboxedString or mixed value
public _is_callable ( mixed $value ) : boolean
$value mixed Value to check if is_callable
Résultat boolean Returns the is_callable value

_is_object() public méthode

Return is_object value of SandboxedString or mixed value
public _is_object ( mixed $value ) : boolean
$value mixed Value to check if is_object
Résultat boolean Returns the is_object value

_is_scalar() public méthode

Return is_scalar value of SandboxedString or mixed value
public _is_scalar ( mixed $value ) : boolean
$value mixed Value to check if is_scalar
Résultat boolean Returns the is_scalar value

_is_string() public méthode

Return is_string value of SandboxedString or mixed value
public _is_string ( mixed $value ) : boolean
$value mixed Value to check if is_string
Résultat boolean Returns the is_string value

_objectval() public méthode

Return object value of SandboxedString or mixed value
public _objectval ( mixed $value ) : object
$value mixed Value to return as object
Résultat object Returns the object value

_print_r() public méthode

Get PHPSandbox redefined print_r
public _print_r ( ) : array
Résultat array Returns the redefined print_r

_require() public méthode

Sandbox required file
public _require ( string $file ) : mixed
$file string Required file to sandbox
Résultat mixed Returns value passed from required file

_require_once() public méthode

Sandbox required once file
public _require_once ( string $file ) : mixed
$file string Required once file to sandbox
Résultat mixed Returns value passed from required once file

_var_dump() public méthode

Get PHPSandbox redefined var_dump
public _var_dump ( ) : array
Résultat array Returns the redefined var_dump

_var_export() public méthode

Get PHPSandbox redefined var_export
public _var_export ( ) : array
Résultat array Returns the redefined var_export

append() public méthode

Append trusted code
public append ( string | callable $code )
$code string | callable String or callable of trusted $code to append to generated code

autoDefine() protected méthode

Automatically define variables passed to disassembled closure
protected autoDefine ( FunctionParser\FunctionParser $disassembled_closure )
$disassembled_closure FunctionParser\FunctionParser

autoWhitelist() protected méthode

Automatically whitelisted trusted code
protected autoWhitelist ( string $code, boolean $appended = false ) : mixed
$code string String of trusted $code to automatically whitelist
$appended boolean Flag if this code ir prended or appended (true = appended)
Résultat mixed Return result of error handler if $code could not be parsed

blacklist() public méthode

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
public blacklist ( string | array $type, string | array | null $name = null )
$type string | array Associative array or string of blacklist type to set
$name string | array | null Array or string of blacklist name to set

blacklistAlias() public méthode

You can pass a string of alias name, or pass an array of the alias names to blacklist
public blacklistAlias ( string | array $name )
$name string | array String of alias name or array of alias names to blacklist

blacklistClass() public méthode

You can pass a string of class name, or pass an array of the class names to blacklist
public blacklistClass ( string | array $name )
$name string | array String of class name or array of class names to blacklist

blacklistConst() public méthode

You can pass a string of constant name, or pass an array of the constant names to blacklist
public blacklistConst ( string | array $name )
$name string | array String of constant name or array of constant names to blacklist

blacklistFunc() public méthode

You can pass a string of the function name, or pass an array of function names to blacklist
public blacklistFunc ( string | array $name )
$name string | array String of function name, or array of function names to blacklist

blacklistGlobal() public méthode

You can pass a string of global name, or pass an array of the global names to blacklist
public blacklistGlobal ( string | array $name )
$name string | array String of global name or array of global names to blacklist

blacklistInterface() public méthode

You can pass a string of interface name, or pass an array of the interface names to blacklist
public blacklistInterface ( string | array $name )
$name string | array String of interface name or array of interface names to blacklist

blacklistKeyword() public méthode

You can pass a string of keyword name, or pass an array of the keyword names to blacklist
public blacklistKeyword ( string | array $name )
$name string | array String of keyword name or array of keyword names to blacklist

blacklistMagicConst() public méthode

You can pass a string of magic constant name, or pass an array of the magic constant names to blacklist
public blacklistMagicConst ( string | array $name )
$name string | array String of magic constant name or array of magic constant names to blacklist

blacklistNamespace() public méthode

You can pass a string of namespace name, or pass an array of the namespace names to blacklist
public blacklistNamespace ( string | array $name )
$name string | array String of namespace name or array of namespace names to blacklist

blacklistOperator() public méthode

You can pass a string of operator name, or pass an array of the operator names to blacklist
public blacklistOperator ( string | array $name )
$name string | array String of operator name or array of operator names to blacklist

blacklistPrimitive() public méthode

You can pass a string of primitive name, or pass an array of the primitive names to blacklist
public blacklistPrimitive ( string | array $name )
$name string | array String of primitive name or array of primitive names to blacklist

blacklistSuperglobal() public méthode

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
public blacklistSuperglobal ( string | array $name, string $key = null )
$name string | array String of superglobal name, or an array of superglobal names, or an associative array of superglobal names and their keys to blacklist
$key string String of superglobal key to blacklist

blacklistTrait() public méthode

You can pass a string of trait name, or pass an array of the trait names to blacklist
public blacklistTrait ( string | array $name )
$name string | array String of trait name or array of trait names to blacklist

blacklistType() public méthode

You can pass a string of type name, or pass an array of the type names to blacklist
public blacklistType ( string | array $name )
$name string | array String of type name or array of type names to blacklist

blacklistUse() public méthode

You can pass a string of use (or alias) name, or pass an array of the use (or alias) names to blacklist
public blacklistUse ( string | array $name )
$name string | array String of use (or alias) name or array of use (or alias) names to blacklist

blacklistVar() public méthode

You can pass a string of variable name, or pass an array of the variable names to blacklist
public blacklistVar ( string | array $name )
$name string | array String of variable name or array of variable names to blacklist

call_func() public méthode

Get PHPSandbox redefined function. This is an internal PHPSandbox function but requires public access to work.
public call_func ( ) : mixed
Résultat mixed Returns the redefined function result

checkAlias() public méthode

Check alias name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkAlias ( string $name ) : boolean
$name string String of the alias name to check
Résultat boolean Returns true if alias is valid

checkClass() public méthode

Check class name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkClass ( string $name, boolean $extends = false ) : boolean
$name string String of the class name to check
$extends boolean Flag whether this is an extended class
Résultat boolean Returns true if class is valid

checkConst() public méthode

Check constant name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkConst ( string $name ) : boolean
$name string String of the constant name to check
Résultat boolean Returns true if constant is valid

checkFunc() public méthode

Check function name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkFunc ( string $name ) : boolean
$name string String of the function name to check
Résultat boolean Returns true if function is valid, this is also used for testing closures

checkGlobal() public méthode

Check global name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkGlobal ( string $name ) : boolean
$name string String of the global name to check
Résultat boolean Returns true if global is valid

checkInterface() public méthode

Check interface name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkInterface ( string $name ) : boolean
$name string String of the interface name to check
Résultat boolean Returns true if interface is valid

checkKeyword() public méthode

Check keyword name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkKeyword ( string $name ) : boolean
$name string String of the keyword name to check
Résultat boolean Returns true if keyword is valid

checkMagicConst() public méthode

Check magic constant name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkMagicConst ( string $name ) : boolean
$name string String of the magic constant name to check
Résultat boolean Returns true if magic constant is valid

checkNamespace() public méthode

Check namespace name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkNamespace ( string $name ) : boolean
$name string String of the namespace name to check
Résultat boolean Returns true if namespace is valid

checkOperator() public méthode

Check operator name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkOperator ( string $name ) : boolean
$name string String of the type operator to check
Résultat boolean Returns true if operator is valid

checkPrimitive() public méthode

Check primitive name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkPrimitive ( string $name ) : boolean
$name string String of the primitive name to check
Résultat boolean Returns true if primitive is valid

checkSuperglobal() public méthode

Check superglobal name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkSuperglobal ( string $name ) : boolean
$name string String of the superglobal name to check
Résultat boolean Returns true if superglobal is valid

checkTrait() public méthode

Check trait name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkTrait ( string $name ) : boolean
$name string String of the trait name to check
Résultat boolean Returns true if trait is valid

checkType() public méthode

Check type name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkType ( string $name ) : boolean
$name string String of the type name to check
Résultat boolean Returns true if type is valid

checkUse() public méthode

Check use (or alias) name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkUse ( string $name ) : boolean
$name string String of the use (or alias) name to check
Résultat boolean Returns true if use (or alias) is valid

checkVar() public méthode

Check variable name against PHPSandbox validation rules. This is an internal PHPSandbox function but requires public access to work.
public checkVar ( string $name ) : boolean
$name string String of the variable name to check
Résultat boolean Returns true if variable is valid

clear() public méthode

Clear all trusted and sandboxed code
public clear ( )

clearAppend() public méthode

Clear all appended trusted code
public clearAppend ( )

clearAppendedCode() public méthode

Clear all appended trusted code
public clearAppendedCode ( )

clearCode() public méthode

Clear generated code
public clearCode ( )

clearPrepended() public méthode

Clear all prepended trusted code
public clearPrepended ( )

clearPrependedCode() public méthode

Clear all prepended trusted code
public clearPrependedCode ( )

clearTrustedCode() public méthode

Clear all trusted code
public clearTrustedCode ( )

create() public static méthode

You can pass optional arrays of predefined functions, variables, etc. to the sandbox through the constructor
public static create ( array $options = [], array $functions = [], array $variables = [], array $constants = [], array $namespaces = [], array $aliases = [], array $superglobals = [], array $magic_constants = [], array $classes = [], array $interfaces = [], array $traits = [] )
$options array Optional array of options to set for the sandbox
$functions array Optional array of functions to define for the sandbox
$variables array Optional array of variables to define for the sandbox
$constants array Optional array of constants to define for the sandbox
$namespaces array Optional array of namespaces to define for the sandbox
$aliases array Optional array of aliases to define for the sandbox
$superglobals array Optional array of superglobals to define for the sandbox
$magic_constants array Optional array of magic constants to define for the sandbox
$classes array Optional array of classes to define for the sandbox
$interfaces array Optional array of interfaces to define for the sandbox
$traits array Optional array of traits to define for the sandbox

deblacklist() public méthode

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
public deblacklist ( string | array $type, string | array | null $name )
$type string | array Associative array or string of blacklist type to unset
$name string | array | null Array or string of blacklist name to unset

deblacklistAlias() public méthode

You can pass a string of alias name, or pass an array of the alias names to remove from blacklist
public deblacklistAlias ( string | array $name )
$name string | array String of alias name or array of alias names to remove from blacklist

deblacklistClass() public méthode

You can pass a string of class name, or pass an array of the class names to remove from blacklist
public deblacklistClass ( string | array $name )
$name string | array String of class name or array of class names to remove from blacklist

deblacklistConst() public méthode

You can pass a string of constant name, or pass an array of the constant names to remove from blacklist
public deblacklistConst ( string | array $name )
$name string | array String of constant name or array of constant names to remove from blacklist

deblacklistFunc() public méthode

You can pass a string of the function name, or pass an array of function names to remove from blacklist
public deblacklistFunc ( string | array $name )
$name string | array String of function name or array of function names to remove from blacklist

deblacklistGlobal() public méthode

You can pass a string of global name, or pass an array of the global names to remove from blacklist
public deblacklistGlobal ( string | array $name )
$name string | array String of global name or array of global names to remove from blacklist

deblacklistInterface() public méthode

You can pass a string of interface name, or pass an array of the interface names to remove from blacklist
public deblacklistInterface ( string | array $name )
$name string | array String of interface name or array of interface names to remove from blacklist

deblacklistKeyword() public méthode

You can pass a string of keyword name, or pass an array of the keyword names to remove from blacklist
public deblacklistKeyword ( string | array $name )
$name string | array String of keyword name or array of keyword names to remove from blacklist

deblacklistMagicConst() public méthode

You can pass a string of magic constant name, or pass an array of the magic constant names to remove from blacklist
public deblacklistMagicConst ( string | array $name )
$name string | array String of magic constant name or array of magic constant names to remove from blacklist

deblacklistNamespace() public méthode

You can pass a string of namespace name, or pass an array of the namespace names to remove from blacklist
public deblacklistNamespace ( string | array $name )
$name string | array String of namespace name or array of namespace names to remove from blacklist

deblacklistOperator() public méthode

You can pass a string of operator name, or pass an array of the operator names to remove from blacklist
public deblacklistOperator ( string | array $name )
$name string | array String of operator name or array of operator names to remove from blacklist

deblacklistPrimitive() public méthode

You can pass a string of primitive name, or pass an array of the primitive names to remove from blacklist
public deblacklistPrimitive ( string | array $name )
$name string | array String of primitive name or array of primitive names to remove from blacklist

deblacklistSuperglobal() public méthode

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
public deblacklistSuperglobal ( string | array $name, string $key = null )
$name string | array String of superglobal name, or an array of superglobal names, or an associative array of superglobal names and their keys to remove from blacklist
$key string String of superglobal key to remove from blacklist

deblacklistTrait() public méthode

You can pass a string of trait name, or pass an array of the trait names to remove from blacklist
public deblacklistTrait ( string | array $name )
$name string | array String of trait name or array of trait names to remove from blacklist

deblacklistType() public méthode

You can pass a string of type name, or pass an array of the type names to remove from blacklist
public deblacklistType ( string | array $name )
$name string | array String of type name or array of type names to remove from blacklist

deblacklistUse() public méthode

You can pass a string of use (or alias name, or pass an array of the use (or alias) names to remove from blacklist
public deblacklistUse ( string | array $name )
$name string | array String of use (or alias) name or array of use (or alias) names to remove from blacklist

deblacklistVar() public méthode

You can pass a string of variable name, or pass an array of the variable names to remove from blacklist
public deblacklistVar ( string | array $name )
$name string | array String of variable name or array of variable names to remove from blacklist

define() public méthode

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
public define ( string | array $type, string | array | null $name = null, mixed | null $value = null )
$type string | array Associative array or string of definition type to define
$name string | array | null Associative array or string of definition name to define
$value mixed | null Value of definition to define

defineAlias() public méthode

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
public defineAlias ( string | array $name, string | null $alias = null )
$name string | array 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
$alias string | null String of $alias to use

defineAliases() public méthode

You can pass an array of namespaces to use, or an associative array of namespaces to use and their aliases
public defineAliases ( array $aliases = [] )
$aliases array Array of namespaces to use, or an associative array of namespaces and their aliases to use

defineClass() public méthode

You can pass the class $name and $value to define, or an associative array of classes to define
public defineClass ( string | array $name, mixed $value )
$name string | array String of class $name or associative array to define
$value mixed Value to define class to

defineClasses() public méthode

You can pass an associative array of classes to define
public defineClasses ( array $classes = [] )
$classes array Associative array of $classes to define

defineConst() public méthode

You can pass the constant $name and $value to define, or an associative array of constants to define
public defineConst ( string | array $name, mixed $value )
$name string | array String of constant $name or associative array to define
$value mixed Value to define constant to

defineConsts() public méthode

You can pass an associative array of constants to define
public defineConsts ( array $constants = [] )
$constants array Associative array of $constants to define

defineFunc() public méthode

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
public defineFunc ( string | array $name, callable $function, boolean $pass_sandbox = false )
$name string | array Associative array or string of function $name to define
$function callable Callable to define $function to
$pass_sandbox boolean Pass PHPSandbox instance to defined function when called? Default is false

defineFuncs() public méthode

You can pass an associative array of functions to define
public defineFuncs ( array $functions = [] )
$functions array Associative array of $functions to define

defineInterface() public méthode

You can pass the interface $name and $value to define, or an associative array of interfaces to define
public defineInterface ( string | array $name, mixed $value )
$name string | array String of interface $name or associative array to define
$value mixed Value to define interface to

defineInterfaces() public méthode

You can pass an associative array of interfaces to define
public defineInterfaces ( array $interfaces = [] )
$interfaces array Associative array of $interfaces to define

defineMagicConst() public méthode

You can pass the magic constant $name and $value to define, or an associative array of magic constants to define
public defineMagicConst ( string | array $name, mixed $value )
$name string | array String of magic constant $name or associative array to define
$value mixed Value to define magic constant to, can be callable

defineMagicConsts() public méthode

You can pass an associative array of magic constants to define
public defineMagicConsts ( array $magic_constants = [] )
$magic_constants array Associative array of $magic_constants to define

defineNamespace() public méthode

You can pass the namespace $name and $value to define, or an array of namespaces to define
public defineNamespace ( string | array $name )
$name string | array String of namespace $name, or an array of namespace names to define

defineNamespaces() public méthode

You can pass an array of namespaces to define
public defineNamespaces ( array $namespaces = [] )
$namespaces array Array of $namespaces to define

defineSuperglobal() public méthode

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
public defineSuperglobal ( string | array $name, mixed $value )
$name string | array String of superglobal $name or associative array of superglobal names to define
$value mixed Value to define superglobal to, can be callable

defineSuperglobals() public méthode

You can pass an associative array of superglobals to define
public defineSuperglobals ( array $superglobals = [] )
$superglobals array Associative array of $superglobals to define

defineTrait() public méthode

You can pass the trait $name and $value to define, or an associative array of traits to define
public defineTrait ( string | array $name, mixed $value )
$name string | array String of trait $name or associative array to define
$value mixed Value to define trait to

defineTraits() public méthode

You can pass an associative array of traits to define
public defineTraits ( array $traits = [] )
$traits array Associative array of $traits to define

defineUse() public méthode

Define PHPSandbox use (or alias)
public defineUse ( string | array $name, string | null $alias = null )
$name string | array 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
$alias string | null String of $alias to use

defineUses() public méthode

Define PHPSandbox uses (or aliases) by array
public defineUses ( array $uses = [] )
$uses array Array of namespaces to use, or an associative array of namespaces and their aliases to use

defineVar() public méthode

You can pass the variable $name and $value to define, or an associative array of variables to define
public defineVar ( string | array $name, mixed $value )
$name string | array String of variable $name or associative array to define
$value mixed Value to define variable to

defineVars() public méthode

You can pass an associative array of variables to define
public defineVars ( array $variables = [] )
$variables array Associative array of $variables to define

dewhitelist() public méthode

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
public dewhitelist ( string | array $type, string | array | null $name )
$type string | array Associative array or string of whitelist type to unset
$name string | array | null Array or string of whitelist name to unset

dewhitelistAlias() public méthode

You can pass a string of alias name, or pass an array of the alias names to remove from whitelist
public dewhitelistAlias ( string | array $name )
$name string | array String of alias name or array of alias names to remove from whitelist

dewhitelistClass() public méthode

You can pass a string of class name, or pass an array of the class names to remove from whitelist
public dewhitelistClass ( string | array $name )
$name string | array String of class name or array of class names to remove from whitelist

dewhitelistConst() public méthode

You can pass a string of constant name, or pass an array of the constant names to remove from whitelist
public dewhitelistConst ( string | array $name )
$name string | array String of constant name or array of constant names to remove from whitelist

dewhitelistFunc() public méthode

You can pass a string of the function name, or pass an array of function names to remove from whitelist
public dewhitelistFunc ( string | array $name )
$name string | array String of function name or array of function names to remove from whitelist

dewhitelistGlobal() public méthode

You can pass a string of global name, or pass an array of the global names to remove from whitelist
public dewhitelistGlobal ( string | array $name )
$name string | array String of global name or array of global names to remove from whitelist

dewhitelistInterface() public méthode

You can pass a string of interface name, or pass an array of the interface names to remove from whitelist
public dewhitelistInterface ( string | array $name )
$name string | array String of interface name or array of interface names to remove from whitelist

dewhitelistKeyword() public méthode

You can pass a string of keyword name, or pass an array of the keyword names to remove from whitelist
public dewhitelistKeyword ( string | array $name )
$name string | array String of keyword name or array of keyword names to remove from whitelist

dewhitelistMagicConst() public méthode

You can pass a string of magic constant name, or pass an array of the magic constant names to remove from whitelist
public dewhitelistMagicConst ( string | array $name )
$name string | array String of magic constant name or array of magic constant names to remove from whitelist

dewhitelistNamespace() public méthode

You can pass a string of namespace name, or pass an array of the namespace names to remove from whitelist
public dewhitelistNamespace ( string | array $name )
$name string | array String of namespace name or array of namespace names to remove from whitelist

dewhitelistOperator() public méthode

You can pass a string of operator name, or pass an array of the operator names to remove from whitelist
public dewhitelistOperator ( string | array $name )
$name string | array String of operator name or array of operator names to remove from whitelist

dewhitelistPrimitive() public méthode

You can pass a string of primitive name, or pass an array of the primitive names to remove from whitelist
public dewhitelistPrimitive ( string | array $name )
$name string | array String of primitive name or array of primitive names to remove from whitelist

dewhitelistSuperglobal() public méthode

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
public dewhitelistSuperglobal ( string | array $name, string $key = null )
$name string | array String of superglobal name, or an array of superglobal names, or an associative array of superglobal names and their keys to remove from whitelist
$key string String of superglobal key to remove from whitelist

dewhitelistTrait() public méthode

You can pass a string of trait name, or pass an array of the trait names to remove from whitelist
public dewhitelistTrait ( string | array $name )
$name string | array String of trait name or array of trait names to remove from whitelist

dewhitelistType() public méthode

You can pass a string of type name, or pass an array of the type names to remove from whitelist
public dewhitelistType ( string | array $name )
$name string | array String of type name or array of type names to remove from whitelist

dewhitelistUse() public méthode

You can pass a string of use (or alias name, or pass an array of the use (or alias) names to remove from whitelist
public dewhitelistUse ( string | array $name )
$name string | array String of use (or alias) name or array of use (or alias) names to remove from whitelist

dewhitelistVar() public méthode

You can pass a string of variable name, or pass an array of the variable names to remove from whitelist
public dewhitelistVar ( string | array $name )
$name string | array String of variable name or array of variable names to remove from whitelist

disassemble() protected méthode

Disassemble callable to string
protected disassemble ( callable $closure ) : string
$closure callable The callable to disassemble
Résultat string Return the disassembled code string

error() public méthode

Invoke sandbox error handler
public error ( integer $errno, string $errstr, string $errfile, integer $errline, array $errcontext ) : mixed
$errno integer Error number
$errstr string Error message
$errfile string Error file
$errline integer Error line number
$errcontext array Error context array
Résultat mixed

exception() public méthode

Invoke sandbox exception handler
public exception ( Exception $exception ) : mixed
$exception Exception Error number
Résultat mixed

execute() public méthode

This function validates your code and automatically whitelists it according to your specified configuration, then executes it.
public execute ( callable | string $callable = null, boolean $skip_validation = false ) : mixed
$callable callable | string Callable or string of PHP code to prepare and execute within the sandbox
$skip_validation boolean Boolean flag to indicate whether the sandbox should skip validation of the pass callable. Default is false.
Résultat mixed The output from the executed sandboxed code

getAliasValidator() public méthode

Get validation callable for aliases
public getAliasValidator ( ) : callable | null
Résultat callable | null

getAppendedCode() public méthode

Get PHPSandbox appended code
public getAppendedCode ( ) : string
Résultat string Returns a string of the appended code

getClassValidator() public méthode

Get validation callable for classes
public getClassValidator ( ) : callable | null
Résultat callable | null

getCode() public méthode

Get PHPSandbox generated code
public getCode ( ) : string
Résultat string Returns a string of the generated code

getConstValidator() public méthode

Get validation callable for constants
public getConstValidator ( ) : callable | null
Résultat callable | null

getDefinedClass() public méthode

Get defined class of $name
public getDefinedClass ( string $name ) : string
$name string String of class $name to get
Résultat string Returns string of defined class value

getDefinedInterface() public méthode

Get defined interface of $name
public getDefinedInterface ( string $name ) : string
$name string String of interface $name to get
Résultat string Returns string of defined interface value

getDefinedNamespace() public méthode

Get defined namespace of $name
public getDefinedNamespace ( string $name ) : string
$name string String of namespace $name to get
Résultat string Returns string of defined namespace value

getDefinedTrait() public méthode

Get defined trait of $name
public getDefinedTrait ( string $name ) : string
$name string String of trait $name to get
Résultat string Returns string of defined trait value

getErrorHandler() public méthode

This function returns the sandbox error handler.
public getErrorHandler ( ) : null | callable
Résultat null | callable

getExceptionHandler() public méthode

This function returns the sandbox exception handler.
public getExceptionHandler ( ) : null | callable
Résultat null | callable

getExecutionTime() public méthode

You can pass the number of digits you wish to round the return value
public getExecutionTime ( integer | null $round ) : float
$round integer | null The number of digits to round the return value
Résultat float The amount of time in microseconds it took to execute the sandboxed code

getFuncValidator() public méthode

Get validation for functions
public getFuncValidator ( ) : callable | null
Résultat callable | null

getGeneratedCode() public méthode

Get PHPSandbox generated code
public getGeneratedCode ( ) : string
Résultat string Returns a string of the generated code

getGlobalValidator() public méthode

Get validation callable for globals
public getGlobalValidator ( ) : callable | null
Résultat callable | null

getInterfaceValidator() public méthode

Get validation callable for interfaces
public getInterfaceValidator ( ) : callable | null
Résultat callable | null

getIterator() public méthode

Get an iterator of all the public PHPSandbox properties
public getIterator ( ) : array
Résultat array

getKeywordValidator() public méthode

Get validation callable for keywords
public getKeywordValidator ( ) : callable | null
Résultat callable | null

getLastError() public méthode

Gets the last sandbox error
public getLastError ( ) : array
Résultat array

getLastException() public méthode

Gets the last exception thrown by the sandbox
public getLastException ( ) : Exception | Error
Résultat Exception | Error

getLastValidationError() public méthode

Gets the last validation error thrown by the sandbox
public getLastValidationError ( ) : Exception | Error
Résultat Exception | Error

getMagicConstValidator() public méthode

Get validation callable for magic constants
public getMagicConstValidator ( ) : callable | null
Résultat callable | null

getMemoryUsage() public méthode

You can pass the number of digits you wish to round the return value
public getMemoryUsage ( integer | null $round ) : integer
$round integer | null The number of digits to round the return value
Résultat integer The amount of bytes in memory it took to prepare and execute the sandboxed code

getName() public méthode

Get name of PHPSandbox variable
public getName ( ) : string
Résultat string The name of the PHPSandbox variable

getNamespaceValidator() public méthode

Get validation callable for namespaces
public getNamespaceValidator ( ) : callable | null
Résultat callable | null

getOperatorValidator() public méthode

Get validation callable for operators
public getOperatorValidator ( ) : callable | null
Résultat callable | null

getOption() public méthode

You pass a string $option name to get its associated value
public getOption ( string $option ) : boolean | integer | null
$option string String of $option name to get
Résultat boolean | integer | null Returns the value of the requested option

getParsedAST() public méthode

Get PHPSandbox parsed AST array
public getParsedAST ( ) : array
Résultat array Returns an array of the parsed AST code

getPreparedAST() public méthode

Get PHPSandbox prepared AST array
public getPreparedAST ( ) : array
Résultat array Returns an array of the prepared AST code

getPreparedCode() public méthode

Get PHPSandbox prepared code
public getPreparedCode ( ) : string
Résultat string Returns a string of the prepared code

getPreparedTime() public méthode

You can pass the number of digits you wish to round the return value
public getPreparedTime ( integer | null $round ) : float
$round integer | null The number of digits to round the return value
Résultat float The amount of time in microseconds it took to prepare the sandboxed code

getPreparsedCode() public méthode

Get PHPSandbox preparsed code
public getPreparsedCode ( ) : string
Résultat string Returns a string of the preparsed code

getPrependedCode() public méthode

Get PHPSandbox prepended code
public getPrependedCode ( ) : string
Résultat string Returns a string of the prepended code

getPrimitiveValidator() public méthode

Get validation callable for primitives
public getPrimitiveValidator ( ) : callable | null
Résultat callable | null

getSandbox() public static méthode

Get a named PHPSandbox instance (used to retrieve the sandbox instance from within sandboxed code)
public static getSandbox ( string $name ) : null | PHPSandbox
$name string The name of the PHPSandbox instance to retrieve
Résultat null | PHPSandbox

getSuperglobalValidator() public méthode

Get validation callable for superglobals
public getSuperglobalValidator ( ) : callable | null
Résultat callable | null

getTime() public méthode

You can pass the number of digits you wish to round the return value
public getTime ( integer | null $round ) : float
$round integer | null The number of digits to round the return value
Résultat float The amount of time in microseconds it took to prepare and execute the sandboxed code

getTraitValidator() public méthode

Get validation callable for traits
public getTraitValidator ( ) : callable | null
Résultat callable | null

getTypeValidator() public méthode

Get validation callable for types
public getTypeValidator ( ) : callable | null
Résultat callable | null

getUseValidator() public méthode

Get validation callable for uses (aka aliases)
public getUseValidator ( ) : callable | null
Résultat callable | null

getValidationErrorHandler() public méthode

This function returns the sandbox validation error handler.
public getValidationErrorHandler ( ) : null | callable
Résultat null | callable

getValidator() public méthode

Get validation callable for specified $type
public getValidator ( string $type ) : callable | null
$type string String of $type to return
Résultat callable | null

getVarValidator() public méthode

Get validation callable for variables
public getVarValidator ( ) : callable | null
Résultat callable | null

hasBlacklist() public méthode

Query whether PHPSandbox instance has blacklist type.
public hasBlacklist ( string $type ) : integer
$type string The blacklist type to query
Résultat integer Returns the number of blacklists this instance has defined

hasBlacklistedAliases() public méthode

Query whether PHPSandbox instance has blacklisted aliases.
public hasBlacklistedAliases ( ) : integer
Résultat integer Returns the number of blacklisted aliases this instance has defined

hasBlacklistedClasses() public méthode

Query whether PHPSandbox instance has blacklisted classes.
public hasBlacklistedClasses ( ) : integer
Résultat integer Returns the number of blacklisted classes this instance has defined

hasBlacklistedConsts() public méthode

Query whether PHPSandbox instance has blacklisted constants.
public hasBlacklistedConsts ( ) : integer
Résultat integer Returns the number of blacklisted constants this instance has defined

hasBlacklistedFuncs() public méthode

Query whether PHPSandbox instance has blacklisted functions.
public hasBlacklistedFuncs ( ) : integer
Résultat integer Returns the number of blacklisted functions this instance has defined

hasBlacklistedGlobals() public méthode

Query whether PHPSandbox instance has blacklisted globals.
public hasBlacklistedGlobals ( ) : integer
Résultat integer Returns the number of blacklisted globals this instance has defined

hasBlacklistedInterfaces() public méthode

Query whether PHPSandbox instance has blacklisted interfaces.
public hasBlacklistedInterfaces ( ) : integer
Résultat integer Returns the number of blacklisted interfaces this instance has defined

hasBlacklistedKeywords() public méthode

Query whether PHPSandbox instance has blacklisted keywords.
public hasBlacklistedKeywords ( ) : integer
Résultat integer Returns the number of blacklisted keywords this instance has defined

hasBlacklistedMagicConsts() public méthode

Query whether PHPSandbox instance has blacklisted magic constants.
public hasBlacklistedMagicConsts ( ) : integer
Résultat integer Returns the number of blacklisted magic constants this instance has defined

hasBlacklistedNamespaces() public méthode

Query whether PHPSandbox instance has blacklisted namespaces.
public hasBlacklistedNamespaces ( ) : integer
Résultat integer Returns the number of blacklisted namespaces this instance has defined

hasBlacklistedOperators() public méthode

Query whether PHPSandbox instance has blacklisted operators.
public hasBlacklistedOperators ( ) : integer
Résultat integer Returns the number of blacklisted operators this instance has defined

hasBlacklistedPrimitives() public méthode

Query whether PHPSandbox instance has blacklisted primitives.
public hasBlacklistedPrimitives ( ) : integer
Résultat integer Returns the number of blacklisted primitives this instance has defined

hasBlacklistedSuperglobals() public méthode

Query whether PHPSandbox instance has blacklisted superglobals, or superglobal keys
public hasBlacklistedSuperglobals ( string $name = null ) : integer
$name string The blacklist superglobal key to query
Résultat integer Returns the number of blacklisted superglobals or superglobal keys this instance has defined

hasBlacklistedTraits() public méthode

Query whether PHPSandbox instance has blacklisted traits.
public hasBlacklistedTraits ( ) : integer
Résultat integer Returns the number of blacklisted traits this instance has defined

hasBlacklistedTypes() public méthode

Query whether PHPSandbox instance has blacklisted types.
public hasBlacklistedTypes ( ) : integer
Résultat integer Returns the number of blacklisted types this instance has defined

hasBlacklistedUses() public méthode

Query whether PHPSandbox instance has blacklisted uses (or aliases.)
public hasBlacklistedUses ( ) : integer
Résultat integer Returns the number of blacklisted uses (or aliases) this instance has defined

hasBlacklistedVars() public méthode

Query whether PHPSandbox instance has blacklisted variables.
public hasBlacklistedVars ( ) : integer
Résultat integer Returns the number of blacklisted variables this instance has defined

hasDefinedAliases() public méthode

Query whether PHPSandbox instance has defined aliases
public hasDefinedAliases ( ) : integer
Résultat integer Returns the number of aliases this instance has defined

hasDefinedClasses() public méthode

Query whether PHPSandbox instance has defined classes
public hasDefinedClasses ( ) : integer
Résultat integer Returns the number of classes this instance has defined

hasDefinedConsts() public méthode

Query whether PHPSandbox instance has defined constants
public hasDefinedConsts ( ) : integer
Résultat integer Returns the number of constants this instance has defined

hasDefinedFuncs() public méthode

Query whether PHPSandbox instance has defined functions
public hasDefinedFuncs ( ) : integer
Résultat integer Returns the number of functions this instance has defined

hasDefinedInterfaces() public méthode

Query whether PHPSandbox instance has defined interfaces
public hasDefinedInterfaces ( ) : integer
Résultat integer Returns the number of interfaces this instance has defined

hasDefinedMagicConsts() public méthode

Query whether PHPSandbox instance has defined magic constants
public hasDefinedMagicConsts ( ) : integer
Résultat integer Returns the number of magic constants this instance has defined

hasDefinedNamespaces() public méthode

Query whether PHPSandbox instance has defined namespaces
public hasDefinedNamespaces ( ) : integer
Résultat integer Returns the number of namespaces this instance has defined

hasDefinedSuperglobals() public méthode

Query whether PHPSandbox instance has defined superglobals, or if superglobal $name has defined keys
public hasDefinedSuperglobals ( string | null $name = null ) : integer | boolean
$name string | null String of superglobal $name to check for keys
Résultat integer | boolean Returns the number of superglobals or superglobal keys this instance has defined, or false if invalid superglobal name specified

hasDefinedTraits() public méthode

Query whether PHPSandbox instance has defined traits
public hasDefinedTraits ( ) : integer
Résultat integer Returns the number of traits this instance has defined

hasDefinedUses() public méthode

Query whether PHPSandbox instance has defined uses (or aliases)
public hasDefinedUses ( ) : integer
Résultat integer Returns the number of uses (or aliases) this instance has defined

hasDefinedVars() public méthode

Query whether PHPSandbox instance has defined variables
public hasDefinedVars ( ) : integer
Résultat integer Returns the number of variables this instance has defined

hasWhitelist() public méthode

Query whether PHPSandbox instance has whitelist type
public hasWhitelist ( string $type ) : integer
$type string The whitelist type to query
Résultat integer Returns the number of whitelists this instance has defined

hasWhitelistKeywords() public méthode

Query whether PHPSandbox instance has whitelisted keywords.
public hasWhitelistKeywords ( ) : integer
Résultat integer Returns the number of whitelisted keywords this instance has defined

hasWhitelistedAliases() public méthode

Query whether PHPSandbox instance has whitelisted aliases.
public hasWhitelistedAliases ( ) : integer
Résultat integer Returns the number of whitelisted aliases this instance has defined

hasWhitelistedClasses() public méthode

Query whether PHPSandbox instance has whitelisted classes.
public hasWhitelistedClasses ( ) : integer
Résultat integer Returns the number of whitelisted classes this instance has defined

hasWhitelistedConsts() public méthode

Query whether PHPSandbox instance has whitelisted constants.
public hasWhitelistedConsts ( ) : integer
Résultat integer Returns the number of whitelisted constants this instance has defined

hasWhitelistedFuncs() public méthode

Query whether PHPSandbox instance has whitelisted functions.
public hasWhitelistedFuncs ( ) : integer
Résultat integer Returns the number of whitelisted functions this instance has defined

hasWhitelistedGlobals() public méthode

Query whether PHPSandbox instance has whitelisted globals.
public hasWhitelistedGlobals ( ) : integer
Résultat integer Returns the number of whitelisted globals this instance has defined

hasWhitelistedInterfaces() public méthode

Query whether PHPSandbox instance has whitelisted interfaces.
public hasWhitelistedInterfaces ( ) : integer
Résultat integer Returns the number of whitelisted interfaces this instance has defined

hasWhitelistedMagicConsts() public méthode

Query whether PHPSandbox instance has whitelisted magic constants.
public hasWhitelistedMagicConsts ( ) : integer
Résultat integer Returns the number of whitelisted magic constants this instance has defined

hasWhitelistedNamespaces() public méthode

Query whether PHPSandbox instance has whitelisted namespaces.
public hasWhitelistedNamespaces ( ) : integer
Résultat integer Returns the number of whitelisted namespaces this instance has defined

hasWhitelistedOperators() public méthode

Query whether PHPSandbox instance has whitelisted operators.
public hasWhitelistedOperators ( ) : integer
Résultat integer Returns the number of whitelisted operators this instance has defined

hasWhitelistedPrimitives() public méthode

Query whether PHPSandbox instance has whitelisted primitives.
public hasWhitelistedPrimitives ( ) : integer
Résultat integer Returns the number of whitelisted primitives this instance has defined

hasWhitelistedSuperglobals() public méthode

Query whether PHPSandbox instance has whitelisted superglobals, or superglobal keys
public hasWhitelistedSuperglobals ( string $name = null ) : integer
$name string The whitelist superglobal key to query
Résultat integer Returns the number of whitelisted superglobals or superglobal keys this instance has defined

hasWhitelistedTraits() public méthode

Query whether PHPSandbox instance has whitelisted traits.
public hasWhitelistedTraits ( ) : integer
Résultat integer Returns the number of whitelisted traits this instance has defined

hasWhitelistedTypes() public méthode

Query whether PHPSandbox instance has whitelisted types.
public hasWhitelistedTypes ( ) : integer
Résultat integer Returns the number of whitelisted types this instance has defined

hasWhitelistedUses() public méthode

Query whether PHPSandbox instance has whitelisted uses (or aliases.)
public hasWhitelistedUses ( ) : integer
Résultat integer Returns the number of whitelisted uses (or aliases) this instance has defined

hasWhitelistedVars() public méthode

Query whether PHPSandbox instance has whitelisted variables.
public hasWhitelistedVars ( ) : integer
Résultat integer Returns the number of whitelisted variables this instance has defined

import() public méthode

* Import JSON template into sandbox
public import ( array | string $template, integer $import_flag )
$template array | string The JSON array or string template to import
$import_flag integer Binary flags signifying which parts of the JSON template to import

importJSON() public méthode

Import JSON template into sandbox
public importJSON ( array | string $template, integer $import_flag )
$template array | string The JSON array or string template to import
$import_flag integer Binary flags signifying which parts of the JSON template to import

isBlacklisted() public méthode

Check if PHPSandbox instance has blacklist type and name set
public isBlacklisted ( string $type, string $name ) : boolean
$type string String of blacklist $type to query
$name string String of blacklist $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted $type and $name, false otherwise

isBlacklistedAlias() public méthode

Check if PHPSandbox instance has blacklisted alias name set
public isBlacklistedAlias ( string $name ) : boolean
$name string String of alias $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted alias $name, false otherwise

isBlacklistedClass() public méthode

Check if PHPSandbox instance has blacklisted class name set
public isBlacklistedClass ( string $name ) : boolean
$name string String of class $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted class $name, false otherwise

isBlacklistedConst() public méthode

Check if PHPSandbox instance has blacklisted constant name set
public isBlacklistedConst ( string $name ) : boolean
$name string String of constant $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted constant $name, false otherwise

isBlacklistedFunc() public méthode

Check if PHPSandbox instance has blacklisted function name set
public isBlacklistedFunc ( string $name ) : boolean
$name string String of function $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted function $name, false otherwise

isBlacklistedGlobal() public méthode

Check if PHPSandbox instance has blacklisted global name set
public isBlacklistedGlobal ( string $name ) : boolean
$name string String of global $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted global $name, false otherwise

isBlacklistedInterface() public méthode

Check if PHPSandbox instance has blacklisted interface name set
public isBlacklistedInterface ( string $name ) : boolean
$name string String of interface $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted interface $name, false otherwise

isBlacklistedKeyword() public méthode

Check if PHPSandbox instance has blacklisted keyword name set
public isBlacklistedKeyword ( string $name ) : boolean
$name string String of keyword $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted keyword $name, false otherwise

isBlacklistedMagicConst() public méthode

Check if PHPSandbox instance has blacklisted magic constant name set
public isBlacklistedMagicConst ( string $name ) : boolean
$name string String of magic constant $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted magic constant $name, false otherwise

isBlacklistedNamespace() public méthode

Check if PHPSandbox instance has blacklisted namespace name set
public isBlacklistedNamespace ( string $name ) : boolean
$name string String of namespace $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted namespace $name, false otherwise

isBlacklistedOperator() public méthode

Check if PHPSandbox instance has blacklisted operator name set
public isBlacklistedOperator ( string $name ) : boolean
$name string String of operator $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted operator $name, false otherwise

isBlacklistedPrimitive() public méthode

Check if PHPSandbox instance has blacklisted primitive name set
public isBlacklistedPrimitive ( string $name ) : boolean
$name string String of primitive $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted primitive $name, false otherwise

isBlacklistedSuperglobal() public méthode

Check if PHPSandbox instance has blacklisted superglobal or superglobal key set
public isBlacklistedSuperglobal ( string $name, string $key = null ) : boolean
$name string String of blacklisted superglobal $name to query
$key string String of blacklisted superglobal $key to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted superglobal key or superglobal, false otherwise

isBlacklistedTrait() public méthode

Check if PHPSandbox instance has blacklisted trait name set
public isBlacklistedTrait ( string $name ) : boolean
$name string String of trait $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted trait $name, false otherwise

isBlacklistedType() public méthode

Check if PHPSandbox instance has blacklisted type name set
public isBlacklistedType ( string $name ) : boolean
$name string String of type $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted type $name, false otherwise

isBlacklistedUse() public méthode

Check if PHPSandbox instance has blacklisted use (or alias) name set
public isBlacklistedUse ( string $name ) : boolean
$name string String of use (or alias) $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted use (or alias) $name, false otherwise

isBlacklistedVar() public méthode

Check if PHPSandbox instance has blacklisted variable name set
public isBlacklistedVar ( string $name ) : boolean
$name string String of variable $name to query
Résultat boolean Returns true if PHPSandbox instance has blacklisted variable $name, false otherwise

isDefinedAlias() public méthode

Check if PHPSandbox instance has $name alias defined
public isDefinedAlias ( string $name ) : boolean
$name string String of alias $name to query
Résultat boolean Returns true if PHPSandbox instance has defined aliases, false otherwise

isDefinedClass() public méthode

Check if PHPSandbox instance has $name class defined
public isDefinedClass ( string $name ) : boolean
$name string String of class $name to query
Résultat boolean Returns true if PHPSandbox instance has defined class, false otherwise

isDefinedConst() public méthode

Check if PHPSandbox instance has $name constant defined
public isDefinedConst ( string $name ) : boolean
$name string String of constant $name to query
Résultat boolean Returns true if PHPSandbox instance has defined constant, false otherwise

isDefinedFunc() public méthode

Check if PHPSandbox instance has $name function defined
public isDefinedFunc ( string $name ) : boolean
$name string String of function $name to query
Résultat boolean Returns true if PHPSandbox instance has defined function, false otherwise

isDefinedInterface() public méthode

Check if PHPSandbox instance has $name interface defined
public isDefinedInterface ( string $name ) : boolean
$name string String of interface $name to query
Résultat boolean Returns true if PHPSandbox instance has defined interface, false otherwise

isDefinedMagicConst() public méthode

Check if PHPSandbox instance has $name magic constant defined
public isDefinedMagicConst ( string $name ) : boolean
$name string String of magic constant $name to query
Résultat boolean Returns true if PHPSandbox instance has defined magic constant, false otherwise

isDefinedNamespace() public méthode

Check if PHPSandbox instance has $name namespace defined
public isDefinedNamespace ( string $name ) : boolean
$name string String of namespace $name to query
Résultat boolean Returns true if PHPSandbox instance has defined namespace, false otherwise

isDefinedSuperglobal() public méthode

Check if PHPSandbox instance has $name superglobal defined, or if superglobal $name key is defined
public isDefinedSuperglobal ( string $name, string | null $key = null ) : boolean
$name string String of superglobal $name to query
$key string | null String of key to to query in superglobal
Résultat boolean Returns true if PHPSandbox instance has defined superglobal, false otherwise

isDefinedTrait() public méthode

Check if PHPSandbox instance has $name trait defined
public isDefinedTrait ( string $name ) : boolean
$name string String of trait $name to query
Résultat boolean Returns true if PHPSandbox instance has defined trait, false otherwise

isDefinedUse() public méthode

Check if PHPSandbox instance has $name uses (or alias) defined
public isDefinedUse ( string $name ) : boolean
$name string String of use (or alias) $name to query
Résultat boolean Returns true if PHPSandbox instance has defined uses (or aliases) and false otherwise

isDefinedVar() public méthode

Check if PHPSandbox instance has $name variable defined
public isDefinedVar ( string $name ) : boolean
$name string String of variable $name to query
Résultat boolean Returns true if PHPSandbox instance has defined variable, false otherwise

isWhitelisted() public méthode

Check if PHPSandbox instance has whitelist type and name set
public isWhitelisted ( string $type, string $name ) : boolean
$type string String of whitelist $type to query
$name string String of whitelist $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted $type and $name, false otherwise

isWhitelistedAlias() public méthode

Check if PHPSandbox instance has whitelisted alias name set
public isWhitelistedAlias ( string $name ) : boolean
$name string String of alias $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted alias $name, false otherwise

isWhitelistedClass() public méthode

Check if PHPSandbox instance has whitelisted class name set
public isWhitelistedClass ( string $name ) : boolean
$name string String of class $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted class $name, false otherwise

isWhitelistedConst() public méthode

Check if PHPSandbox instance has whitelisted constant name set
public isWhitelistedConst ( string $name ) : boolean
$name string String of constant $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted constant $name, false otherwise

isWhitelistedFunc() public méthode

Check if PHPSandbox instance has whitelisted function name set
public isWhitelistedFunc ( string $name ) : boolean
$name string String of function $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted function $name, false otherwise

isWhitelistedGlobal() public méthode

Check if PHPSandbox instance has whitelisted global name set
public isWhitelistedGlobal ( string $name ) : boolean
$name string String of global $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted global $name, false otherwise

isWhitelistedInterface() public méthode

Check if PHPSandbox instance has whitelisted interface name set
public isWhitelistedInterface ( string $name ) : boolean
$name string String of interface $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted interface $name, false otherwise

isWhitelistedKeyword() public méthode

Check if PHPSandbox instance has whitelisted keyword name set
public isWhitelistedKeyword ( string $name ) : boolean
$name string String of keyword $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted keyword $name, false otherwise

isWhitelistedMagicConst() public méthode

Check if PHPSandbox instance has whitelisted magic constant name set
public isWhitelistedMagicConst ( string $name ) : boolean
$name string String of magic constant $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted magic constant $name, false otherwise

isWhitelistedNamespace() public méthode

Check if PHPSandbox instance has whitelisted namespace name set
public isWhitelistedNamespace ( string $name ) : boolean
$name string String of namespace $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted namespace $name, false otherwise

isWhitelistedOperator() public méthode

Check if PHPSandbox instance has whitelisted operator name set
public isWhitelistedOperator ( string $name ) : boolean
$name string String of operator $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted operator $name, false otherwise

isWhitelistedPrimitive() public méthode

Check if PHPSandbox instance has whitelisted primitive name set
public isWhitelistedPrimitive ( string $name ) : boolean
$name string String of primitive $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted primitive $name, false otherwise

isWhitelistedSuperglobal() public méthode

Check if PHPSandbox instance has whitelisted superglobal or superglobal key set
public isWhitelistedSuperglobal ( string $name, string $key = null ) : boolean
$name string String of whitelisted superglobal $name to query
$key string String of whitelisted superglobal $key to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted superglobal key or superglobal, false otherwise

isWhitelistedTrait() public méthode

Check if PHPSandbox instance has whitelisted trait name set
public isWhitelistedTrait ( string $name ) : boolean
$name string String of trait $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted trait $name, false otherwise

isWhitelistedType() public méthode

Check if PHPSandbox instance has whitelisted type name set
public isWhitelistedType ( string $name ) : boolean
$name string String of type $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted type $name, false otherwise

isWhitelistedUse() public méthode

Check if PHPSandbox instance has whitelisted use (or alias) name set
public isWhitelistedUse ( string $name ) : boolean
$name string String of use (or alias) $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted use (or alias) $name, false otherwise

isWhitelistedVar() public méthode

Check if PHPSandbox instance has whitelisted variable name set
public isWhitelistedVar ( string $name ) : boolean
$name string String of variable $name to query
Résultat boolean Returns true if PHPSandbox instance has whitelisted variable $name, false otherwise

normalizeAlias() protected méthode

Normalize alias name. This is an internal PHPSandbox function.
protected normalizeAlias ( string | array $name ) : string | array
$name string | array String of the alias $name, or array of strings to normalize
Résultat string | array Returns the normalized alias string or an array of normalized strings

normalizeClass() protected méthode

Normalize class name. This is an internal PHPSandbox function.
protected normalizeClass ( string | array $name ) : string | array
$name string | array String of the class $name to normalize
Résultat string | array Returns the normalized class string or an array of normalized strings

normalizeFunc() protected méthode

Normalize function name. This is an internal PHPSandbox function.
protected normalizeFunc ( string | array $name ) : string | array
$name string | array String of the function $name, or array of strings to normalize
Résultat string | array Returns the normalized function string or an array of normalized strings

normalizeInterface() protected méthode

Normalize interface name. This is an internal PHPSandbox function.
protected normalizeInterface ( string | array $name ) : string | array
$name string | array String of the interface $name, or array of strings to normalize
Résultat string | array Returns the normalized interface string or an array of normalized strings

normalizeKeyword() protected méthode

Normalize keyword name. This is an internal PHPSandbox function.
protected normalizeKeyword ( string | array $name ) : string | array
$name string | array String of the keyword $name, or array of strings to normalize
Résultat string | array Returns the normalized keyword string or an array of normalized strings

normalizeMagicConst() protected méthode

Normalize magic constant name. This is an internal PHPSandbox function.
protected normalizeMagicConst ( string | array $name ) : string | array
$name string | array String of the magic constant $name, or array of strings to normalize
Résultat string | array Returns the normalized magic constant string or an array of normalized strings

normalizeNamespace() protected méthode

Normalize namespace name. This is an internal PHPSandbox function.
protected normalizeNamespace ( string | array $name ) : string | array
$name string | array String of the namespace $name, or array of strings to normalize
Résultat string | array Returns the normalized namespace string or an array of normalized strings

normalizeOperator() protected méthode

Normalize operator name. This is an internal PHPSandbox function.
protected normalizeOperator ( string | array $name ) : string | array
$name string | array String of the operator $name, or array of strings to normalize
Résultat string | array Returns the normalized operator string or an array of normalized strings

normalizePrimitive() protected méthode

Normalize primitive name. This is an internal PHPSandbox function.
protected normalizePrimitive ( string | array $name ) : string | array
$name string | array String of the primitive $name, or array of strings to normalize
Résultat string | array Returns the normalized primitive string or an array of normalized strings

normalizeSuperglobal() protected méthode

Normalize superglobal name. This is an internal PHPSandbox function.
protected normalizeSuperglobal ( string | array $name ) : string | array
$name string | array String of the superglobal $name, or array of strings to normalize
Résultat string | array Returns the normalized superglobal string or an array of normalized strings

normalizeTrait() protected méthode

Normalize trait name. This is an internal PHPSandbox function.
protected normalizeTrait ( string | array $name ) : string | array
$name string | array String of the trait $name, or array of strings to normalize
Résultat string | array Returns the normalized trait string or an array of normalized strings

normalizeType() protected méthode

Normalize type name. This is an internal PHPSandbox function.
protected normalizeType ( string | array $name ) : string | array
$name string | array String of the type $name, or array of strings to normalize
Résultat string | array Returns the normalized type string or an array of normalized strings

normalizeUse() protected méthode

Normalize use (or alias) name. This is an internal PHPSandbox function.
protected normalizeUse ( string | array $name ) : string | array
$name string | array String of the use (or alias) $name, or array of strings to normalize
Résultat string | array Returns the normalized use (or alias) string or an array of normalized strings

prepare() public méthode

This function validates your code and automatically whitelists it according to your specified configuration
public prepare ( callable $code, boolean $skip_validation = false ) : string
$code callable The callable to prepare for execution
$skip_validation boolean Boolean flag to indicate whether the sandbox should skip validation. Default is false.
Résultat string The generated code (this can also be accessed via $sandbox->generated_code)

prepareAliases() protected méthode

Prepare defined aliases for execution
protected prepareAliases ( )

prepareConsts() protected méthode

Prepare defined constants for execution
protected prepareConsts ( )

prepareNamespaces() protected méthode

Prepare defined namespaces for execution
protected prepareNamespaces ( )

prepareUses() protected méthode

Prepare defined uses (or aliases) for execution
protected prepareUses ( )

prepareVars() protected méthode

Prepare defined variables for execution
protected prepareVars ( ) : string
Résultat string Prepared string of variable output

prepend() public méthode

Prepend trusted code
public prepend ( string | callable $code )
$code string | callable String or callable of trusted $code to prepend to generated code

resetOptions() public méthode

Reset PHPSandbox options to their default values
public resetOptions ( )

setAliasValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
public setAliasValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed alias name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setAppendedCode() public méthode

Set PHPSandbox appended code
public setAppendedCode ( string $appended_code = '' )
$appended_code string Sets a string of the appended code

setClassValidator() public méthode

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
public setClassValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed class name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setCode() public méthode

Set PHPSandbox generated code
public setCode ( string $generated_code = '' )
$generated_code string Sets a string of the generated code

setConstValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
public setConstValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed constant name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setErrorHandler() public méthode

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
public setErrorHandler ( callable $handler, integer $error_types = E_ALL )
$handler callable Callable to handle thrown Errors
$error_types integer Integer flag of the error types to handle (default is E_ALL)

setExceptionHandler() public méthode

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!
public setExceptionHandler ( callable $handler )
$handler callable Callable to handle thrown exceptions

setFuncValidator() public méthode

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!
public setFuncValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the normalized passed function name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setGeneratedCode() public méthode

Set PHPSandbox generated code
public setGeneratedCode ( string $generated_code = '' )
$generated_code string Sets a string of the generated code

setGlobalValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
public setGlobalValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed global name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setInterfaceValidator() public méthode

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
public setInterfaceValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed interface name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setKeywordValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
public setKeywordValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed keyword name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setMagicConstValidator() public méthode

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 __
public setMagicConstValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed magic constant name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setNamespaceValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
public setNamespaceValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed namespace name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setOperatorValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
public setOperatorValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed operator name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setOption() public méthode

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.
public setOption ( string | array $option, boolean | integer | null $value = null )
$option string | array String or array of strings or associative array of keys of option names to set $value to
$value boolean | integer | null Boolean, integer or null $value to set $option to (optional)

setOptions() public méthode

You can pass an array of option names to set to $value, or an associative array of option names and their values to set.
public setOptions ( array | string $options, boolean | integer | null $value = null )
$options array | string Array of strings or associative array of keys of option names to set $value to, or JSON array or string template to import
$value boolean | integer | null Boolean, integer or null $value to set $option to (optional)

setParsedAST() public méthode

Set PHPSandbox parsed AST array
public setParsedAST ( array $parsed_ast = [] )
$parsed_ast array Sets an array of the parsed AST code

setPreparedAST() public méthode

Set PHPSandbox prepared AST array
public setPreparedAST ( array $prepared_ast = [] )
$prepared_ast array Sets an array of the prepared AST code

setPreparedCode() public méthode

Set PHPSandbox prepared code
public setPreparedCode ( string $prepared_code = '' )
$prepared_code string Sets a string of the prepared code

setPreparsedCode() public méthode

Set PHPSandbox preparsed code
public setPreparsedCode ( string $preparsed_code = '' )
$preparsed_code string Sets a string of the preparsed code

setPrependedCode() public méthode

Set PHPSandbox prepended code
public setPrependedCode ( string $prepended_code = '' )
$prepended_code string Sets a string of the prepended code

setPrimitiveValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
public setPrimitiveValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed primitive name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setSuperglobalValidator() public méthode

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 _
public setSuperglobalValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed superglobal name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setTraitValidator() public méthode

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
public setTraitValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed trait name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setTypeValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
public setTypeValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed type name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setUseValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
public setUseValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed use (aka alias) name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setValidationErrorHandler() public méthode

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!
public setValidationErrorHandler ( callable $handler )
$handler callable Callable to handle thrown validation Errors

setValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
public setValidator ( string $type, callable $callable ) : PHPSandbox
$type string String of $type name to set validator for
$callable callable Callable that validates the passed element
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

setVarValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance
public setVarValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the passed variable name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

undefine() public méthode

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
public undefine ( string | array $type, string | array $name = null )
$type string | array Associative array or string of definition type to undefine
$name string | array Associative array or string of definition name to undefine

undefineAlias() public méthode

You can pass a string of alias $name to undefine, or an array of alias names to undefine
public undefineAlias ( string | array $name )
$name string | array String of alias name, or array of alias names to undefine

undefineAliases() public méthode

You can pass an array of alias names to undefine, or an empty array or null argument to undefine all aliases
public undefineAliases ( array $aliases = [] )
$aliases array Array of alias names to undefine. Passing an empty array or no argument will result in undefining all aliases

undefineClass() public méthode

You can pass a string of class $name to undefine, or an array of class names to undefine
public undefineClass ( string | array $name )
$name string | array String of class name or an array of class names to undefine

undefineClasses() public méthode

You can pass an array of class names to undefine, or an empty array or null argument to undefine all classes
public undefineClasses ( array $classes = [] )
$classes array Array of class names to undefine. Passing an empty array or no argument will result in undefining all classes

undefineConst() public méthode

You can pass a string of constant $name to undefine, or an array of constant names to undefine
public undefineConst ( string | array $name )
$name string | array String of constant name or array of constant names to undefine

undefineConsts() public méthode

You can pass an array of constant names to undefine, or an empty array or null argument to undefine all constants
public undefineConsts ( array $constants = [] )
$constants array Array of constant names to undefine. Passing an empty array or no argument will result in undefining all constants

undefineFunc() public méthode

You can pass a string of function $name to undefine, or pass an array of function names to undefine
public undefineFunc ( string | array $name )
$name string | array String of function name or array of function names to undefine

undefineFuncs() public méthode

You can pass an array of function names to undefine, or an empty array or null argument to undefine all functions
public undefineFuncs ( array $functions = [] )
$functions array Array of function names to undefine. Passing an empty array or no argument will result in undefining all functions

undefineInterface() public méthode

You can pass a string of interface $name to undefine, or an array of interface names to undefine
public undefineInterface ( string | array $name )
$name string | array String of interface name or an array of interface names to undefine

undefineInterfaces() public méthode

You can pass an array of interface names to undefine, or an empty array or null argument to undefine all interfaces
public undefineInterfaces ( array $interfaces = [] )
$interfaces array Array of interface names to undefine. Passing an empty array or no argument will result in undefining all interfaces

undefineMagicConst() public méthode

You can pass an a string of magic constant $name to undefine, or array of magic constant names to undefine
public undefineMagicConst ( string | array $name )
$name string | array String of magic constant name, or array of magic constant names to undefine

undefineMagicConsts() public méthode

You can pass an array of magic constant names to undefine, or an empty array or null argument to undefine all magic constants
public undefineMagicConsts ( array $magic_constants = [] )
$magic_constants array Array of magic constant names to undefine. Passing an empty array or no argument will result in undefining all magic constants

undefineNamespace() public méthode

You can pass a string of namespace $name to undefine, or an array of namespace names to undefine
public undefineNamespace ( string | array $name )
$name string | array String of namespace $name, or an array of namespace names to undefine

undefineNamespaces() public méthode

You can pass an array of namespace names to undefine, or an empty array or null argument to undefine all namespaces
public undefineNamespaces ( array $namespaces = [] )
$namespaces array Array of namespace names to undefine. Passing an empty array or no argument will result in undefining all namespaces

undefineSuperglobal() public méthode

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
public undefineSuperglobal ( string | array $name, string | null $key = null )
$name string | array String of superglobal $name, or array of superglobal names, or associative array of superglobal names and keys to undefine
$key string | null String of superglobal $key to undefine

undefineSuperglobals() public méthode

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
public undefineSuperglobals ( array $superglobals = [] )
$superglobals array Associative array of superglobal names and keys or array of superglobal names to undefine

undefineTrait() public méthode

You can pass a string of trait $name to undefine, or an array of trait names to undefine
public undefineTrait ( string | array $name )
$name string | array String of trait name or an array of trait names to undefine

undefineTraits() public méthode

You can pass an array of trait names to undefine, or an empty array or null argument to undefine all traits
public undefineTraits ( array $traits = [] )
$traits array Array of trait names to undefine. Passing an empty array or no argument will result in undefining all traits

undefineUse() public méthode

You can pass a string of use (or alias) $name to undefine, or an array of use (or alias) names to undefine
public undefineUse ( string | array $name )
$name string | array String of use (or alias) name, or array of use (or alias) names to undefine

undefineUses() public méthode

Undefine PHPSandbox uses (or aliases) by array
public undefineUses ( array $uses = [] )
$uses array Array of use (or alias) names to undefine. Passing an empty array or no argument will result in undefining all uses (or aliases)

undefineVar() public méthode

You can pass a string of variable $name to undefine, or an array of variable names to undefine
public undefineVar ( string | array $name )
$name string | array String of variable name or an array of variable names to undefine

undefineVars() public méthode

You can pass an array of variable names to undefine, or an empty array or null argument to undefine all variables
public undefineVars ( array $variables = [] )
$variables array Array of variable names to undefine. Passing an empty array or no argument will result in undefining all variables

unsetAliasValidator() public méthode

Unset validation callable for aliases
public unsetAliasValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetClassValidator() public méthode

Unset validation callable for classes
public unsetClassValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetConstValidator() public méthode

Unset validation callable for constants
public unsetConstValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetErrorHandler() public méthode

This function unsets the sandbox error handler.
public unsetErrorHandler ( )

unsetExceptionHandler() public méthode

This function unsets the sandbox exception handler.

unsetFuncValidator() public méthode

Unset validation callable for functions
public unsetFuncValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetGlobalValidator() public méthode

Unset validation callable for globals
public unsetGlobalValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetInterfaceValidator() public méthode

Unset validation callable for interfaces
public unsetInterfaceValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetKeywordValidator() public méthode

Unset validation callable for keywords
public unsetKeywordValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetMagicConstValidator() public méthode

Unset validation callable for magic constants
public unsetMagicConstValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetNamespaceValidator() public méthode

Unset validation callable for namespaces
public unsetNamespaceValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetOperatorValidator() public méthode

Unset validation callable for operators
public unsetOperatorValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetPrimitiveValidator() public méthode

Unset validation callable for primitives
public unsetPrimitiveValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetSuperglobalValidator() public méthode

Unset validation callable for superglobals
public unsetSuperglobalValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetTraitValidator() public méthode

Unset validation callable for traits
public unsetTraitValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetTypeValidator() public méthode

Unset validation callable for types
public unsetTypeValidator ( )

unsetUseValidator() public méthode

Unset validation callable for uses (aka aliases)
public unsetUseValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetValidationErrorHandler() public méthode

This function unsets the sandbox validation error handler.

unsetValidator() public méthode

Unset validation callable for specified $type
public unsetValidator ( string $type ) : PHPSandbox
$type string String of $type to unset
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetVarValidator() public méthode

Unset validation callable for variables
public unsetVarValidator ( ) : PHPSandbox
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying

validate() public méthode

Validate passed callable for execution
public validate ( callable | string $code )
$code callable | string The callable or string of code to validate

validationError() public méthode

Invoke sandbox error validation handler if it exists, throw Error otherwise
public validationError ( Exception | Error | string $error, integer $code, PhpParser\Node $node = null, mixed $data = null, Exception $previous = null ) : mixed
$error Exception | Error | string Error to throw if Error is not handled, or error message string
$code integer The error code
$node PhpParser\Node The error parser node
$data mixed The error data
$previous Exception The previous Error thrown
Résultat mixed

whitelist() public méthode

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
public whitelist ( string | array $type, string | array | null $name = null )
$type string | array Associative array or string of whitelist type to set
$name string | array | null Array or string of whitelist name to set

whitelistAlias() public méthode

You can pass a string of alias name, or pass an array of the alias names to whitelist
public whitelistAlias ( string | array $name )
$name string | array String of alias names or array of alias names to whitelist

whitelistClass() public méthode

You can pass a string of class name, or pass an array of the class names to whitelist
public whitelistClass ( string | array $name )
$name string | array String of class name or array of class names to whitelist

whitelistConst() public méthode

You can pass a string of constant name, or pass an array of the constant names to whitelist
public whitelistConst ( string | array $name )
$name string | array String of constant name or array of constant names to whitelist

whitelistFunc() public méthode

You can pass a string of the function name, or pass an array of function names to whitelist
public whitelistFunc ( string | array $name )
$name string | array String of function name, or array of function names to whitelist

whitelistGlobal() public méthode

You can pass a string of global name, or pass an array of the global names to whitelist
public whitelistGlobal ( string | array $name )
$name string | array String of global name or array of global names to whitelist

whitelistInterface() public méthode

You can pass a string of interface name, or pass an array of the interface names to whitelist
public whitelistInterface ( string | array $name )
$name string | array String of interface name or array of interface names to whitelist

whitelistKeyword() public méthode

You can pass a string of keyword name, or pass an array of the keyword names to whitelist
public whitelistKeyword ( string | array $name )
$name string | array String of keyword name or array of keyword names to whitelist

whitelistMagicConst() public méthode

You can pass a string of magic constant name, or pass an array of the magic constant names to whitelist
public whitelistMagicConst ( string | array $name )
$name string | array String of magic constant name or array of magic constant names to whitelist

whitelistNamespace() public méthode

You can pass a string of namespace name, or pass an array of the namespace names to whitelist
public whitelistNamespace ( string | array $name )
$name string | array String of namespace name or array of namespace names to whitelist

whitelistOperator() public méthode

You can pass a string of operator name, or pass an array of the operator names to whitelist
public whitelistOperator ( string | array $name )
$name string | array String of operator name or array of operator names to whitelist

whitelistPrimitive() public méthode

You can pass a string of primitive name, or pass an array of the primitive names to whitelist
public whitelistPrimitive ( string | array $name )
$name string | array String of primitive name or array of primitive names to whitelist

whitelistSuperglobal() public méthode

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
public whitelistSuperglobal ( string | array $name, string $key = null )
$name string | array String of superglobal name, or an array of superglobal names, or an associative array of superglobal names and their keys to whitelist
$key string String of superglobal key to whitelist

whitelistTrait() public méthode

You can pass a string of trait name, or pass an array of the trait names to whitelist
public whitelistTrait ( string | array $name )
$name string | array String of trait name or array of trait names to whitelist

whitelistType() public méthode

You can pass a string of type name, or pass an array of the type names to whitelist
public whitelistType ( string | array $name )
$name string | array String of type name or array of type names to whitelist

whitelistUse() public méthode

You can pass a string of use (or alias) name, or pass an array of the use (or alias) names to whitelist
public whitelistUse ( string | array $name )
$name string | array String of use (or alias) name or array of use (or alias) names to whitelist

whitelistVar() public méthode

You can pass a string of variable name, or pass an array of the variable names to whitelist
public whitelistVar ( string | array $name )
$name string | array String of variable name or array of variable names to whitelist

Property Details

$allow_aliases public_oe property

Should PHPSandbox allow sandboxed code to use namespaces and declare namespace aliases (utilizing the defineAlias function?)
public $allow_aliases

$allow_backticks public_oe property

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)
public $allow_backticks

$allow_casting public_oe property

Should PHPSandbox allow sandboxed code to cast types? (This will still be subject to allowed classes)
public $allow_casting

$allow_classes public_oe property

Should PHPSandbox allow sandboxed code to declare classes?
public $allow_classes

$allow_closures public_oe property

Should PHPSandbox allow sandboxed code to declare closures?
public $allow_closures

$allow_constants public_oe property

Should PHPSandbox allow sandboxed code to define constants?
public $allow_constants

$allow_error_suppressing public_oe property

Should PHPSandbox allow sandboxed code to suppress errors (e.g. the @ operator?)
public $allow_error_suppressing

$allow_escaping public_oe property

Should PHPSandbox allow sandboxed code to escape to HTML?
public $allow_escaping

$allow_functions public_oe property

Should PHPSandbox allow sandboxed code to declare functions?
public $allow_functions

$allow_generators public_oe property

Should PHPSandbox allow sandboxed code to create generators?
public $allow_generators

$allow_globals public_oe property

Should PHPSandbox allow sandboxed code to use global keyword to access variables in the global scope?
public $allow_globals

$allow_halting public_oe property

Should PHPSandbox allow sandboxed code to halt the PHP compiler?
public $allow_halting

$allow_includes public_oe property

Flag to indicate whether the sandbox should allow included files
public $allow_includes

$allow_interfaces public_oe property

Should PHPSandbox allow sandboxed code to declare interfaces?
public $allow_interfaces

$allow_namespaces public_oe property

Should PHPSandbox allow sandboxed code to declare namespaces (utilizing the defineNamespace function?)
public $allow_namespaces

$allow_objects public_oe property

Should PHPSandbox allow sandboxed code to create objects of allow classes (e.g. new keyword)?
public $allow_objects

$allow_references public_oe property

Should PHPSandbox allow sandboxed code to assign references?
public $allow_references

$allow_static_variables public_oe property

Should PHPSandbox allow sandboxed code to create static variables?
public $allow_static_variables

$allow_traits public_oe property

Should PHPSandbox allow sandboxed code to declare traits?
public $allow_traits

$allow_variables public_oe property

Should PHPSandbox allow sandboxed code to create variables?
public $allow_variables

$appended_code protected_oe property

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

$arg_funcs public_oe static_oe property

A static array of func_get_args, func_get_arg, and func_num_args used for redefining those functions
public static $arg_funcs

$auto_define_vars public_oe property

Should PHPSandbox automagically define variables passed to prepended, appended and prepared code closures?
public $auto_define_vars

$auto_whitelist_classes public_oe property

Should PHPSandbox automagically whitelist classes created in sandboxed code if $allow_classes is true?
public $auto_whitelist_classes

$auto_whitelist_constants public_oe property

Should PHPSandbox automagically whitelist constants created in sandboxed code if $allow_constants is true?
public $auto_whitelist_constants

$auto_whitelist_functions public_oe property

Should PHPSandbox automagically whitelist functions created in sandboxed code if $allow_functions is true?
public $auto_whitelist_functions

$auto_whitelist_globals public_oe property

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

$auto_whitelist_interfaces public_oe property

Should PHPSandbox automagically whitelist interfaces created in sandboxed code if $allow_interfaces is true?
public $auto_whitelist_interfaces

$auto_whitelist_traits public_oe property

Should PHPSandbox automagically whitelist traits created in sandboxed code if $allow_traits is true?
public $auto_whitelist_traits

$auto_whitelist_trusted_code public_oe property

Should PHPSandbox automagically whitelist prepended and appended code?
public $auto_whitelist_trusted_code

$blacklist protected_oe property

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

$capture_output public_oe property

Flag whether to return output via an output buffer
public $capture_output

$convert_errors public_oe property

Flag to indicate whether the sandbox should convert errors to exceptions
public $convert_errors

$defined_funcs public_oe static_oe property

A static array of defined_* and declared_* functions names used for redefining defined_* and declared_* values
public static $defined_funcs

$definitions protected_oe property

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

$error_handler protected_oe property

Callable that handles any errors when set
protected $error_handler

$error_handler_types protected_oe property

Integer value of the error types to handle (default is E_ALL)
protected $error_handler_types

$error_level public_oe property

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.
public $error_level

$exception_handler protected_oe property

Callable that handles any thrown exceptions when set
protected $exception_handler

$execution_time protected_oe property

Float of the number of microseconds it took to execute the sandbox
protected $execution_time

$generated_code protected_oe property

String of generated code, for debugging and serialization purposes
protected $generated_code

$includes protected_oe property

Array of sandboxed included files
protected $includes

$last_error protected_oe property

The last error thrown by the sandbox
protected $last_error

$last_exception protected_oe property

The last exception thrown by the sandbox
protected $last_exception

$last_validation_error protected_oe property

The last validation error thrown by the sandbox
protected $last_validation_error

$magic_constants public_oe static_oe property

A static array of magic constant names used for redefining magic constant values
public static $magic_constants

$memory_usage protected_oe property

Int of the number of bytes the sandbox allocates during execution
protected $memory_usage

$name public_oe property

The randomly generated name of the PHPSandbox variable passed to the generated closure
public $name

$overwrite_defined_funcs public_oe property

Should PHPSandbox overwrite get_define_functions, get_defined_vars, get_defined_constants, get_declared_classes, get_declared_interfaces and get_declared_traits?
public $overwrite_defined_funcs

$overwrite_func_get_args public_oe property

Should PHPSandbox overwrite func_get_args, func_get_arg and func_num_args?
public $overwrite_func_get_args

$overwrite_sandboxed_string_funcs public_oe property

Should PHPSandbox overwrite functions to help hide SandboxedStrings?
public $overwrite_sandboxed_string_funcs

$overwrite_superglobals public_oe property

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.
public $overwrite_superglobals

$parsed_ast protected_oe property

Array of parsed code broken down into AST tokens, for debugging and serialization purposes
protected $parsed_ast

$prepare_time protected_oe property

Float of the number of microseconds it took to prepare the sandbox
protected $prepare_time

$prepared_ast protected_oe property

Array of prepared code broken down into AST tokens, for debugging and serialization purposes
protected $prepared_ast

$prepared_code protected_oe property

String of prepared code, for debugging and serialization purposes
protected $prepared_code

$preparsed_code protected_oe property

String of preparsed code, for debugging and serialization purposes
protected $preparsed_code

$prepended_code protected_oe property

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

$restore_error_level public_oe property

Flag to indicate whether the sandbox should return error_reporting to its previous level after execution
public $restore_error_level

$sandbox_includes public_oe property

Flag to indicate whether the sandbox should automatically sandbox included files
public $sandbox_includes

$sandboxed_string_funcs public_oe static_oe property

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
public static $sandboxed_string_funcs

$sandboxes protected_oe static_oe property

Array of PHPSandboxes
protected static $sandboxes

$superglobals public_oe static_oe property

A static array of superglobal names used for redefining superglobal values
public static $superglobals

$time_limit public_oe property

Integer value of maximum number of seconds the sandbox should be allowed to execute
public $time_limit

$validate_aliases public_oe property

Flag to indicate whether the sandbox should validate aliases (aka use)
public $validate_aliases

$validate_classes public_oe property

Flag to indicate whether the sandbox should validate classes
public $validate_classes

$validate_constants public_oe property

Flag to indicate whether the sandbox should validate constants
public $validate_constants

$validate_functions public_oe property

Flag to indicate whether the sandbox should validate functions
public $validate_functions

$validate_globals public_oe property

Flag to indicate whether the sandbox should validate globals
public $validate_globals

$validate_interfaces public_oe property

Flag to indicate whether the sandbox should validate interfaces
public $validate_interfaces

$validate_keywords public_oe property

Flag to indicate whether the sandbox should validate keywords
public $validate_keywords

$validate_magic_constants public_oe property

Flag to indicate whether the sandbox should validate magic constants
public $validate_magic_constants

$validate_namespaces public_oe property

Flag to indicate whether the sandbox should validate namespaces
public $validate_namespaces

$validate_operators public_oe property

Flag to indicate whether the sandbox should validate operators
public $validate_operators

$validate_primitives public_oe property

Flag to indicate whether the sandbox should validate primitives
public $validate_primitives

$validate_superglobals public_oe property

Flag to indicate whether the sandbox should validate superglobals
public $validate_superglobals

$validate_traits public_oe property

Flag to indicate whether the sandbox should validate traits
public $validate_traits

$validate_types public_oe property

Flag to indicate whether the sandbox should validate types
public $validate_types

$validate_variables public_oe property

Flag to indicate whether the sandbox should validate variables
public $validate_variables

$validation protected_oe property

Array of custom validation functions
protected $validation

$validation_error_handler protected_oe property

Callable that handles any thrown validation errors when set
protected $validation_error_handler

$whitelist protected_oe property

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