Skip to content

Commit eb75fb9

Browse files
committed
Fix ast export in encaps list
1 parent 311817f commit eb75fb9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Zend/zend_ast.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,13 @@ static ZEND_COLD int zend_ast_valid_var_name(const char *s, size_t len)
10621062
return 1;
10631063
}
10641064

1065+
static ZEND_COLD int zend_ast_var_needs_braces(char ch)
1066+
{
1067+
if (ch != '[' && !zend_ast_valid_var_char(ch))
1068+
return 0;
1069+
return 1;
1070+
}
1071+
10651072
static ZEND_COLD void zend_ast_export_var(smart_str *str, zend_ast *ast, int priority, int indent)
10661073
{
10671074
if (ast->kind == ZEND_AST_ZVAL) {
@@ -1109,7 +1116,7 @@ static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, ze
11091116
ast->child[0]->kind == ZEND_AST_ZVAL &&
11101117
(i + 1 == list->children ||
11111118
list->child[i + 1]->kind != ZEND_AST_ZVAL ||
1112-
!zend_ast_valid_var_char(
1119+
!zend_ast_var_needs_braces(
11131120
*Z_STRVAL_P(
11141121
zend_ast_get_zval(list->child[i + 1]))))) {
11151122
zend_ast_export_ex(str, ast, 0, indent);

0 commit comments

Comments
 (0)