Skip to content

Commit e7d0ca3

Browse files
committed
Preserve VARIADIC flag for Closure::__invoke()
The 13 arguments are for the benefit of PHP 7, where the first twelve use the bitmask.
1 parent 424005a commit e7d0ca3

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@ ZEND_API zend_function *zend_get_closure_invoke_method(zval *obj TSRMLS_DC) /* {
148148
{
149149
zend_closure *closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC);
150150
zend_function *invoke = (zend_function*)emalloc(sizeof(zend_function));
151+
const zend_uint keep_flags = ZEND_ACC_RETURN_REFERENCE | ZEND_ACC_VARIADIC;
151152

152153
invoke->common = closure->func.common;
153154
invoke->type = ZEND_INTERNAL_FUNCTION;
154-
invoke->internal_function.fn_flags = ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | (closure->func.common.fn_flags & ZEND_ACC_RETURN_REFERENCE);
155+
invoke->internal_function.fn_flags =
156+
ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | (closure->func.common.fn_flags & keep_flags);
155157
invoke->internal_function.handler = ZEND_MN(Closure___invoke);
156158
invoke->internal_function.module = 0;
157159
invoke->internal_function.scope = zend_ce_closure;

0 commit comments

Comments
 (0)