Documentation

NameContext
in package

Table of Contents

$aliases  : array<string|int, array<string|int, Name>>
$errorHandler  : ErrorHandler
$namespace  : null|Name
$origAliases  : array<string|int, array<string|int, Name>>
__construct()  : mixed
Create a name context.
addAlias()  : mixed
Add an alias / import.
getNamespace()  : null|Name
Get current namespace.
getPossibleNames()  : array<string|int, Name>
Get possible ways of writing a fully qualified name (e.g., by making use of aliases).
getResolvedClassName()  : Name
Get resolved class name.
getResolvedName()  : null|Name
Get resolved name.
getShortName()  : Name
Get shortest representation of this fully-qualified name.
startNamespace()  : mixed
Start a new namespace.
getNamespaceRelativeName()  : mixed
normalizeConstName()  : mixed
resolveAlias()  : mixed

Properties

$aliases

protected array<string|int, array<string|int, Name>> $aliases = []

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

$origAliases

protected array<string|int, array<string|int, Name>> $origAliases = []

Same as $aliases but preserving original case

Methods

__construct()

Create a name context.

public __construct(ErrorHandler $errorHandler) : mixed
Parameters
$errorHandler : ErrorHandler

Error handling used to report errors

Return values
mixed

addAlias()

Add an alias / import.

public addAlias(Name $name, string $aliasName, int $type[, array<string|int, mixed> $errorAttrs = [] ]) : mixed
Parameters
$name : Name

Original name

$aliasName : string

Aliased name

$type : int

One of Stmt\Use_::TYPE_*

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

Attributes to use to report an error

Return values
mixed

getNamespace()

Get current namespace.

public getNamespace() : null|Name
Return values
null|Name

Namespace (or null if global namespace)

getPossibleNames()

Get possible ways of writing a fully qualified name (e.g., by making use of aliases).

public getPossibleNames(string $name, int $type) : array<string|int, Name>
Parameters
$name : string

Fully-qualified name (without leading namespace separator)

$type : int

One of Stmt\Use_::TYPE_*

Return values
array<string|int, Name>

Possible representations of the name

getResolvedClassName()

Get resolved class name.

public getResolvedClassName(Name $name) : Name
Parameters
$name : Name

Class ame to resolve

Return values
Name

Resolved name

getResolvedName()

Get resolved name.

public getResolvedName(Name $name, int $type) : null|Name
Parameters
$name : Name

Name to resolve

$type : int

One of Stmt\Use_::TYPE_{FUNCTION|CONSTANT}

Return values
null|Name

Resolved name, or null if static resolution is not possible

getShortName()

Get shortest representation of this fully-qualified name.

public getShortName(string $name, int $type) : Name
Parameters
$name : string

Fully-qualified name (without leading namespace separator)

$type : int

One of Stmt\Use_::TYPE_*

Return values
Name

Shortest representation

startNamespace()

Start a new namespace.

public startNamespace([Name|null $namespace = null ]) : mixed

This also resets the alias table.

Parameters
$namespace : Name|null = null

Null is the global namespace

Return values
mixed

getNamespaceRelativeName()

private getNamespaceRelativeName(string $name, string $lcName, int $type) : mixed
Parameters
$name : string
$lcName : string
$type : int
Return values
mixed

normalizeConstName()

private normalizeConstName(string $name) : mixed
Parameters
$name : string
Return values
mixed

resolveAlias()

private resolveAlias(Name $name, mixed $type) : mixed
Parameters
$name : Name
$type : mixed
Return values
mixed

Search results