Copied!
CloneableInstantiable
Methods
public __construct(PhpParser\ErrorHandler $errorHandler)
 

Create a name context.

  • param \ErrorHandler $errorHandler Error handling used to report errors
public addAlias(PhpParser\Node\Name $name, string $aliasName, int $type, array $errorAttrs = []) : void
 

Add an alias / import.

  • param \Name $name Original name
  • param string $aliasName Aliased name
  • param \Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*
  • param array<string,mixed> $errorAttrs Attributes to use to report an error
public getNamespace() : ?PhpParser\Node\Name
 

Get current namespace.

  • return null|\Name Namespace (or null if global namespace)
public getPossibleNames(string $name, int $type) : array
 

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

  • param string $name Fully-qualified name (without leading namespace separator)
  • param \Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*
  • return \Name[] Possible representations of the name
public getResolvedClassName(PhpParser\Node\Name $name) : PhpParser\Node\Name
 

Get resolved class name.

  • param \Name $name Class ame to resolve
  • return \Name Resolved name
public getResolvedName(PhpParser\Node\Name $name, int $type) : ?PhpParser\Node\Name
 

Get resolved name.

  • param \Name $name Name to resolve
  • param \Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_{FUNCTION|CONSTANT}
  • return null|\Name Resolved name, or null if static resolution is not possible
public getShortName(string $name, int $type) : PhpParser\Node\Name
 

Get shortest representation of this fully-qualified name.

  • param string $name Fully-qualified name (without leading namespace separator)
  • param \Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*
  • return \Name Shortest representation
public startNamespace(?PhpParser\Node\Name $namespace = NULL) : void
 

Start a new namespace.

This also resets the alias table.

  • param \Name|null $namespace Null is the global namespace
Properties
protected array $aliases = []
 
  • var \Name[][] Map of format [aliasType => [aliasName => originalName]]
protected PhpParser\ErrorHandler $errorHandler
 
  • var \ErrorHandler Error handler
protected ?PhpParser\Node\Name $namespace
 
  • var null|\Name Current namespace
protected array $origAliases = []
 
  • var \Name[][] Same as $aliases but preserving original case
Methods
private getNamespaceRelativeName(string $name, string $lcName, int $type) : ?PhpParser\Node\Name
private normalizeConstName(string $name) : string
private resolveAlias(PhpParser\Node\Name $name, int $type) : ?PhpParser\Node\Name\FullyQualified
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration