Merge branch 'PHP-7.4'

This commit is contained in:
Nikita Popov 2019-06-28 16:11:37 +02:00
commit 0588c38a2c
2 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,17 @@
--TEST--
AST pretty-printer
--INI--
zend.assertions=1
assert.exception=0
--FILE--
<?php
assert(0 && ($a = function () {
$var = 'test';
$str = "$var, $var[1], {$var}[], {$var[1]}[], ${var}[], ${var[1]}[]";
}));
?>
--EXPECTF--
Warning: assert(): assert(0 && ($a = function () {
$var = 'test';
$str = "$var, {$var[1]}, {$var}[], {$var[1]}[], {$var}[], {$var[1]}[]";
})) failed in %sexpect_020.php on line %d

View File

@ -1062,6 +1062,11 @@ static ZEND_COLD int zend_ast_valid_var_name(const char *s, size_t len)
return 1; return 1;
} }
static ZEND_COLD int zend_ast_var_needs_braces(char ch)
{
return ch == '[' || zend_ast_valid_var_char(ch);
}
static ZEND_COLD void zend_ast_export_var(smart_str *str, zend_ast *ast, int priority, int indent) static ZEND_COLD void zend_ast_export_var(smart_str *str, zend_ast *ast, int priority, int indent)
{ {
if (ast->kind == ZEND_AST_ZVAL) { if (ast->kind == ZEND_AST_ZVAL) {
@ -1109,7 +1114,7 @@ static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, ze
ast->child[0]->kind == ZEND_AST_ZVAL && ast->child[0]->kind == ZEND_AST_ZVAL &&
(i + 1 == list->children || (i + 1 == list->children ||
list->child[i + 1]->kind != ZEND_AST_ZVAL || list->child[i + 1]->kind != ZEND_AST_ZVAL ||
!zend_ast_valid_var_char( !zend_ast_var_needs_braces(
*Z_STRVAL_P( *Z_STRVAL_P(
zend_ast_get_zval(list->child[i + 1]))))) { zend_ast_get_zval(list->child[i + 1]))))) {
zend_ast_export_ex(str, ast, 0, indent); zend_ast_export_ex(str, ast, 0, indent);
@ -1759,6 +1764,8 @@ simple_list:
zend_ast_export_ex(str, ast->child[1], 80, indent); zend_ast_export_ex(str, ast->child[1], 80, indent);
smart_str_appends(str, " => "); smart_str_appends(str, " => ");
} }
if (ast->attr)
smart_str_appendc(str, '&');
zend_ast_export_ex(str, ast->child[0], 80, indent); zend_ast_export_ex(str, ast->child[0], 80, indent);
break; break;
case ZEND_AST_NEW: case ZEND_AST_NEW: