diff --git a/Zend/tests/arbitrary_string_interpolation.phpt b/Zend/tests/arbitrary_string_interpolation.phpt new file mode 100644 index 0000000000000..813331bdc71de --- /dev/null +++ b/Zend/tests/arbitrary_string_interpolation.phpt @@ -0,0 +1,26 @@ +--TEST-- +Arbitrary string interpolation with "{$:expr}" +--FILE-- + +--EXPECT-- +bar +bar +foo +foo +foo +6 diff --git a/Zend/tests/flexible-heredoc-error7.phpt b/Zend/tests/flexible-heredoc-error7.phpt index d31b430b5670c..05a49ef70e149 100644 --- a/Zend/tests/flexible-heredoc-error7.phpt +++ b/Zend/tests/flexible-heredoc-error7.phpt @@ -8,4 +8,4 @@ Note: the closing ?> has been deliberately elided. echo << has been deliberately elided. echo <<<'END' --EXPECTF-- -Parse error: syntax error, unexpected end of file, expecting variable or heredoc end or "${" or "{$" in %s on line %d +Parse error: syntax error, unexpected end of file in %s on line %d diff --git a/Zend/tests/flexible-nowdoc-error8.phpt b/Zend/tests/flexible-nowdoc-error8.phpt index 5c5643206b91c..3b9641e635501 100644 --- a/Zend/tests/flexible-nowdoc-error8.phpt +++ b/Zend/tests/flexible-nowdoc-error8.phpt @@ -8,4 +8,4 @@ eval('<<<\'end\' ?> --EXPECTF-- -Parse error: syntax error, unexpected end of file, expecting variable or heredoc end or "${" or "{$" in %s on line %d +Parse error: syntax error, unexpected end of file in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 039e95913f6d3..0225e7a79069c 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -9550,7 +9550,6 @@ static void zend_compile_encaps_list(znode *result, zend_ast *ast) /* {{{ */ ZVAL_EMPTY_STRING(&result->u.constant); /* empty string */ } - CG(active_op_array)->last = reserved_op_number - 1; return; } else if (last_const_node.op_type == IS_CONST) { opline = &CG(active_op_array)->opcodes[reserved_op_number]; diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index f6ba5465abebb..c01479c5c427b 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -226,6 +226,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %token T_END_HEREDOC "heredoc end" %token T_DOLLAR_OPEN_CURLY_BRACES "'${'" %token T_CURLY_OPEN "'{$'" +%token T_CURLY_DOLLAR_COLON "'{$:'" %token T_PAAMAYIM_NEKUDOTAYIM "'::'" %token T_NS_SEPARATOR "'\\'" %token T_ELLIPSIS "'...'" @@ -1497,6 +1498,7 @@ encaps_var: { $$ = zend_ast_create(ZEND_AST_DIM, zend_ast_create(ZEND_AST_VAR, $2), $4); } | T_CURLY_OPEN variable '}' { $$ = $2; } + | T_CURLY_DOLLAR_COLON expr '}' { $$ = $2; } ; encaps_var_offset: diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index a367c2acb82da..5c011910c7445 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -2761,6 +2761,13 @@ skip_escape_conversion: } +"{$:" { + yy_push_state(ST_IN_SCRIPTING); + enter_nesting('{'); + RETURN_TOKEN(T_CURLY_DOLLAR_COLON); +} + + "{$" { yy_push_state(ST_IN_SCRIPTING); yyless(1); diff --git a/ext/tokenizer/tests/token_get_all_heredoc_nowdoc.phpt b/ext/tokenizer/tests/token_get_all_heredoc_nowdoc.phpt index 6b3010d7cf41b..bdbd4b3db7550 100644 --- a/ext/tokenizer/tests/token_get_all_heredoc_nowdoc.phpt +++ b/ext/tokenizer/tests/token_get_all_heredoc_nowdoc.phpt @@ -326,11 +326,11 @@ Line 2: T_END_HEREDOC (' INNER_END') Test case 5 -Parse error: syntax error, unexpected end of file, expecting variable or heredoc end or "${" or "{$" on line 2 +Parse error: syntax error, unexpected end of file on line 2 Test case 6 -Parse error: syntax error, unexpected end of file, expecting variable or heredoc end or "${" or "{$" on line 2 +Parse error: syntax error, unexpected end of file on line 2 Test case 7 @@ -409,8 +409,8 @@ Line 3: T_END_HEREDOC (' INNER_END') Test case 17 -Parse error: syntax error, unexpected end of file, expecting variable or heredoc end or "${" or "{$" on line 4 +Parse error: syntax error, unexpected end of file on line 4 Test case 18 -Parse error: syntax error, unexpected end of file, expecting variable or heredoc end or "${" or "{$" on line 4 +Parse error: syntax error, unexpected end of file on line 4 diff --git a/ext/tokenizer/tokenizer_data.c b/ext/tokenizer/tokenizer_data.c index a5adc67308485..16c9b39e70fff 100644 --- a/ext/tokenizer/tokenizer_data.c +++ b/ext/tokenizer/tokenizer_data.c @@ -162,6 +162,7 @@ void tokenizer_register_constants(INIT_FUNC_ARGS) { REGISTER_LONG_CONSTANT("T_END_HEREDOC", T_END_HEREDOC, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_DOLLAR_OPEN_CURLY_BRACES", T_DOLLAR_OPEN_CURLY_BRACES, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_CURLY_OPEN", T_CURLY_OPEN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("T_CURLY_DOLLAR_COLON", T_CURLY_DOLLAR_COLON, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_PAAMAYIM_NEKUDOTAYIM", T_PAAMAYIM_NEKUDOTAYIM, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_NS_SEPARATOR", T_NS_SEPARATOR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_ELLIPSIS", T_ELLIPSIS, CONST_CS | CONST_PERSISTENT); @@ -315,6 +316,7 @@ char *get_token_type_name(int token_type) case T_END_HEREDOC: return "T_END_HEREDOC"; case T_DOLLAR_OPEN_CURLY_BRACES: return "T_DOLLAR_OPEN_CURLY_BRACES"; case T_CURLY_OPEN: return "T_CURLY_OPEN"; + case T_CURLY_DOLLAR_COLON: return "T_CURLY_DOLLAR_COLON"; case T_PAAMAYIM_NEKUDOTAYIM: return "T_DOUBLE_COLON"; case T_NS_SEPARATOR: return "T_NS_SEPARATOR"; case T_ELLIPSIS: return "T_ELLIPSIS";