Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NameContext.php

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

NameContext

Namespace

PhpParser

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal