\PHPSandboxValidatorVisitor

Validator class for PHP Sandboxes.

This class takes parsed AST code and checks it against the passed PHPSandbox instance configuration for errors, and throws exceptions if they are found

Summary

Methods
Properties
Constants
__construct()
leaveNode()
No public properties found
No constants found
isMagicConst()
isKeyword()
isOperator()
isPrimitive()
$sandbox
N/A
No private methods found
No private properties found
N/A

Properties

$sandbox

$sandbox : \PHPSandbox\PHPSandbox

The PHPSandbox instance to check against

Type

\PHPSandbox\PHPSandbox

Methods

__construct()

__construct(\PHPSandbox\PHPSandbox  $sandbox) 

ValidatorVisitor class constructor

This constructor takes a passed PHPSandbox instance to check against for validating sandboxed code.

Parameters

\PHPSandbox\PHPSandbox $sandbox

The PHPSandbox instance to check against

leaveNode()

leaveNode(\PhpParser\Node  $node) : \PhpParser\Node|boolean|null

Examine the current PhpParser_Node node against the PHPSandbox configuration for validating sandboxed code

Parameters

\PhpParser\Node $node

The sandboxed $node to validate

Throws

\PHPSandbox\Error

Throws an exception if validation fails

Returns

\PhpParser\Node|boolean|null —

Return rewritten node, false if node must be removed, or null if no changes to the node are made

isMagicConst()

isMagicConst(\PhpParser\Node  $node) : string|null

Test the current PhpParser_Node node to see if it is a magic constant, and return the name if it is and null if it is not

Parameters

\PhpParser\Node $node

The sandboxed $node to test

Returns

string|null —

Return string name of node, or null if it is not a magic constant

isKeyword()

isKeyword(\PhpParser\Node  $node) : string|null

Test the current PhpParser_Node node to see if it is a keyword, and return the name if it is and null if it is not

Parameters

\PhpParser\Node $node

The sandboxed $node to test

Returns

string|null —

Return string name of node, or null if it is not a keyword

isOperator()

isOperator(\PhpParser\Node  $node) : string|null

Test the current PhpParser_Node node to see if it is an operator, and return the name if it is and null if it is not

Parameters

\PhpParser\Node $node

The sandboxed $node to test

Returns

string|null —

Return string name of node, or null if it is not an operator

isPrimitive()

isPrimitive(\PhpParser\Node  $node) : string|null

Test the current PhpParser_Node node to see if it is a primitive, and return the name if it is and null if it is not

Parameters

\PhpParser\Node $node

The sandboxed $node to test

Returns

string|null —

Return string name of node, or null if it is not a primitive