summaryrefslogtreecommitdiff
path: root/Zend/zend_language_scanner.h
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-06-05 16:55:20 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-06-08 12:55:14 +0200
commitb03cafd19c01db57b89727ce77cc89a7d816077c (patch)
treeb8e39eeca2edf8fbb74e4b3fb7e2979470b959c0 /Zend/zend_language_scanner.h
parent08518b18b2095b8c5158e272b4fe6c339f0eb1b7 (diff)
downloadphp-git-b03cafd19c01db57b89727ce77cc89a7d816077c.tar.gz
Fix bug #77966: Cannot alias a method named "namespace"
This is a bit tricky: In this cases we have "namespace as", which means that we will only recognize "namespace" as an identifier when the lookahead token is already at the "as". This means that zend_lex_tstring picks up the wrong identifier. We solve this by actually assigning the identifier as the semantic value on the parser stack -- as in almost all cases we will not actually need the identifier, this is just an (offset, size) reference, not a copy of the string. Additionally, we need to teach the lexer feedback mechanism used by tokenizer TOKEN_PARSE mode to apply feedback to something other than the very last token. To that purpose we pass through the token text and check the tokens in reverse order to find the right one. Closes GH-5668.
Diffstat (limited to 'Zend/zend_language_scanner.h')
-rw-r--r--Zend/zend_language_scanner.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/Zend/zend_language_scanner.h b/Zend/zend_language_scanner.h
index 35eccaf7e6..35d4d0269e 100644
--- a/Zend/zend_language_scanner.h
+++ b/Zend/zend_language_scanner.h
@@ -50,7 +50,9 @@ typedef struct _zend_lex_state {
const zend_encoding *script_encoding;
/* hooks */
- void (*on_event)(zend_php_scanner_event event, int token, int line, void *context);
+ void (*on_event)(
+ zend_php_scanner_event event, int token, int line,
+ const char *text, size_t length, void *context);
void *on_event_context;
zend_ast *ast;
@@ -76,7 +78,7 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state);
ZEND_API int zend_prepare_string_for_scanning(zval *str, const char *filename);
ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding);
ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding);
-ZEND_API void zend_lex_tstring(zval *zv);
+ZEND_API void zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref);
END_EXTERN_C()