From c74832feabf89a66fc66646a65b3c0c3d8c126aa Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 12 Dec 2022 00:23:46 +0100 Subject: [PATCH] Allow comments between intersection types and by-ref params --- .../intersection_types/parsing.phpt | 26 +++++++++++++++++++ .../intersection_types/parsing_attribute.phpt | 13 ++++++++++ Zend/zend_language_scanner.l | 7 ++++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/type_declarations/intersection_types/parsing.phpt create mode 100644 Zend/tests/type_declarations/intersection_types/parsing_attribute.phpt diff --git a/Zend/tests/type_declarations/intersection_types/parsing.phpt b/Zend/tests/type_declarations/intersection_types/parsing.phpt new file mode 100644 index 0000000000000..1825dbe4745ae --- /dev/null +++ b/Zend/tests/type_declarations/intersection_types/parsing.phpt @@ -0,0 +1,26 @@ +--TEST-- +Intersection type parsing interaction with comments +--FILE-- + +--EXPECTF-- diff --git a/Zend/tests/type_declarations/intersection_types/parsing_attribute.phpt b/Zend/tests/type_declarations/intersection_types/parsing_attribute.phpt new file mode 100644 index 0000000000000..7997435b7b2f2 --- /dev/null +++ b/Zend/tests/type_declarations/intersection_types/parsing_attribute.phpt @@ -0,0 +1,13 @@ +--TEST-- +Intersection type parsing interaction with attributes +--FILE-- + +--EXPECTF-- +Parse error: syntax error, unexpected token "#[" in %s on line %d diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index c73a50948d6bc..6adc00a44fcbf 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -1368,6 +1368,11 @@ TABS_AND_SPACES [ \t]* TOKENS [;:,.|^&+-/*=%!~$<>?@] ANY_CHAR [^] NEWLINE ("\r"|"\n"|"\r\n") +OPTIONAL_WHITESPACE [ \n\r\t]* +MULTI_LINE_COMMENT "/*"([^"*"]*"*"+)"/" +SINGLE_LINE_COMMENT "//".*[\n\r] +HASH_COMMENT "#"(([^"["].*[\n\r])|[\n\r]) +OPTIONAL_WHITESPACE_AND_COMMENTS ({OPTIONAL_WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_COMMENT}|{HASH_COMMENT})* /* compute yyleng before each rule */ := yyleng = YYCURSOR - SCNG(yy_text); @@ -1869,7 +1874,7 @@ NEWLINE ("\r"|"\n"|"\r\n") RETURN_TOKEN(T_SR); } -"&"[ \t\r\n]*("$"|"...") { +"&"{OPTIONAL_WHITESPACE_AND_COMMENTS}("$"|"...") { yyless(1); RETURN_TOKEN(T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG); }