Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ PHP NEWS
. Fixed bugs GH-17711 and GH-18022 (Infinite recursion on deprecated attribute
evaluation) and GH-18464 (Recursion protection for deprecation constants not
released on bailout). (DanielEScherzer and ilutov)
. Fixed AST printing for immediately invoked Closure. (Dmitriy Derepko)

- Curl:
. Added curl_multi_get_handles(). (timwolla)
Expand Down
6 changes: 2 additions & 4 deletions Zend/tests/arrow_functions/007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ zend.assertions=1
--FILE--
<?php

// TODO We're missing parentheses for the direct call

try {
assert((fn() => false)());
} catch (AssertionError $e) {
Expand All @@ -21,5 +19,5 @@ try {

?>
--EXPECT--
assert(): assert(fn() => false()) failed
assert(): assert(fn&(int ...$args): ?bool => $args[0](false)) failed
assert(): assert((fn() => false)()) failed
assert(): assert((fn&(int ...$args): ?bool => $args[0])(false)) failed
4 changes: 2 additions & 2 deletions Zend/tests/enum/ast-dumper.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ try {

?>
--EXPECT--
assert(function () {
assert((function () {
enum Foo {
case Bar;
}
Expand All @@ -45,4 +45,4 @@ assert(function () {
}

return false;
}())
})())
18 changes: 18 additions & 0 deletions Zend/tests/functions/007.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Pretty printing for arrow functions
--INI--
zend.assertions=1
--FILE--
<?php

try {
assert((function() { return false; })());
} catch (AssertionError $e) {
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
}

?>
--EXPECT--
assert(): assert((function () {
return false;
})()) failed
4 changes: 2 additions & 2 deletions Zend/tests/match/009_ast_export.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ assert((function () {

?>
--EXPECTF--
assert(): assert(function () {
assert(): assert((function () {
match ('foo') {
'foo', 'bar' => false,
'baz' => 'a',
default => 'b',
};
}()) failed
})()) failed
12 changes: 10 additions & 2 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2424,12 +2424,20 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
smart_str_appends(str, "::$");
zend_ast_export_var(str, ast->child[1], 0, indent);
break;
case ZEND_AST_CALL:
zend_ast_export_ns_name(str, ast->child[0], 0, indent);
case ZEND_AST_CALL: {
zend_ast *left = ast->child[0];
if (left->kind == ZEND_AST_ARROW_FUNC || left->kind == ZEND_AST_CLOSURE) {
smart_str_appends(str, "(");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have used smart_str_appendc() here and below, fixing in #18703 along with a few others

zend_ast_export_ns_name(str, left, 0, indent);
smart_str_appends(str, ")");
} else {
zend_ast_export_ns_name(str, left, 0, indent);
}
smart_str_appendc(str, '(');
zend_ast_export_ex(str, ast->child[1], 0, indent);
smart_str_appendc(str, ')');
break;
}
case ZEND_AST_PARENT_PROPERTY_HOOK_CALL:
smart_str_append(str, Z_STR_P(zend_ast_get_zval(ast->child[0])));
smart_str_appendc(str, '(');
Expand Down
Loading