Skip to content

Commit

Permalink
Merge branch 'PHP-8.3'
Browse files Browse the repository at this point in the history
* PHP-8.3:
  Fix comments between -> and keyword
  • Loading branch information
iluuu1994 committed Jul 16, 2024
2 parents fdbe910 + e01e2bb commit ead679e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
26 changes: 26 additions & 0 deletions Zend/tests/gh14961.phpt
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 8 additions & 8 deletions Zend/zend_language_scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -2389,7 +2383,7 @@ inline_char_handler:
}
<ST_IN_SCRIPTING>"#"|"//" {
<ST_IN_SCRIPTING,ST_LOOKING_FOR_PROPERTY>"#"|"//" {
while (YYCURSOR < YYLIMIT) {
switch (*YYCURSOR++) {
case '\r':
Expand All @@ -2413,7 +2407,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) {
Expand Down Expand Up @@ -2449,6 +2443,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] != '>') {
Expand Down

0 comments on commit ead679e

Please sign in to comment.