]> granicus.if.org Git - php/commitdiff
Fixed bug #80462
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 2 Dec 2020 09:19:32 +0000 (10:19 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 2 Dec 2020 09:19:32 +0000 (10:19 +0100)
NEWS
Zend/zend_language_scanner.l
ext/tokenizer/tests/bug80462.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 979924f72e8efaf8ce410c789d528b75e1ad9166..b1a0c50776e20d7df1f296e9086d2a8458a2e123 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -47,6 +47,10 @@ PHP                                                                        NEWS
 - Tidy:
   . Fixed bug #77594 (ob_tidyhandler is never reset). (cmb)
 
+- Tokenizer:
+  . Fixed bug #80462 (Nullsafe operator tokenize with TOKEN_PARSE flag fails).
+    (Nikita)
+
 - XML:
   . XmlParser opaque object renamed to XMLParser for consistency with other XML objects. (girgias)
 
index d1c5b85cf248c11c19fa225e62c1d3cf92d55ac5..b9e6127059096401ccb163675aa2df116256e54a 100644 (file)
@@ -1564,7 +1564,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
 
 <ST_IN_SCRIPTING>"?->" {
        yy_push_state(ST_LOOKING_FOR_PROPERTY);
-       return T_NULLSAFE_OBJECT_OPERATOR;
+       RETURN_TOKEN(T_NULLSAFE_OBJECT_OPERATOR);
 }
 
 <ST_IN_SCRIPTING,ST_LOOKING_FOR_PROPERTY>{WHITESPACE}+ {
diff --git a/ext/tokenizer/tests/bug80462.phpt b/ext/tokenizer/tests/bug80462.phpt
new file mode 100644 (file)
index 0000000..068cea0
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Bug #80462: Nullsafe operator tokenize with TOKEN_PARSE flag fails
+--FILE--
+<?php
+
+foreach (PhpToken::tokenize('<?php $foo = $a?->b();', TOKEN_PARSE) as $token) {
+    echo $token->getTokenName(), "\n";
+}
+
+?>
+--EXPECT--
+T_OPEN_TAG
+T_VARIABLE
+T_WHITESPACE
+=
+T_WHITESPACE
+T_VARIABLE
+T_NULLSAFE_OBJECT_OPERATOR
+T_STRING
+(
+)
+;