Menu

## ValidatorVisitor extends NodeVisitorAbstract
in package

ValidatorVisitor.php : 22

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 elijah@corveda.com

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

#### $sandbox

ValidatorVisitor.php : 26

The PHPSandbox instance to check against

`protected PHPSandbox $sandbox`

### Methods

#### __construct()

ValidatorVisitor.php : 33

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()

ValidatorVisitor.php : 44

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()

ValidatorVisitor.php : 446

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()

ValidatorVisitor.php : 437

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()

ValidatorVisitor.php : 511

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()

ValidatorVisitor.php : 614

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