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

Breadcrumb

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

function TokenParser::parseUseStatements

Gets all use statements.

Parameters

string $namespaceName The namespace name of the reflected class.:

Return value

array<string, string> A list with all found use statements.

File

vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/TokenParser.php, line 151

Class

TokenParser
Parses a file for namespaces/use/class declarations.

Namespace

Doctrine\Common\Annotations

Code

public function parseUseStatements(string $namespaceName) {
    $statements = [];
    while ($token = $this->next()) {
        if ($token[0] === T_USE) {
            $statements = array_merge($statements, $this->parseUseStatement());
            continue;
        }
        if ($token[0] !== T_NAMESPACE || $this->parseNamespace() !== $namespaceName) {
            continue;
        }
        // Get fresh array for new namespace. This is to prevent the parser to collect the use statements
        // for a previous namespace with the same name. This is the case if a namespace is defined twice
        // or if a namespace with the same name is commented out.
        $statements = [];
    }
    return $statements;
}

API Navigation

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