Skip to content

Commit cee9a0e

Browse files
committed
Fix enum BC break where class name is followed by extends or implements
1 parent 830b4da commit cee9a0e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Zend/tests/enum/keyword-no-bc-break.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ namespace enum {
77
class Foo {}
88
}
99

10+
namespace foo {
11+
class Bar {}
12+
class enum extends Bar {}
13+
}
14+
15+
namespace bar {
16+
interface Baz {}
17+
class enum implements Baz {}
18+
}
19+
1020
namespace {
1121
class enum {}
1222

Zend/zend_language_scanner.l

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,10 @@ NEWLINE ("\r"|"\n"|"\r\n")
15551555
* The enum keyword must be followed by whitespace and another identifier.
15561556
* This avoids the BC break of using enum in classes, namespaces, functions and constants.
15571557
*/
1558+
<ST_IN_SCRIPTING>"enum"{WHITESPACE}("extends"|"implements") {
1559+
yyless(4);
1560+
RETURN_TOKEN_WITH_STR(T_STRING, 0);
1561+
}
15581562
<ST_IN_SCRIPTING>"enum"{WHITESPACE}[a-zA-Z_\x80-\xff] {
15591563
yyless(4);
15601564
RETURN_TOKEN_WITH_IDENT(T_ENUM);

0 commit comments

Comments
 (0)