Skip to content

Commit 39753fa

Browse files
committed
Merge branch 'PHP-5.6'
Preserving HAS_RETURN_TYPE for __invoke() here as well. Conflicts: Zend/zend_alloc.c
2 parents 402f697 + e7d0ca3 commit 39753fa

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Closure::__invoke() with variadic parameter
3+
--FILE--
4+
<?php
5+
6+
$closure = function(&...$refs) {};
7+
$closure->__invoke(
8+
$v1, $v2, $v3, $v4,
9+
$v5, $v6, $v7, $v8,
10+
$v9, $v10, $v11, $v12,
11+
$v13
12+
);
13+
14+
?>
15+
===DONE===
16+
--EXPECT--
17+
===DONE===

Zend/zend_closures.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,17 @@ ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object) /* {
203203
{
204204
zend_closure *closure = (zend_closure *)object;
205205
zend_function *invoke = (zend_function*)emalloc(sizeof(zend_function));
206+
const uint32_t keep_flags =
207+
ZEND_ACC_RETURN_REFERENCE | ZEND_ACC_VARIADIC | ZEND_ACC_HAS_RETURN_TYPE;
206208

207209
invoke->common = closure->func.common;
208210
/* We return ZEND_INTERNAL_FUNCTION, but arg_info representation is the
209211
* same as for ZEND_USER_FUNCTION (uses zend_string* instead of char*).
210212
* This is not a problem, because ZEND_ACC_HAS_TYPE_HINTS is never set,
211213
* and we won't check arguments on internal function */
212214
invoke->type = ZEND_INTERNAL_FUNCTION;
213-
invoke->internal_function.fn_flags = ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | (closure->func.common.fn_flags & ZEND_ACC_RETURN_REFERENCE);
215+
invoke->internal_function.fn_flags =
216+
ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | (closure->func.common.fn_flags & keep_flags);
214217
invoke->internal_function.handler = ZEND_MN(Closure___invoke);
215218
invoke->internal_function.module = 0;
216219
invoke->internal_function.scope = zend_ce_closure;

0 commit comments

Comments
 (0)