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

Breadcrumb

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

function ParserAbstract::fixupNamespaceAttributes

1 call to ParserAbstract::fixupNamespaceAttributes()
ParserAbstract::handleNamespaces in vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php
Moves statements of semicolon-style namespaces into $ns->stmts and checks various error conditions.

File

vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php, line 617

Class

ParserAbstract

Namespace

PhpParser

Code

private function fixupNamespaceAttributes(Node\Stmt\Namespace_ $stmt) : void {
    // We moved the statements into the namespace node, as such the end of the namespace node
    // needs to be extended to the end of the statements.
    if (empty($stmt->stmts)) {
        return;
    }
    // We only move the builtin end attributes here. This is the best we can do with the
    // knowledge we have.
    $endAttributes = [
        'endLine',
        'endFilePos',
        'endTokenPos',
    ];
    $lastStmt = $stmt->stmts[count($stmt->stmts) - 1];
    foreach ($endAttributes as $endAttribute) {
        if ($lastStmt->hasAttribute($endAttribute)) {
            $stmt->setAttribute($endAttribute, $lastStmt->getAttribute($endAttribute));
        }
    }
}

API Navigation

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