in src/Node/QualifiedName.php [82:145]
public function getResolvedName($namespaceDefinition = null) {
// Name resolution not applicable to constructs that define symbol names or aliases.
if (($this->parent instanceof Node\Statement\NamespaceDefinition && $this->parent->name->getStartPosition() === $this->getStartPosition()) ||
$this->parent instanceof Node\Statement\NamespaceUseDeclaration ||
$this->parent instanceof Node\NamespaceUseClause ||
$this->parent instanceof Node\NamespaceUseGroupClause ||
$this->parent->parent instanceof Node\TraitUseClause ||
$this->parent instanceof Node\TraitSelectOrAliasClause ||
($this->parent instanceof TraitSelectOrAliasClause &&
($this->parent->asOrInsteadOfKeyword == null || $this->parent->asOrInsteadOfKeyword->kind === TokenKind::AsKeyword))
) {
return null;
}
if (in_array($lowerText = strtolower($this->getText()), ["self", "static", "parent"])) {
return $lowerText;
}
// FULLY QUALIFIED NAMES
// - resolve to the name without leading namespace separator.
if ($this->isFullyQualifiedName()) {
return ResolvedName::buildName($this->nameParts, $this->getFileContents());
}
// RELATIVE NAMES
// - resolve to the name with namespace replaced by the current namespace.
// - if current namespace is global, strip leading namespace\ prefix.
if ($this->isRelativeName()) {
return $this->getNamespacedName();
}
[$namespaceImportTable, $functionImportTable, $constImportTable] = $this->getImportTablesForCurrentScope();
// QUALIFIED NAMES
// - first segment of the name is translated according to the current class/namespace import table.
// - If no import rule applies, the current namespace is prepended to the name.
if ($this->isQualifiedName()) {
return $this->tryResolveFromImportTable($namespaceImportTable) ?? $this->getNamespacedName();
}
// UNQUALIFIED NAMES
// - translated according to the current import table for the respective symbol type.
// (class-like => namespace import table, constant => const import table, function => function import table)
// - if no import rule applies:
// - all symbol types: if current namespace is global, resolve to global namespace.
// - class-like symbols: resolve from current namespace.
// - function or const: resolved at runtime (from current namespace, with fallback to global namespace).
if ($this->isConstantName()) {
$resolvedName = $this->tryResolveFromImportTable($constImportTable, /* case-sensitive */ true);
$namespaceDefinition = $this->getNamespaceDefinition();
if ($namespaceDefinition !== null && $namespaceDefinition->name === null) {
$resolvedName = $resolvedName ?? ResolvedName::buildName($this->nameParts, $this->getFileContents());
}
return $resolvedName;
} elseif ($this->parent instanceof CallExpression) {
$resolvedName = $this->tryResolveFromImportTable($functionImportTable);
if (($namespaceDefinition = $this->getNamespaceDefinition()) === null || $namespaceDefinition->name === null) {
$resolvedName = $resolvedName ?? ResolvedName::buildName($this->nameParts, $this->getFileContents());
}
return $resolvedName;
}
return $this->tryResolveFromImportTable($namespaceImportTable) ?? $this->getNamespacedName();
}