Skip to content

Commit 35306de

Browse files
committed
Support visibility modifiers in namespaced names
Fixes nikic#704.
1 parent ad365b1 commit 35306de

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/PhpParser/Lexer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ private function createIdentifierTokenMap(): array {
494494
// Based on semi_reserved production.
495495
return array_fill_keys([
496496
\T_STRING,
497+
\T_STATIC, \T_ABSTRACT, \T_FINAL, \T_PRIVATE, \T_PROTECTED, \T_PUBLIC,
497498
\T_INCLUDE, \T_INCLUDE_ONCE, \T_EVAL, \T_REQUIRE, \T_REQUIRE_ONCE, \T_LOGICAL_OR, \T_LOGICAL_XOR, \T_LOGICAL_AND,
498499
\T_INSTANCEOF, \T_NEW, \T_CLONE, \T_EXIT, \T_IF, \T_ELSEIF, \T_ELSE, \T_ENDIF, \T_ECHO, \T_DO, \T_WHILE,
499500
\T_ENDWHILE, \T_FOR, \T_ENDFOR, \T_FOREACH, \T_ENDFOREACH, \T_DECLARE, \T_ENDDECLARE, \T_AS, \T_TRY, \T_CATCH,

test/code/parser/expr/keywordsInNamespacedName.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace static;
99
fn\use();
1010
\fn\use();
1111
namespace\fn\use();
12+
private\protected\public\static\abstract\final();
1213
-----
1314
!!php7
1415
array(
@@ -92,6 +93,22 @@ array(
9293
)
9394
)
9495
)
96+
3: Stmt_Expression(
97+
expr: Expr_FuncCall(
98+
name: Name(
99+
parts: array(
100+
0: private
101+
1: protected
102+
2: public
103+
3: static
104+
4: abstract
105+
5: final
106+
)
107+
)
108+
args: array(
109+
)
110+
)
111+
)
95112
)
96113
)
97114
)

0 commit comments

Comments
 (0)