Documentation

NameContext
in package

Table of Contents

Properties

$aliases  : array<string|int, array<string|int, Name>>
$errorHandler  : ErrorHandler
$namespace  : null|Name
$origAliases  : array<string|int, array<string|int, Name>>

Methods

__construct()  : mixed
Create a name context.
addAlias()  : void
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()  : void
Start a new namespace.
getNamespaceRelativeName()  : Name|null
normalizeConstName()  : string
resolveAlias()  : FullyQualified|null

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

addAlias()

Add an alias / import.

public addAlias(Name $name, string $aliasName, Use_::TYPE_* $type[, array<string, mixed> $errorAttrs = [] ]) : void
Parameters
$name : Name

Original name

$aliasName : string

Aliased name

$type : Use_::TYPE_*

One of Stmt\Use_::TYPE_*

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

Attributes to use to report an error

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, Use_::TYPE_* $type) : array<string|int, Name>
Parameters
$name : string

Fully-qualified name (without leading namespace separator)

$type : Use_::TYPE_*

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, Use_::TYPE_* $type) : null|Name
Parameters
$name : Name

Name to resolve

$type : Use_::TYPE_*

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, Use_::TYPE_* $type) : Name
Parameters
$name : string

Fully-qualified name (without leading namespace separator)

$type : Use_::TYPE_*

One of Stmt\Use_::TYPE_*

Return values
Name

Shortest representation

startNamespace()

Start a new namespace.

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

This also resets the alias table.

Parameters
$namespace : Name|null = null

Null is the global namespace

getNamespaceRelativeName()

private getNamespaceRelativeName(string $name, string $lcName, int $type) : Name|null
Parameters
$name : string
$lcName : string
$type : int
Return values
Name|null

normalizeConstName()

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

        
On this page

Search results