--- /dev/null
+--TEST--
+Bug #69802 (Reflection on Closure::__invoke borks type hint class name)
+--FILE--
+<?php
+$f = (new ReflectionFunction('iterator_to_array'))->getClosure();
+$r = new ReflectionMethod($f, '__invoke');
+var_dump($r->getParameters()[0]->getClass());
+?>
+--EXPECT--
+object(ReflectionClass)#4 (1) {
+ ["name"]=>
+ string(11) "Traversable"
+}
* ZEND_ACC_USER_ARG_INFO flag to prevent invalid usage by Reflection */
invoke->type = ZEND_INTERNAL_FUNCTION;
invoke->internal_function.fn_flags =
- ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | ZEND_ACC_USER_ARG_INFO | (closure->func.common.fn_flags & keep_flags);
+ ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | (closure->func.common.fn_flags & keep_flags);
+ if (closure->func.type != ZEND_INTERNAL_FUNCTION || (closure->func.common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
+ invoke->internal_function.fn_flags |=
+ ZEND_ACC_USER_ARG_INFO;
+ }
invoke->internal_function.handler = ZEND_MN(Closure___invoke);
invoke->internal_function.module = 0;
invoke->internal_function.scope = zend_ce_closure;
closure = (zend_closure *)Z_OBJ_P(res);
- closure->func = *func;
+ memcpy(&closure->func, func, func->type == ZEND_USER_FUNCTION ? sizeof(zend_op_array) : sizeof(zend_internal_function));
closure->func.common.prototype = (zend_function*)closure;
closure->func.common.fn_flags |= ZEND_ACC_CLOSURE;
ce = ce->parent;
} else {
if (param->fptr->type == ZEND_INTERNAL_FUNCTION &&
- (param->fptr->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) {
+ !(param->fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
zend_string *name = zend_string_init(class_name, class_name_len, 0);
ce = zend_lookup_class(name);
zend_string_release(name);