Properties

$namespace

$namespace : null|\PhpParser\Node\Name

Type

null|\PhpParser\Node\Name — Current namespace

$aliases

$aliases : array

Type

array — Map of format [aliasType => [aliasName => originalName]]

$preserveOriginalNames

$preserveOriginalNames : boolean

Type

boolean — Whether to preserve original names

Methods

beforeTraverse()

beforeTraverse(array  $nodes) : null|array<mixed,\PhpParser\Node>

Called once before traversal.

Return value semantics:

  • null: $nodes stays as-is
  • otherwise: $nodes is set to the return value

Parameters

array $nodes

Array of nodes

Returns

null|array<mixed,\PhpParser\Node> —

Array of nodes

enterNode()

enterNode(\PhpParser\Node  $node) : null|integer|\PhpParser\Node

Called when entering a 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

\PhpParser\Node $node

Node

Returns

null|integer|\PhpParser\Node

Node

leaveNode()

leaveNode(\PhpParser\Node  $node) : null|false|integer|\PhpParser\Node|array<mixed,\PhpParser\Node>

Called when leaving a node.

Return value semantics:

  • null => $node stays as-is
  • NodeTraverser::REMOVE_NODE => $node is removed from the parent array
  • NodeTraverser::STOP_TRAVERSAL => Traversal is aborted. $node stays as-is
  • array (of Nodes) => The return value is merged into the parent array (at the position of the $node)
  • otherwise => $node is set to the return value

Parameters

\PhpParser\Node $node

Node

Returns

null|false|integer|\PhpParser\Node|array<mixed,\PhpParser\Node> —

Node

afterTraverse()

afterTraverse(array  $nodes) : null|array<mixed,\PhpParser\Node>

Called once after traversal.

Return value semantics:

  • null: $nodes stays as-is
  • otherwise: $nodes is set to the return value

Parameters

array $nodes

Array of nodes

Returns

null|array<mixed,\PhpParser\Node> —

Array of nodes

__construct()

__construct(\PhpParser\ErrorHandler|null  $errorHandler = null, array  $options = array()) 

Constructs a name resolution visitor.

Options: If "preserveOriginalNames" is enabled, an "originalName" attribute will be added to all name nodes that underwent resolution.

Parameters

\PhpParser\ErrorHandler|null $errorHandler

Error handler

array $options

Options

resetState()

resetState(\PhpParser\Node\Name  $namespace = null) 

Parameters

\PhpParser\Node\Name $namespace

resolveClassName()

resolveClassName(\PhpParser\Node\Name  $name) 

Parameters

\PhpParser\Node\Name $name

resolveOtherName()

resolveOtherName(\PhpParser\Node\Name  $name,   $type) 

Parameters

\PhpParser\Node\Name $name
$type

addNamespacedName()

addNamespacedName(\PhpParser\Node  $node) 

Parameters

\PhpParser\Node $node

resolveType()

resolveType(  $node) 

Parameters

$node