Menu

## NameResolver extends NodeVisitorAbstract
in package

NameResolver.php : 14

### Table of Contents

$nameContext : NameContext
$preserveOriginalNames : bool
$replaceNodes : bool
__construct() : mixed
  Constructs a name resolution visitor.
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.
getNameContext() : NameContext
  Get name resolution context.
leaveNode() : null|int|Node|array<string|int, Node>
  Called when leaving a node.
addNamespacedName() : mixed
resolveAttrGroups() : mixed
resolveClassName() : mixed
resolveName() : Name
  Resolve name, according to name resolver options.
addAlias() : mixed
resolveSignature() : mixed
resolveType() : mixed

### Properties

#### $nameContext

NameResolver.php : 17
`protected NameContext $nameContext`

Naming context

#### $preserveOriginalNames

NameResolver.php : 20
`protected bool $preserveOriginalNames`

Whether to preserve original names

#### $replaceNodes

NameResolver.php : 23
`protected bool $replaceNodes`

Whether to replace resolved nodes in place, or to add resolvedNode attributes

### Methods

#### __construct()

NameResolver.php : 38

Constructs a name resolution visitor.

`public __construct([ErrorHandler|null $errorHandler = null ][, array<string|int, mixed> $options = [] ]) : mixed`

Options:

- preserveOriginalNames (default false): An "originalName" attribute will be added to all name nodes that underwent resolution.
- replaceNodes (default true): Resolved names are replaced in-place. Otherwise, a resolvedName attribute is added. (Names that cannot be statically resolved receive a namespacedName attribute, as usual.)

##### Parameters

$errorHandler : ErrorHandler|null = null

  Error handler

$options : array<string|int, mixed> = []

  Options

##### Return values

mixed —

#### afterTraverse()

NodeVisitorAbstract.php : 22

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

NameResolver.php : 53

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

NameResolver.php : 58

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)

#### getNameContext()

NameResolver.php : 49

Get name resolution context.

`public getNameContext() : NameContext`

##### Return values

NameContext —

#### leaveNode()

NodeVisitorAbstract.php : 18

Called when leaving a node.

`public leaveNode(Node $node) : null|int|Node|array<string|int, 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

$node : Node

  Node

##### Return values

null|int|Node|array<string|int, Node> —

Replacement node (or special return value)

#### addNamespacedName()

NameResolver.php : 244
`protected addNamespacedName(Node $node) : mixed`

##### Parameters

$node : Node

##### Return values

mixed —

#### resolveAttrGroups()

NameResolver.php : 249
`protected resolveAttrGroups(Node $node) : mixed`

##### Parameters

$node : Node

##### Return values

mixed —

#### resolveClassName()

NameResolver.php : 240
`protected resolveClassName(Name $name) : mixed`

##### Parameters

$name : Name

##### Return values

mixed —

#### resolveName()

NameResolver.php : 209

Resolve name, according to name resolver options.

`protected resolveName(Name $name, int $type) : Name`

##### Parameters

$name : Name

  Function or constant name to resolve

$type : int

  One of Stmt\Use_::TYPE_*

##### Return values

Name —

Resolved name, or original name with attribute

#### addAlias()

NameResolver.php : 164
`private addAlias(UseUse $use, mixed $type[, Name $prefix = null ]) : mixed`

##### Parameters

$use : UseUse
$type : mixed
$prefix : Name = null

##### Return values

mixed —

#### resolveSignature()

NameResolver.php : 176
`private resolveSignature(Function_|ClassMethod|Closure $node) : mixed`

##### Parameters

$node : Function_|ClassMethod|Closure

##### Return values

mixed —

#### resolveType()

NameResolver.php : 184
`private resolveType(mixed $node) : mixed`

##### Parameters

$node : mixed

##### Return values

mixed —

## Search results