function NameContext::getNamespaceRelativeName
1 call to NameContext::getNamespaceRelativeName()
- NameContext::getPossibleNames in vendor/
nikic/ php-parser/ lib/ PhpParser/ NameContext.php - Get possible ways of writing a fully qualified name (e.g., by making use of aliases).
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ NameContext.php, line 252
Class
Namespace
PhpParserCode
private function getNamespaceRelativeName(string $name, string $lcName, int $type) : ?Name {
if (null === $this->namespace) {
return new Name($name);
}
if ($type === Stmt\Use_::TYPE_CONSTANT) {
// The constants true/false/null always resolve to the global symbols, even inside a
// namespace, so they may be used without qualification
if ($lcName === "true" || $lcName === "false" || $lcName === "null") {
return new Name($name);
}
}
$namespacePrefix = strtolower($this->namespace . '\\');
if (0 === strpos($lcName, $namespacePrefix)) {
return new Name(substr($name, strlen($namespacePrefix)));
}
return null;
}