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
Namespace
PhpParserCode
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));
}
}
}