Skip to content

Commit ead679e

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix comments between -> and keyword
2 parents fdbe910 + e01e2bb commit ead679e

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

Zend/tests/gh14961.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
GH-14961: Comment between -> and keyword
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public $class = C::class;
8+
}
9+
10+
$c = new C();
11+
$c->/* comment */class = 42;
12+
var_dump($c->/** doc comment */class);
13+
var_dump($c->
14+
// line comment
15+
class);
16+
var_dump($c->
17+
# hash comment
18+
class);
19+
var_dump($c?->/* comment */class);
20+
21+
?>
22+
--EXPECT--
23+
int(42)
24+
int(42)
25+
int(42)
26+
int(42)

Zend/zend_language_scanner.l

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,12 +1597,6 @@ OPTIONAL_WHITESPACE_OR_COMMENTS ({WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_
15971597
RETURN_TOKEN_WITH_STR(T_STRING, 0);
15981598
}
15991599

1600-
<ST_LOOKING_FOR_PROPERTY>{ANY_CHAR} {
1601-
yyless(0);
1602-
yy_pop_state();
1603-
goto restart;
1604-
}
1605-
16061600
<ST_IN_SCRIPTING>"::" {
16071601
RETURN_TOKEN(T_PAAMAYIM_NEKUDOTAYIM);
16081602
}
@@ -2389,7 +2383,7 @@ inline_char_handler:
23892383
}
23902384
23912385
2392-
<ST_IN_SCRIPTING>"#"|"//" {
2386+
<ST_IN_SCRIPTING,ST_LOOKING_FOR_PROPERTY>"#"|"//" {
23932387
while (YYCURSOR < YYLIMIT) {
23942388
switch (*YYCURSOR++) {
23952389
case '\r':
@@ -2413,7 +2407,7 @@ inline_char_handler:
24132407
RETURN_OR_SKIP_TOKEN(T_COMMENT);
24142408
}
24152409

2416-
<ST_IN_SCRIPTING>"/*"|"/**"{WHITESPACE} {
2410+
<ST_IN_SCRIPTING,ST_LOOKING_FOR_PROPERTY>"/*"|"/**"{WHITESPACE} {
24172411
int doc_com;
24182412

24192413
if (yyleng > 2) {
@@ -2449,6 +2443,12 @@ inline_char_handler:
24492443
RETURN_OR_SKIP_TOKEN(T_COMMENT);
24502444
}
24512445

2446+
<ST_LOOKING_FOR_PROPERTY>{ANY_CHAR} {
2447+
yyless(0);
2448+
yy_pop_state();
2449+
goto restart;
2450+
}
2451+
24522452
<ST_IN_SCRIPTING>"?>"{NEWLINE}? {
24532453
BEGIN(INITIAL);
24542454
if (yytext[yyleng-1] != '>') {

0 commit comments

Comments
 (0)