ValidConstantPass
extends NamespaceAwarePass
in package
Validate that namespaced constant references will succeed.
This pass throws a FatalErrorException rather than letting PHP run headfirst into a real fatal error and die.
Tags
Table of Contents
- $currentScope : mixed
- $namespace : mixed
- afterTraverse() : null|array<string|int, Node>
- Called once after traversal.
- beforeTraverse() : null|array<string|int, Node>
- Called once before traversal.
- enterNode() : null|int|Node
- Called when entering a node.
- leaveNode() : mixed
- Validate that namespaced constant references will succeed.
- getFullyQualifiedName() : string
- Get a fully-qualified name (class, function, interface, etc).
- validateClassConstFetchExpression() : mixed
- Validate a class constant fetch expression.
Properties
$currentScope
protected
mixed
$currentScope
$namespace
protected
mixed
$namespace
Methods
afterTraverse()
Called once after traversal.
public
afterTraverse(array<string|int, mixed> $nodes) : null|array<string|int, Node>
Return value semantics:
- null: $nodes stays as-is
- otherwise: $nodes is set to the return value
Parameters
- $nodes : array<string|int, mixed>
-
Array of nodes
Return values
null|array<string|int, Node> —Array of nodes
beforeTraverse()
Called once before traversal.
public
beforeTraverse(array<string|int, mixed> $nodes) : null|array<string|int, Node>
Return value semantics:
- null: $nodes stays as-is
- otherwise: $nodes is set to the return value
Parameters
- $nodes : array<string|int, mixed>
-
Array of nodes
Return values
null|array<string|int, Node> —Array of nodes
enterNode()
Called when entering a node.
public
enterNode(Node $node) : null|int|Node
Return value semantics:
- null => $node stays as-is
- NodeTraverser::DONT_TRAVERSE_CHILDREN => Children of $node are not traversed. $node stays as-is
- NodeTraverser::STOP_TRAVERSAL => Traversal is aborted. $node stays as-is
- otherwise => $node is set to the return value
Parameters
- $node : Node
-
Node
Return values
null|int|Node —Replacement node (or special return value)
leaveNode()
Validate that namespaced constant references will succeed.
public
leaveNode(Node $node) : mixed
Note that this does not (yet) detect constants defined in the current code snippet. It won't happen very often, so we'll punt for now.
Parameters
- $node : Node
Tags
Return values
mixed —getFullyQualifiedName()
Get a fully-qualified name (class, function, interface, etc).
protected
getFullyQualifiedName(mixed $name) : string
Parameters
- $name : mixed
Return values
string —validateClassConstFetchExpression()
Validate a class constant fetch expression.
protected
validateClassConstFetchExpression(ClassConstFetch $stmt) : mixed
Parameters
- $stmt : ClassConstFetch