PHPSandbox

ValidatorVisitor extends NodeVisitorAbstract
in package

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

Tags
namespace

PHPSandbox

author

Elijah Horton [email protected]

version
3.0

Table of Contents

$sandbox  : PHPSandbox
The PHPSandbox instance to check against
__construct()  : mixed
ValidatorVisitor class constructor
leaveNode()  : Node|bool|null
Examine the current PhpParser_Node node against the PHPSandbox configuration for validating sandboxed code
isKeyword()  : 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
isMagicConst()  : 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
isOperator()  : 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
isPrimitive()  : 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

Properties

Methods

__construct()

ValidatorVisitor class constructor

public __construct(PHPSandbox $sandbox) : mixed

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

Parameters
$sandbox : PHPSandbox

The PHPSandbox instance to check against

Return values
mixed

leaveNode()

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

public leaveNode(Node $node) : Node|bool|null
Parameters
$node : Node

The sandboxed $node to validate

Tags
throws
Throwable

Throws an exception if validation fails

Return values
Node|bool|null

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

isKeyword()

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

protected isKeyword(Node $node) : string|null
Parameters
$node : Node

The sandboxed $node to test

Return values
string|null

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

isMagicConst()

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

protected isMagicConst(Node $node) : string|null
Parameters
$node : Node

The sandboxed $node to test

Return values
string|null

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

isOperator()

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

protected isOperator(Node $node) : string|null
Parameters
$node : Node

The sandboxed $node to test

Return values
string|null

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

isPrimitive()

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

protected isPrimitive(Node $node) : string|null
Parameters
$node : Node

The sandboxed $node to test

Return values
string|null

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

Search results