PHP Класс 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
Автор: Elijah Horton ([email protected])
Наследование: implements IteratorAggregate
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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)

Свойство Тип Описание
$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

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
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

Описание методов

__call() публичный Метод

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
Результат mixed

__construct() публичный Метод

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() публичный Метод

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
Результат mixed The output of the executed sandboxed code

__sleep() публичный Метод

PHPSandbox __sleep magic method
public __sleep ( ) : array
Результат array An array of property keys to be serialized

_arrayval() публичный Метод

Return array value of SandboxedString or mixed value
public _arrayval ( mixed $value ) : array
$value mixed Value to return as array
Результат array Returns the array value

_boolval() публичный Метод

Return boolean value of SandboxedString or mixed value
public _boolval ( mixed $value ) : boolean
$value mixed Value to return as boolean
Результат boolean Returns the boolean value

_floatval() публичный Метод

Return float value of SandboxedString or mixed value
public _floatval ( mixed $value ) : float
$value mixed Value to return as float
Результат float Returns the float value

_func_get_arg() публичный Метод

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
Результат array Returns the redefined argument

_func_get_args() публичный Метод

Get PHPSandbox redefined function arguments array
public _func_get_args ( array $arguments = [] ) : array
$arguments array Array result from func_get_args() is passed here
Результат array Returns the redefined arguments array

_func_num_args() публичный Метод

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
Результат integer Returns the redefined number of function arguments

_get_declared_classes() публичный Метод

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
Результат array Returns the redefined classes

_get_declared_interfaces() публичный Метод

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
Результат array Returns the redefined interfaces

_get_declared_traits() публичный Метод

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
Результат array Returns the redefined traits

_get_defined_constants() публичный Метод

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
Результат array Returns the redefined constants

_get_defined_functions() публичный Метод

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
Результат array Returns the redefined functions array

_get_defined_vars() публичный Метод

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
Результат array Returns the redefined variables array

_get_included_files() публичный Метод

Return get_included_files() and sandboxed included files
public _get_included_files ( ) : array
Результат array Returns array of get_included_files() and sandboxed included files

_get_magic_const() публичный Метод

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.)
Результат array Returns the redefined magic constant

_get_superglobal() публичный Метод

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.)
Результат array Returns the redefined superglobal

_include() публичный Метод

Sandbox included file
public _include ( string $file ) : mixed
$file string Included file to sandbox
Результат mixed Returns value passed from included file

_include_once() публичный Метод

Sandbox included once file
public _include_once ( string $file ) : mixed
$file string Included once file to sandbox
Результат mixed Returns value passed from included once file

_intval() публичный Метод

Return integer value of SandboxedString or mixed value
public _intval ( mixed $value ) : integer
$value mixed Value to return as integer
Результат integer Returns the integer value

_is_callable() публичный Метод

Return is_callable value of SandboxedString or mixed value
public _is_callable ( mixed $value ) : boolean
$value mixed Value to check if is_callable
Результат boolean Returns the is_callable value

_is_object() публичный Метод

Return is_object value of SandboxedString or mixed value
public _is_object ( mixed $value ) : boolean
$value mixed Value to check if is_object
Результат boolean Returns the is_object value

_is_scalar() публичный Метод

Return is_scalar value of SandboxedString or mixed value
public _is_scalar ( mixed $value ) : boolean
$value mixed Value to check if is_scalar
Результат boolean Returns the is_scalar value

_is_string() публичный Метод

Return is_string value of SandboxedString or mixed value
public _is_string ( mixed $value ) : boolean
$value mixed Value to check if is_string
Результат boolean Returns the is_string value

_objectval() публичный Метод

Return object value of SandboxedString or mixed value
public _objectval ( mixed $value ) : object
$value mixed Value to return as object
Результат object Returns the object value

_print_r() публичный Метод

Get PHPSandbox redefined print_r
public _print_r ( ) : array
Результат array Returns the redefined print_r

_require() публичный Метод

Sandbox required file
public _require ( string $file ) : mixed
$file string Required file to sandbox
Результат mixed Returns value passed from required file

_require_once() публичный Метод

Sandbox required once file
public _require_once ( string $file ) : mixed
$file string Required once file to sandbox
Результат mixed Returns value passed from required once file

_var_dump() публичный Метод

Get PHPSandbox redefined var_dump
public _var_dump ( ) : array
Результат array Returns the redefined var_dump

_var_export() публичный Метод

Get PHPSandbox redefined var_export
public _var_export ( ) : array
Результат array Returns the redefined var_export

append() публичный Метод

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

autoDefine() защищенный Метод

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

autoWhitelist() защищенный Метод

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)
Результат mixed Return result of error handler if $code could not be parsed

blacklist() публичный Метод

You can pass an associative array of blacklist types and their names, or a string $type and array of $names, or pass a string of the $type and $name
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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

Get PHPSandbox redefined function. This is an internal PHPSandbox function but requires public access to work.
public call_func ( ) : mixed
Результат mixed Returns the redefined function result

checkAlias() публичный Метод

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
Результат boolean Returns true if alias is valid

checkClass() публичный Метод

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
Результат boolean Returns true if class is valid

checkConst() публичный Метод

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
Результат boolean Returns true if constant is valid

checkFunc() публичный Метод

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
Результат boolean Returns true if function is valid, this is also used for testing closures

checkGlobal() публичный Метод

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
Результат boolean Returns true if global is valid

checkInterface() публичный Метод

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
Результат boolean Returns true if interface is valid

checkKeyword() публичный Метод

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
Результат boolean Returns true if keyword is valid

checkMagicConst() публичный Метод

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
Результат boolean Returns true if magic constant is valid

checkNamespace() публичный Метод

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
Результат boolean Returns true if namespace is valid

checkOperator() публичный Метод

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
Результат boolean Returns true if operator is valid

checkPrimitive() публичный Метод

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
Результат boolean Returns true if primitive is valid

checkSuperglobal() публичный Метод

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
Результат boolean Returns true if superglobal is valid

checkTrait() публичный Метод

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
Результат boolean Returns true if trait is valid

checkType() публичный Метод

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
Результат boolean Returns true if type is valid

checkUse() публичный Метод

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
Результат boolean Returns true if use (or alias) is valid

checkVar() публичный Метод

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
Результат boolean Returns true if variable is valid

clear() публичный Метод

Clear all trusted and sandboxed code
public clear ( )

clearAppend() публичный Метод

Clear all appended trusted code
public clearAppend ( )

clearAppendedCode() публичный Метод

Clear all appended trusted code
public clearAppendedCode ( )

clearCode() публичный Метод

Clear generated code
public clearCode ( )

clearPrepended() публичный Метод

Clear all prepended trusted code
public clearPrepended ( )

clearPrependedCode() публичный Метод

Clear all prepended trusted code
public clearPrependedCode ( )

clearTrustedCode() публичный Метод

Clear all trusted code
public clearTrustedCode ( )

create() публичный статический Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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

defineConst() публичный Метод

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() публичный Метод

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

defineFunc() публичный Метод

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() публичный Метод

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

defineInterface() публичный Метод

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() публичный Метод

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

defineMagicConst() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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

defineSuperglobal() публичный Метод

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() публичный Метод

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

defineTrait() публичный Метод

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() публичный Метод

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

defineUse() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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

dewhitelist() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() защищенный Метод

Disassemble callable to string
protected disassemble ( callable $closure ) : string
$closure callable The callable to disassemble
Результат string Return the disassembled code string

error() публичный Метод

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
Результат mixed

exception() публичный Метод

Invoke sandbox exception handler
public exception ( Exception $exception ) : mixed
$exception Exception Error number
Результат mixed

execute() публичный Метод

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.
Результат mixed The output from the executed sandboxed code

getAliasValidator() публичный Метод

Get validation callable for aliases
public getAliasValidator ( ) : callable | null
Результат callable | null

getAppendedCode() публичный Метод

Get PHPSandbox appended code
public getAppendedCode ( ) : string
Результат string Returns a string of the appended code

getClassValidator() публичный Метод

Get validation callable for classes
public getClassValidator ( ) : callable | null
Результат callable | null

getCode() публичный Метод

Get PHPSandbox generated code
public getCode ( ) : string
Результат string Returns a string of the generated code

getConstValidator() публичный Метод

Get validation callable for constants
public getConstValidator ( ) : callable | null
Результат callable | null

getDefinedClass() публичный Метод

Get defined class of $name
public getDefinedClass ( string $name ) : string
$name string String of class $name to get
Результат string Returns string of defined class value

getDefinedInterface() публичный Метод

Get defined interface of $name
public getDefinedInterface ( string $name ) : string
$name string String of interface $name to get
Результат string Returns string of defined interface value

getDefinedNamespace() публичный Метод

Get defined namespace of $name
public getDefinedNamespace ( string $name ) : string
$name string String of namespace $name to get
Результат string Returns string of defined namespace value

getDefinedTrait() публичный Метод

Get defined trait of $name
public getDefinedTrait ( string $name ) : string
$name string String of trait $name to get
Результат string Returns string of defined trait value

getErrorHandler() публичный Метод

This function returns the sandbox error handler.
public getErrorHandler ( ) : null | callable
Результат null | callable

getExceptionHandler() публичный Метод

This function returns the sandbox exception handler.
public getExceptionHandler ( ) : null | callable
Результат null | callable

getExecutionTime() публичный Метод

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
Результат float The amount of time in microseconds it took to execute the sandboxed code

getFuncValidator() публичный Метод

Get validation for functions
public getFuncValidator ( ) : callable | null
Результат callable | null

getGeneratedCode() публичный Метод

Get PHPSandbox generated code
public getGeneratedCode ( ) : string
Результат string Returns a string of the generated code

getGlobalValidator() публичный Метод

Get validation callable for globals
public getGlobalValidator ( ) : callable | null
Результат callable | null

getInterfaceValidator() публичный Метод

Get validation callable for interfaces
public getInterfaceValidator ( ) : callable | null
Результат callable | null

getIterator() публичный Метод

Get an iterator of all the public PHPSandbox properties
public getIterator ( ) : array
Результат array

getKeywordValidator() публичный Метод

Get validation callable for keywords
public getKeywordValidator ( ) : callable | null
Результат callable | null

getLastError() публичный Метод

Gets the last sandbox error
public getLastError ( ) : array
Результат array

getLastException() публичный Метод

Gets the last exception thrown by the sandbox
public getLastException ( ) : Exception | Error
Результат Exception | Error

getLastValidationError() публичный Метод

Gets the last validation error thrown by the sandbox
public getLastValidationError ( ) : Exception | Error
Результат Exception | Error

getMagicConstValidator() публичный Метод

Get validation callable for magic constants
public getMagicConstValidator ( ) : callable | null
Результат callable | null

getMemoryUsage() публичный Метод

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
Результат integer The amount of bytes in memory it took to prepare and execute the sandboxed code

getName() публичный Метод

Get name of PHPSandbox variable
public getName ( ) : string
Результат string The name of the PHPSandbox variable

getNamespaceValidator() публичный Метод

Get validation callable for namespaces
public getNamespaceValidator ( ) : callable | null
Результат callable | null

getOperatorValidator() публичный Метод

Get validation callable for operators
public getOperatorValidator ( ) : callable | null
Результат callable | null

getOption() публичный Метод

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
Результат boolean | integer | null Returns the value of the requested option

getParsedAST() публичный Метод

Get PHPSandbox parsed AST array
public getParsedAST ( ) : array
Результат array Returns an array of the parsed AST code

getPreparedAST() публичный Метод

Get PHPSandbox prepared AST array
public getPreparedAST ( ) : array
Результат array Returns an array of the prepared AST code

getPreparedCode() публичный Метод

Get PHPSandbox prepared code
public getPreparedCode ( ) : string
Результат string Returns a string of the prepared code

getPreparedTime() публичный Метод

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
Результат float The amount of time in microseconds it took to prepare the sandboxed code

getPreparsedCode() публичный Метод

Get PHPSandbox preparsed code
public getPreparsedCode ( ) : string
Результат string Returns a string of the preparsed code

getPrependedCode() публичный Метод

Get PHPSandbox prepended code
public getPrependedCode ( ) : string
Результат string Returns a string of the prepended code

getPrimitiveValidator() публичный Метод

Get validation callable for primitives
public getPrimitiveValidator ( ) : callable | null
Результат callable | null

getSandbox() публичный статический Метод

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
Результат null | PHPSandbox

getSuperglobalValidator() публичный Метод

Get validation callable for superglobals
public getSuperglobalValidator ( ) : callable | null
Результат callable | null

getTime() публичный Метод

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
Результат float The amount of time in microseconds it took to prepare and execute the sandboxed code

getTraitValidator() публичный Метод

Get validation callable for traits
public getTraitValidator ( ) : callable | null
Результат callable | null

getTypeValidator() публичный Метод

Get validation callable for types
public getTypeValidator ( ) : callable | null
Результат callable | null

getUseValidator() публичный Метод

Get validation callable for uses (aka aliases)
public getUseValidator ( ) : callable | null
Результат callable | null

getValidationErrorHandler() публичный Метод

This function returns the sandbox validation error handler.
public getValidationErrorHandler ( ) : null | callable
Результат null | callable

getValidator() публичный Метод

Get validation callable for specified $type
public getValidator ( string $type ) : callable | null
$type string String of $type to return
Результат callable | null

getVarValidator() публичный Метод

Get validation callable for variables
public getVarValidator ( ) : callable | null
Результат callable | null

hasBlacklist() публичный Метод

Query whether PHPSandbox instance has blacklist type.
public hasBlacklist ( string $type ) : integer
$type string The blacklist type to query
Результат integer Returns the number of blacklists this instance has defined

hasBlacklistedAliases() публичный Метод

Query whether PHPSandbox instance has blacklisted aliases.
public hasBlacklistedAliases ( ) : integer
Результат integer Returns the number of blacklisted aliases this instance has defined

hasBlacklistedClasses() публичный Метод

Query whether PHPSandbox instance has blacklisted classes.
public hasBlacklistedClasses ( ) : integer
Результат integer Returns the number of blacklisted classes this instance has defined

hasBlacklistedConsts() публичный Метод

Query whether PHPSandbox instance has blacklisted constants.
public hasBlacklistedConsts ( ) : integer
Результат integer Returns the number of blacklisted constants this instance has defined

hasBlacklistedFuncs() публичный Метод

Query whether PHPSandbox instance has blacklisted functions.
public hasBlacklistedFuncs ( ) : integer
Результат integer Returns the number of blacklisted functions this instance has defined

hasBlacklistedGlobals() публичный Метод

Query whether PHPSandbox instance has blacklisted globals.
public hasBlacklistedGlobals ( ) : integer
Результат integer Returns the number of blacklisted globals this instance has defined

hasBlacklistedInterfaces() публичный Метод

Query whether PHPSandbox instance has blacklisted interfaces.
public hasBlacklistedInterfaces ( ) : integer
Результат integer Returns the number of blacklisted interfaces this instance has defined

hasBlacklistedKeywords() публичный Метод

Query whether PHPSandbox instance has blacklisted keywords.
public hasBlacklistedKeywords ( ) : integer
Результат integer Returns the number of blacklisted keywords this instance has defined

hasBlacklistedMagicConsts() публичный Метод

Query whether PHPSandbox instance has blacklisted magic constants.
public hasBlacklistedMagicConsts ( ) : integer
Результат integer Returns the number of blacklisted magic constants this instance has defined

hasBlacklistedNamespaces() публичный Метод

Query whether PHPSandbox instance has blacklisted namespaces.
public hasBlacklistedNamespaces ( ) : integer
Результат integer Returns the number of blacklisted namespaces this instance has defined

hasBlacklistedOperators() публичный Метод

Query whether PHPSandbox instance has blacklisted operators.
public hasBlacklistedOperators ( ) : integer
Результат integer Returns the number of blacklisted operators this instance has defined

hasBlacklistedPrimitives() публичный Метод

Query whether PHPSandbox instance has blacklisted primitives.
public hasBlacklistedPrimitives ( ) : integer
Результат integer Returns the number of blacklisted primitives this instance has defined

hasBlacklistedSuperglobals() публичный Метод

Query whether PHPSandbox instance has blacklisted superglobals, or superglobal keys
public hasBlacklistedSuperglobals ( string $name = null ) : integer
$name string The blacklist superglobal key to query
Результат integer Returns the number of blacklisted superglobals or superglobal keys this instance has defined

hasBlacklistedTraits() публичный Метод

Query whether PHPSandbox instance has blacklisted traits.
public hasBlacklistedTraits ( ) : integer
Результат integer Returns the number of blacklisted traits this instance has defined

hasBlacklistedTypes() публичный Метод

Query whether PHPSandbox instance has blacklisted types.
public hasBlacklistedTypes ( ) : integer
Результат integer Returns the number of blacklisted types this instance has defined

hasBlacklistedUses() публичный Метод

Query whether PHPSandbox instance has blacklisted uses (or aliases.)
public hasBlacklistedUses ( ) : integer
Результат integer Returns the number of blacklisted uses (or aliases) this instance has defined

hasBlacklistedVars() публичный Метод

Query whether PHPSandbox instance has blacklisted variables.
public hasBlacklistedVars ( ) : integer
Результат integer Returns the number of blacklisted variables this instance has defined

hasDefinedAliases() публичный Метод

Query whether PHPSandbox instance has defined aliases
public hasDefinedAliases ( ) : integer
Результат integer Returns the number of aliases this instance has defined

hasDefinedClasses() публичный Метод

Query whether PHPSandbox instance has defined classes
public hasDefinedClasses ( ) : integer
Результат integer Returns the number of classes this instance has defined

hasDefinedConsts() публичный Метод

Query whether PHPSandbox instance has defined constants
public hasDefinedConsts ( ) : integer
Результат integer Returns the number of constants this instance has defined

hasDefinedFuncs() публичный Метод

Query whether PHPSandbox instance has defined functions
public hasDefinedFuncs ( ) : integer
Результат integer Returns the number of functions this instance has defined

hasDefinedInterfaces() публичный Метод

Query whether PHPSandbox instance has defined interfaces
public hasDefinedInterfaces ( ) : integer
Результат integer Returns the number of interfaces this instance has defined

hasDefinedMagicConsts() публичный Метод

Query whether PHPSandbox instance has defined magic constants
public hasDefinedMagicConsts ( ) : integer
Результат integer Returns the number of magic constants this instance has defined

hasDefinedNamespaces() публичный Метод

Query whether PHPSandbox instance has defined namespaces
public hasDefinedNamespaces ( ) : integer
Результат integer Returns the number of namespaces this instance has defined

hasDefinedSuperglobals() публичный Метод

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
Результат integer | boolean Returns the number of superglobals or superglobal keys this instance has defined, or false if invalid superglobal name specified

hasDefinedTraits() публичный Метод

Query whether PHPSandbox instance has defined traits
public hasDefinedTraits ( ) : integer
Результат integer Returns the number of traits this instance has defined

hasDefinedUses() публичный Метод

Query whether PHPSandbox instance has defined uses (or aliases)
public hasDefinedUses ( ) : integer
Результат integer Returns the number of uses (or aliases) this instance has defined

hasDefinedVars() публичный Метод

Query whether PHPSandbox instance has defined variables
public hasDefinedVars ( ) : integer
Результат integer Returns the number of variables this instance has defined

hasWhitelist() публичный Метод

Query whether PHPSandbox instance has whitelist type
public hasWhitelist ( string $type ) : integer
$type string The whitelist type to query
Результат integer Returns the number of whitelists this instance has defined

hasWhitelistKeywords() публичный Метод

Query whether PHPSandbox instance has whitelisted keywords.
public hasWhitelistKeywords ( ) : integer
Результат integer Returns the number of whitelisted keywords this instance has defined

hasWhitelistedAliases() публичный Метод

Query whether PHPSandbox instance has whitelisted aliases.
public hasWhitelistedAliases ( ) : integer
Результат integer Returns the number of whitelisted aliases this instance has defined

hasWhitelistedClasses() публичный Метод

Query whether PHPSandbox instance has whitelisted classes.
public hasWhitelistedClasses ( ) : integer
Результат integer Returns the number of whitelisted classes this instance has defined

hasWhitelistedConsts() публичный Метод

Query whether PHPSandbox instance has whitelisted constants.
public hasWhitelistedConsts ( ) : integer
Результат integer Returns the number of whitelisted constants this instance has defined

hasWhitelistedFuncs() публичный Метод

Query whether PHPSandbox instance has whitelisted functions.
public hasWhitelistedFuncs ( ) : integer
Результат integer Returns the number of whitelisted functions this instance has defined

hasWhitelistedGlobals() публичный Метод

Query whether PHPSandbox instance has whitelisted globals.
public hasWhitelistedGlobals ( ) : integer
Результат integer Returns the number of whitelisted globals this instance has defined

hasWhitelistedInterfaces() публичный Метод

Query whether PHPSandbox instance has whitelisted interfaces.
public hasWhitelistedInterfaces ( ) : integer
Результат integer Returns the number of whitelisted interfaces this instance has defined

hasWhitelistedMagicConsts() публичный Метод

Query whether PHPSandbox instance has whitelisted magic constants.
public hasWhitelistedMagicConsts ( ) : integer
Результат integer Returns the number of whitelisted magic constants this instance has defined

hasWhitelistedNamespaces() публичный Метод

Query whether PHPSandbox instance has whitelisted namespaces.
public hasWhitelistedNamespaces ( ) : integer
Результат integer Returns the number of whitelisted namespaces this instance has defined

hasWhitelistedOperators() публичный Метод

Query whether PHPSandbox instance has whitelisted operators.
public hasWhitelistedOperators ( ) : integer
Результат integer Returns the number of whitelisted operators this instance has defined

hasWhitelistedPrimitives() публичный Метод

Query whether PHPSandbox instance has whitelisted primitives.
public hasWhitelistedPrimitives ( ) : integer
Результат integer Returns the number of whitelisted primitives this instance has defined

hasWhitelistedSuperglobals() публичный Метод

Query whether PHPSandbox instance has whitelisted superglobals, or superglobal keys
public hasWhitelistedSuperglobals ( string $name = null ) : integer
$name string The whitelist superglobal key to query
Результат integer Returns the number of whitelisted superglobals or superglobal keys this instance has defined

hasWhitelistedTraits() публичный Метод

Query whether PHPSandbox instance has whitelisted traits.
public hasWhitelistedTraits ( ) : integer
Результат integer Returns the number of whitelisted traits this instance has defined

hasWhitelistedTypes() публичный Метод

Query whether PHPSandbox instance has whitelisted types.
public hasWhitelistedTypes ( ) : integer
Результат integer Returns the number of whitelisted types this instance has defined

hasWhitelistedUses() публичный Метод

Query whether PHPSandbox instance has whitelisted uses (or aliases.)
public hasWhitelistedUses ( ) : integer
Результат integer Returns the number of whitelisted uses (or aliases) this instance has defined

hasWhitelistedVars() публичный Метод

Query whether PHPSandbox instance has whitelisted variables.
public hasWhitelistedVars ( ) : integer
Результат integer Returns the number of whitelisted variables this instance has defined

import() публичный Метод

* 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() публичный Метод

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() публичный Метод

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
Результат boolean Returns true if PHPSandbox instance has blacklisted $type and $name, false otherwise

isBlacklistedAlias() публичный Метод

Check if PHPSandbox instance has blacklisted alias name set
public isBlacklistedAlias ( string $name ) : boolean
$name string String of alias $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted alias $name, false otherwise

isBlacklistedClass() публичный Метод

Check if PHPSandbox instance has blacklisted class name set
public isBlacklistedClass ( string $name ) : boolean
$name string String of class $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted class $name, false otherwise

isBlacklistedConst() публичный Метод

Check if PHPSandbox instance has blacklisted constant name set
public isBlacklistedConst ( string $name ) : boolean
$name string String of constant $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted constant $name, false otherwise

isBlacklistedFunc() публичный Метод

Check if PHPSandbox instance has blacklisted function name set
public isBlacklistedFunc ( string $name ) : boolean
$name string String of function $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted function $name, false otherwise

isBlacklistedGlobal() публичный Метод

Check if PHPSandbox instance has blacklisted global name set
public isBlacklistedGlobal ( string $name ) : boolean
$name string String of global $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted global $name, false otherwise

isBlacklistedInterface() публичный Метод

Check if PHPSandbox instance has blacklisted interface name set
public isBlacklistedInterface ( string $name ) : boolean
$name string String of interface $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted interface $name, false otherwise

isBlacklistedKeyword() публичный Метод

Check if PHPSandbox instance has blacklisted keyword name set
public isBlacklistedKeyword ( string $name ) : boolean
$name string String of keyword $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted keyword $name, false otherwise

isBlacklistedMagicConst() публичный Метод

Check if PHPSandbox instance has blacklisted magic constant name set
public isBlacklistedMagicConst ( string $name ) : boolean
$name string String of magic constant $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted magic constant $name, false otherwise

isBlacklistedNamespace() публичный Метод

Check if PHPSandbox instance has blacklisted namespace name set
public isBlacklistedNamespace ( string $name ) : boolean
$name string String of namespace $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted namespace $name, false otherwise

isBlacklistedOperator() публичный Метод

Check if PHPSandbox instance has blacklisted operator name set
public isBlacklistedOperator ( string $name ) : boolean
$name string String of operator $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted operator $name, false otherwise

isBlacklistedPrimitive() публичный Метод

Check if PHPSandbox instance has blacklisted primitive name set
public isBlacklistedPrimitive ( string $name ) : boolean
$name string String of primitive $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted primitive $name, false otherwise

isBlacklistedSuperglobal() публичный Метод

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
Результат boolean Returns true if PHPSandbox instance has blacklisted superglobal key or superglobal, false otherwise

isBlacklistedTrait() публичный Метод

Check if PHPSandbox instance has blacklisted trait name set
public isBlacklistedTrait ( string $name ) : boolean
$name string String of trait $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted trait $name, false otherwise

isBlacklistedType() публичный Метод

Check if PHPSandbox instance has blacklisted type name set
public isBlacklistedType ( string $name ) : boolean
$name string String of type $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted type $name, false otherwise

isBlacklistedUse() публичный Метод

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
Результат boolean Returns true if PHPSandbox instance has blacklisted use (or alias) $name, false otherwise

isBlacklistedVar() публичный Метод

Check if PHPSandbox instance has blacklisted variable name set
public isBlacklistedVar ( string $name ) : boolean
$name string String of variable $name to query
Результат boolean Returns true if PHPSandbox instance has blacklisted variable $name, false otherwise

isDefinedAlias() публичный Метод

Check if PHPSandbox instance has $name alias defined
public isDefinedAlias ( string $name ) : boolean
$name string String of alias $name to query
Результат boolean Returns true if PHPSandbox instance has defined aliases, false otherwise

isDefinedClass() публичный Метод

Check if PHPSandbox instance has $name class defined
public isDefinedClass ( string $name ) : boolean
$name string String of class $name to query
Результат boolean Returns true if PHPSandbox instance has defined class, false otherwise

isDefinedConst() публичный Метод

Check if PHPSandbox instance has $name constant defined
public isDefinedConst ( string $name ) : boolean
$name string String of constant $name to query
Результат boolean Returns true if PHPSandbox instance has defined constant, false otherwise

isDefinedFunc() публичный Метод

Check if PHPSandbox instance has $name function defined
public isDefinedFunc ( string $name ) : boolean
$name string String of function $name to query
Результат boolean Returns true if PHPSandbox instance has defined function, false otherwise

isDefinedInterface() публичный Метод

Check if PHPSandbox instance has $name interface defined
public isDefinedInterface ( string $name ) : boolean
$name string String of interface $name to query
Результат boolean Returns true if PHPSandbox instance has defined interface, false otherwise

isDefinedMagicConst() публичный Метод

Check if PHPSandbox instance has $name magic constant defined
public isDefinedMagicConst ( string $name ) : boolean
$name string String of magic constant $name to query
Результат boolean Returns true if PHPSandbox instance has defined magic constant, false otherwise

isDefinedNamespace() публичный Метод

Check if PHPSandbox instance has $name namespace defined
public isDefinedNamespace ( string $name ) : boolean
$name string String of namespace $name to query
Результат boolean Returns true if PHPSandbox instance has defined namespace, false otherwise

isDefinedSuperglobal() публичный Метод

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
Результат boolean Returns true if PHPSandbox instance has defined superglobal, false otherwise

isDefinedTrait() публичный Метод

Check if PHPSandbox instance has $name trait defined
public isDefinedTrait ( string $name ) : boolean
$name string String of trait $name to query
Результат boolean Returns true if PHPSandbox instance has defined trait, false otherwise

isDefinedUse() публичный Метод

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
Результат boolean Returns true if PHPSandbox instance has defined uses (or aliases) and false otherwise

isDefinedVar() публичный Метод

Check if PHPSandbox instance has $name variable defined
public isDefinedVar ( string $name ) : boolean
$name string String of variable $name to query
Результат boolean Returns true if PHPSandbox instance has defined variable, false otherwise

isWhitelisted() публичный Метод

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
Результат boolean Returns true if PHPSandbox instance has whitelisted $type and $name, false otherwise

isWhitelistedAlias() публичный Метод

Check if PHPSandbox instance has whitelisted alias name set
public isWhitelistedAlias ( string $name ) : boolean
$name string String of alias $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted alias $name, false otherwise

isWhitelistedClass() публичный Метод

Check if PHPSandbox instance has whitelisted class name set
public isWhitelistedClass ( string $name ) : boolean
$name string String of class $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted class $name, false otherwise

isWhitelistedConst() публичный Метод

Check if PHPSandbox instance has whitelisted constant name set
public isWhitelistedConst ( string $name ) : boolean
$name string String of constant $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted constant $name, false otherwise

isWhitelistedFunc() публичный Метод

Check if PHPSandbox instance has whitelisted function name set
public isWhitelistedFunc ( string $name ) : boolean
$name string String of function $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted function $name, false otherwise

isWhitelistedGlobal() публичный Метод

Check if PHPSandbox instance has whitelisted global name set
public isWhitelistedGlobal ( string $name ) : boolean
$name string String of global $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted global $name, false otherwise

isWhitelistedInterface() публичный Метод

Check if PHPSandbox instance has whitelisted interface name set
public isWhitelistedInterface ( string $name ) : boolean
$name string String of interface $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted interface $name, false otherwise

isWhitelistedKeyword() публичный Метод

Check if PHPSandbox instance has whitelisted keyword name set
public isWhitelistedKeyword ( string $name ) : boolean
$name string String of keyword $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted keyword $name, false otherwise

isWhitelistedMagicConst() публичный Метод

Check if PHPSandbox instance has whitelisted magic constant name set
public isWhitelistedMagicConst ( string $name ) : boolean
$name string String of magic constant $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted magic constant $name, false otherwise

isWhitelistedNamespace() публичный Метод

Check if PHPSandbox instance has whitelisted namespace name set
public isWhitelistedNamespace ( string $name ) : boolean
$name string String of namespace $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted namespace $name, false otherwise

isWhitelistedOperator() публичный Метод

Check if PHPSandbox instance has whitelisted operator name set
public isWhitelistedOperator ( string $name ) : boolean
$name string String of operator $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted operator $name, false otherwise

isWhitelistedPrimitive() публичный Метод

Check if PHPSandbox instance has whitelisted primitive name set
public isWhitelistedPrimitive ( string $name ) : boolean
$name string String of primitive $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted primitive $name, false otherwise

isWhitelistedSuperglobal() публичный Метод

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
Результат boolean Returns true if PHPSandbox instance has whitelisted superglobal key or superglobal, false otherwise

isWhitelistedTrait() публичный Метод

Check if PHPSandbox instance has whitelisted trait name set
public isWhitelistedTrait ( string $name ) : boolean
$name string String of trait $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted trait $name, false otherwise

isWhitelistedType() публичный Метод

Check if PHPSandbox instance has whitelisted type name set
public isWhitelistedType ( string $name ) : boolean
$name string String of type $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted type $name, false otherwise

isWhitelistedUse() публичный Метод

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
Результат boolean Returns true if PHPSandbox instance has whitelisted use (or alias) $name, false otherwise

isWhitelistedVar() публичный Метод

Check if PHPSandbox instance has whitelisted variable name set
public isWhitelistedVar ( string $name ) : boolean
$name string String of variable $name to query
Результат boolean Returns true if PHPSandbox instance has whitelisted variable $name, false otherwise

normalizeAlias() защищенный Метод

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
Результат string | array Returns the normalized alias string or an array of normalized strings

normalizeClass() защищенный Метод

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
Результат string | array Returns the normalized class string or an array of normalized strings

normalizeFunc() защищенный Метод

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
Результат string | array Returns the normalized function string or an array of normalized strings

normalizeInterface() защищенный Метод

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
Результат string | array Returns the normalized interface string or an array of normalized strings

normalizeKeyword() защищенный Метод

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
Результат string | array Returns the normalized keyword string or an array of normalized strings

normalizeMagicConst() защищенный Метод

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
Результат string | array Returns the normalized magic constant string or an array of normalized strings

normalizeNamespace() защищенный Метод

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
Результат string | array Returns the normalized namespace string or an array of normalized strings

normalizeOperator() защищенный Метод

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
Результат string | array Returns the normalized operator string or an array of normalized strings

normalizePrimitive() защищенный Метод

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
Результат string | array Returns the normalized primitive string or an array of normalized strings

normalizeSuperglobal() защищенный Метод

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
Результат string | array Returns the normalized superglobal string or an array of normalized strings

normalizeTrait() защищенный Метод

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
Результат string | array Returns the normalized trait string or an array of normalized strings

normalizeType() защищенный Метод

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
Результат string | array Returns the normalized type string or an array of normalized strings

normalizeUse() защищенный Метод

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
Результат string | array Returns the normalized use (or alias) string or an array of normalized strings

prepare() публичный Метод

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.
Результат string The generated code (this can also be accessed via $sandbox->generated_code)

prepareAliases() защищенный Метод

Prepare defined aliases for execution
protected prepareAliases ( )

prepareConsts() защищенный Метод

Prepare defined constants for execution
protected prepareConsts ( )

prepareNamespaces() защищенный Метод

Prepare defined namespaces for execution
protected prepareNamespaces ( )

prepareUses() защищенный Метод

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

prepareVars() защищенный Метод

Prepare defined variables for execution
protected prepareVars ( ) : string
Результат string Prepared string of variable output

prepend() публичный Метод

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

resetOptions() публичный Метод

Reset PHPSandbox options to their default values
public resetOptions ( )

setAliasValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setAppendedCode() публичный Метод

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

setClassValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setCode() публичный Метод

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

setConstValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setErrorHandler() публичный Метод

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() публичный Метод

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() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setGeneratedCode() публичный Метод

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

setGlobalValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setInterfaceValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setKeywordValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setMagicConstValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setNamespaceValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setOperatorValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setOption() публичный Метод

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() публичный Метод

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() публичный Метод

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

setPreparedAST() публичный Метод

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

setPreparedCode() публичный Метод

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

setPreparsedCode() публичный Метод

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

setPrependedCode() публичный Метод

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

setPrimitiveValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setSuperglobalValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setTraitValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setTypeValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setUseValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setValidationErrorHandler() публичный Метод

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() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

setVarValidator() публичный Метод

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
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

undefine() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

Unset validation callable for aliases
public unsetAliasValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetClassValidator() публичный Метод

Unset validation callable for classes
public unsetClassValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetConstValidator() публичный Метод

Unset validation callable for constants
public unsetConstValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetErrorHandler() публичный Метод

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

unsetExceptionHandler() публичный Метод

This function unsets the sandbox exception handler.

unsetFuncValidator() публичный Метод

Unset validation callable for functions
public unsetFuncValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetGlobalValidator() публичный Метод

Unset validation callable for globals
public unsetGlobalValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetInterfaceValidator() публичный Метод

Unset validation callable for interfaces
public unsetInterfaceValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetKeywordValidator() публичный Метод

Unset validation callable for keywords
public unsetKeywordValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetMagicConstValidator() публичный Метод

Unset validation callable for magic constants
public unsetMagicConstValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetNamespaceValidator() публичный Метод

Unset validation callable for namespaces
public unsetNamespaceValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetOperatorValidator() публичный Метод

Unset validation callable for operators
public unsetOperatorValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetPrimitiveValidator() публичный Метод

Unset validation callable for primitives
public unsetPrimitiveValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetSuperglobalValidator() публичный Метод

Unset validation callable for superglobals
public unsetSuperglobalValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetTraitValidator() публичный Метод

Unset validation callable for traits
public unsetTraitValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetTypeValidator() публичный Метод

Unset validation callable for types
public unsetTypeValidator ( )

unsetUseValidator() публичный Метод

Unset validation callable for uses (aka aliases)
public unsetUseValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetValidationErrorHandler() публичный Метод

This function unsets the sandbox validation error handler.

unsetValidator() публичный Метод

Unset validation callable for specified $type
public unsetValidator ( string $type ) : PHPSandbox
$type string String of $type to unset
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

unsetVarValidator() публичный Метод

Unset validation callable for variables
public unsetVarValidator ( ) : PHPSandbox
Результат PHPSandbox Returns the PHPSandbox instance for fluent querying

validate() публичный Метод

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

validationError() публичный Метод

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
Результат mixed

whitelist() публичный Метод

You can pass an associative array of whitelist types and their names, or a string $type and array of $names, or pass a string of the $type and $name
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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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

Описание свойств

$allow_aliases публичное свойство

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

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

$allow_casting публичное свойство

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

$allow_classes публичное свойство

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

$allow_closures публичное свойство

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

$allow_constants публичное свойство

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

$allow_error_suppressing публичное свойство

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

$allow_escaping публичное свойство

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

$allow_functions публичное свойство

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

$allow_generators публичное свойство

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

$allow_globals публичное свойство

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

$allow_halting публичное свойство

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

$allow_includes публичное свойство

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

$allow_interfaces публичное свойство

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

$allow_namespaces публичное свойство

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

$allow_objects публичное свойство

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

$allow_references публичное свойство

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

$allow_static_variables публичное свойство

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

$allow_traits публичное свойство

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

$allow_variables публичное свойство

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

$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
protected $appended_code

$arg_funcs публичное статическое свойство

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 публичное свойство

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

$auto_whitelist_classes публичное свойство

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

$auto_whitelist_constants публичное свойство

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

$auto_whitelist_functions публичное свойство

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

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

$auto_whitelist_interfaces публичное свойство

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

$auto_whitelist_traits публичное свойство

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

$auto_whitelist_trusted_code публичное свойство

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

$blacklist защищенное свойство

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

$capture_output публичное свойство

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

$convert_errors публичное свойство

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

$defined_funcs публичное статическое свойство

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

$definitions защищенное свойство

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

$error_handler защищенное свойство

Callable that handles any errors when set
protected $error_handler

$error_handler_types защищенное свойство

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

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

$exception_handler защищенное свойство

Callable that handles any thrown exceptions when set
protected $exception_handler

$execution_time защищенное свойство

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

$generated_code защищенное свойство

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

$includes защищенное свойство

Array of sandboxed included files
protected $includes

$last_error защищенное свойство

The last error thrown by the sandbox
protected $last_error

$last_exception защищенное свойство

The last exception thrown by the sandbox
protected $last_exception

$last_validation_error защищенное свойство

The last validation error thrown by the sandbox
protected $last_validation_error

$magic_constants публичное статическое свойство

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

$memory_usage защищенное свойство

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

$name публичное свойство

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

$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?
public $overwrite_defined_funcs

$overwrite_func_get_args публичное свойство

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

$overwrite_sandboxed_string_funcs публичное свойство

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

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

$parsed_ast защищенное свойство

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

$prepare_time защищенное свойство

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

$prepared_ast защищенное свойство

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

$prepared_code защищенное свойство

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

$preparsed_code защищенное свойство

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

$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
protected $prepended_code

$restore_error_level публичное свойство

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

$sandbox_includes публичное свойство

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

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

$sandboxes защищенное статическое свойство

Array of PHPSandboxes
protected static $sandboxes

$superglobals публичное статическое свойство

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

$time_limit публичное свойство

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

$validate_aliases публичное свойство

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

$validate_classes публичное свойство

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

$validate_constants публичное свойство

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

$validate_functions публичное свойство

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

$validate_globals публичное свойство

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

$validate_interfaces публичное свойство

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

$validate_keywords публичное свойство

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

$validate_magic_constants публичное свойство

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

$validate_namespaces публичное свойство

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

$validate_operators публичное свойство

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

$validate_primitives публичное свойство

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

$validate_superglobals публичное свойство

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

$validate_traits публичное свойство

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

$validate_types публичное свойство

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

$validate_variables публичное свойство

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

$validation защищенное свойство

Array of custom validation functions
protected $validation

$validation_error_handler защищенное свойство

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

$whitelist защищенное свойство

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