mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
Remove self/parent/static restriction for namespace names
This no longer applies as of PHP 8.0.
This commit is contained in:
parent
78e08fc178
commit
0cee2088ea
@ -898,13 +898,6 @@ abstract class ParserAbstract implements Parser
|
||||
}
|
||||
|
||||
protected function checkNamespace(Namespace_ $node) {
|
||||
if ($node->name && $node->name->isSpecialClassName()) {
|
||||
$this->emitError(new Error(
|
||||
sprintf('Cannot use \'%s\' as namespace name', $node->name),
|
||||
$node->name->getAttributes()
|
||||
));
|
||||
}
|
||||
|
||||
if (null !== $node->stmts) {
|
||||
foreach ($node->stmts as $stmt) {
|
||||
if ($stmt instanceof Namespace_) {
|
||||
|
@ -3,6 +3,9 @@ Keywords in namespaced name
|
||||
<?php
|
||||
namespace fn;
|
||||
namespace fn\use;
|
||||
namespace self;
|
||||
namespace parent;
|
||||
namespace static;
|
||||
fn\use();
|
||||
\fn\use();
|
||||
namespace\fn\use();
|
||||
@ -25,6 +28,33 @@ array(
|
||||
1: use
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
2: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: self
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
3: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: parent
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
4: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: static
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_Expression(
|
||||
expr: Expr_FuncCall(
|
||||
|
@ -1,51 +1,5 @@
|
||||
Invalid namespace names
|
||||
-----
|
||||
<?php namespace self;
|
||||
-----
|
||||
Cannot use 'self' as namespace name from 1:17 to 1:20
|
||||
array(
|
||||
0: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: self
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php namespace PARENT;
|
||||
-----
|
||||
Cannot use 'PARENT' as namespace name from 1:17 to 1:22
|
||||
array(
|
||||
0: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: PARENT
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php namespace static;
|
||||
-----
|
||||
!!php7
|
||||
Cannot use 'static' as namespace name from 1:17 to 1:22
|
||||
array(
|
||||
0: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: static
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php use A as self;
|
||||
-----
|
||||
Cannot use A as self because 'self' is a special class name from 1:16 to 1:19
|
||||
|
Loading…
Reference in New Issue
Block a user