Skip to content

Commit b4196ae

Browse files
committed
Fix fetching default value of internal function with userland arginfo
"Fix" in the sense of "not crash". We aren't able to actually display the default value for this case, as there's no way to fetch the relevant information right now.
1 parent bef20d4 commit b4196ae

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

ext/reflection/php_reflection.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,10 @@ static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_
667667
if (!required) {
668668
if (fptr->type == ZEND_INTERNAL_FUNCTION) {
669669
smart_str_appends(str, " = ");
670-
if (((zend_internal_arg_info*)arg_info)->default_value) {
670+
/* TODO: We don't have a way to fetch the default value for an internal function
671+
* with userland arg info. */
672+
if (has_internal_arg_info(fptr)
673+
&& ((zend_internal_arg_info*)arg_info)->default_value) {
671674
smart_str_appends(str, ((zend_internal_arg_info*)arg_info)->default_value);
672675
} else {
673676
smart_str_appends(str, "<default>");
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Fetching default value of an internal trampoline function with userland arginfo
3+
--FILE--
4+
<?php
5+
$closure = function ($b = 0) {};
6+
$ro = new ReflectionObject($closure);
7+
$rm = $ro->getMethod('__invoke');
8+
echo $rm, "\n";
9+
?>
10+
--EXPECT--
11+
Method [ <internal> public method __invoke ] {
12+
13+
- Parameters [1] {
14+
Parameter #0 [ <optional> $b = <default> ]
15+
}
16+
}

0 commit comments

Comments
 (0)