1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

zend_ast: Print placeholder value when printing ZEND_AST_OP_ARRAY (#17405)

As per the discussion in GH-17120, we are printing a placeholder value only.
The commit history of that PR also includes alternative implementations, should
a different decision be desirable.

Fixes GH-17096
Closes GH-17120
This commit is contained in:
Tim Düsterhus
2025-01-10 08:37:17 +01:00
committed by GitHub
parent 8d79ed6b3e
commit d8d1cb4195
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
--TEST--
AST printing for closures in attributes at runtime
--FILE--
<?php
#[Attr(static function ($foo) {
echo $foo;
})]
function foo() { }
$r = new ReflectionFunction('foo');
foreach ($r->getAttributes() as $attribute) {
echo $attribute;
}
?>
--EXPECT--
Attribute [ Attr ] {
- Arguments [1] {
Argument #0 [ Closure({closure:foo():3}) ]
}
}

View File

@@ -1885,6 +1885,11 @@ tail_call:
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;