diff --git a/Zend/tests/closure_const_expr/attributes_ast_printing_runtime.phpt b/Zend/tests/closure_const_expr/attributes_ast_printing_runtime.phpt new file mode 100644 index 0000000000000..dfdb32e492f0c --- /dev/null +++ b/Zend/tests/closure_const_expr/attributes_ast_printing_runtime.phpt @@ -0,0 +1,22 @@ +--TEST-- +AST printing for closures in attributes at runtime +--FILE-- +getAttributes() as $attribute) { + echo $attribute; +} + +?> +--EXPECT-- +Attribute [ Attr ] { + - Arguments [1] { + Argument #0 [ Closure({closure:foo():3}) ] + } +} diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index c1d973f67c85c..9258f4f30f462 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -1885,6 +1885,11 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio smart_str_appendl(str, ZSTR_VAL(name), ZSTR_LEN(name)); break; } + case ZEND_AST_OP_ARRAY: + smart_str_appends(str, "Closure("); + smart_str_append(str, zend_ast_get_op_array(ast)->op_array->function_name); + smart_str_appends(str, ")"); + break; case ZEND_AST_CONSTANT_CLASS: smart_str_appendl(str, "__CLASS__", sizeof("__CLASS__")-1); break;