1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix comments between -> and keyword
This commit is contained in:
Ilija Tovilo
2024-07-16 23:40:59 +02:00
3 changed files with 36 additions and 8 deletions

2
NEWS
View File

@@ -15,6 +15,8 @@ PHP NEWS
. Fixed bug GH-14741 (Segmentation fault in Zend/zend_types.h). (nielsdos)
. Fixed bug GH-14969 (Use-after-free in property coercion with __toString()).
(ilutov)
. Fixed bug GH-14961 (Comment between -> and keyword results in parse error).
(ilutov)
- Dom:
. Fixed bug GH-14702 (DOMDocument::xinclude() crash). (nielsdos)

26
Zend/tests/gh14961.phpt Normal file
View File

@@ -0,0 +1,26 @@
--TEST--
GH-14961: Comment between -> and keyword
--FILE--
<?php
class C {
public $class = C::class;
}
$c = new C();
$c->/* comment */class = 42;
var_dump($c->/** doc comment */class);
var_dump($c->
// line comment
class);
var_dump($c->
# hash comment
class);
var_dump($c?->/* comment */class);
?>
--EXPECT--
int(42)
int(42)
int(42)
int(42)

View File

@@ -1597,12 +1597,6 @@ OPTIONAL_WHITESPACE_OR_COMMENTS ({WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_
RETURN_TOKEN_WITH_STR(T_STRING, 0);
}
<ST_LOOKING_FOR_PROPERTY>{ANY_CHAR} {
yyless(0);
yy_pop_state();
goto restart;
}
<ST_IN_SCRIPTING>"::" {
RETURN_TOKEN(T_PAAMAYIM_NEKUDOTAYIM);
}
@@ -2385,7 +2379,7 @@ inline_char_handler:
}
<ST_IN_SCRIPTING>"#"|"//" {
<ST_IN_SCRIPTING,ST_LOOKING_FOR_PROPERTY>"#"|"//" {
while (YYCURSOR < YYLIMIT) {
switch (*YYCURSOR++) {
case '\r':
@@ -2409,7 +2403,7 @@ inline_char_handler:
RETURN_OR_SKIP_TOKEN(T_COMMENT);
}
<ST_IN_SCRIPTING>"/*"|"/**"{WHITESPACE} {
<ST_IN_SCRIPTING,ST_LOOKING_FOR_PROPERTY>"/*"|"/**"{WHITESPACE} {
int doc_com;
if (yyleng > 2) {
@@ -2445,6 +2439,12 @@ inline_char_handler:
RETURN_OR_SKIP_TOKEN(T_COMMENT);
}
<ST_LOOKING_FOR_PROPERTY>{ANY_CHAR} {
yyless(0);
yy_pop_state();
goto restart;
}
<ST_IN_SCRIPTING>"?>"{NEWLINE}? {
BEGIN(INITIAL);
if (yytext[yyleng-1] != '>') {