Skip to content

Commit d1d3a4a

Browse files
committed
Generate method entries for Closure
1 parent 74ef4bd commit d1d3a4a

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

Zend/zend_closures.c

+1-10
Original file line numberDiff line numberDiff line change
@@ -600,20 +600,11 @@ ZEND_COLD ZEND_METHOD(Closure, __construct)
600600
}
601601
/* }}} */
602602

603-
static const zend_function_entry closure_functions[] = {
604-
ZEND_ME(Closure, __construct, arginfo_class_Closure___construct, ZEND_ACC_PRIVATE)
605-
ZEND_ME(Closure, bind, arginfo_class_Closure_bind, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
606-
ZEND_MALIAS(Closure, bindTo, bind, arginfo_class_Closure_bindTo, ZEND_ACC_PUBLIC)
607-
ZEND_ME(Closure, call, arginfo_class_Closure_call, ZEND_ACC_PUBLIC)
608-
ZEND_ME(Closure, fromCallable, arginfo_class_Closure_fromCallable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
609-
ZEND_FE_END
610-
};
611-
612603
void zend_register_closure_ce(void) /* {{{ */
613604
{
614605
zend_class_entry ce;
615606

616-
INIT_CLASS_ENTRY(ce, "Closure", closure_functions);
607+
INIT_CLASS_ENTRY(ce, "Closure", class_Closure_methods);
617608
zend_ce_closure = zend_register_internal_class(&ce);
618609
zend_ce_closure->ce_flags |= ZEND_ACC_FINAL;
619610
zend_ce_closure->create_object = zend_closure_new;

Zend/zend_closures.stub.php

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
<?php
22

3-
Class Closure
3+
/** @generate-function-entries */
4+
5+
final class Closure
46
{
57
private function __construct() {}
68

7-
/** @return ?Closure */
8-
public static function bind(Closure $closure, ?object $newthis, $newscope = UNKNOWN) {}
9+
public static function bind(Closure $closure, ?object $newthis, $newscope = UNKNOWN): ?Closure {}
910

10-
/** @return ?Closure */
11-
public function bindTo(?object $newthis, $newscope = UNKNOWN) {}
11+
/** @alias Closure::bind */
12+
public function bindTo(?object $newthis, $newscope = UNKNOWN): ?Closure {}
1213

1314
/** @return mixed */
1415
public function call(object $newthis, ...$parameters) {}
1516

16-
/**
17-
* @param callable $callable Not a proper type annotation due to bug #78770
18-
* @return Closure
19-
*/
20-
public function fromCallable($callable) {}
17+
/** @param callable $callable Not a proper type annotation due to bug #78770 */
18+
public static function fromCallable($callable): Closure {}
2119
}

Zend/zend_closures_arginfo.h

+19-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Closure___construct, 0, 0, 0)
44
ZEND_END_ARG_INFO()
55

6-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Closure_bind, 0, 0, 2)
6+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Closure_bind, 0, 2, Closure, 1)
77
ZEND_ARG_OBJ_INFO(0, closure, Closure, 0)
88
ZEND_ARG_TYPE_INFO(0, newthis, IS_OBJECT, 1)
99
ZEND_ARG_INFO(0, newscope)
1010
ZEND_END_ARG_INFO()
1111

12-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Closure_bindTo, 0, 0, 1)
12+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Closure_bindTo, 0, 1, Closure, 1)
1313
ZEND_ARG_TYPE_INFO(0, newthis, IS_OBJECT, 1)
1414
ZEND_ARG_INFO(0, newscope)
1515
ZEND_END_ARG_INFO()
@@ -19,6 +19,22 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Closure_call, 0, 0, 1)
1919
ZEND_ARG_VARIADIC_INFO(0, parameters)
2020
ZEND_END_ARG_INFO()
2121

22-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Closure_fromCallable, 0, 0, 1)
22+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Closure_fromCallable, 0, 1, Closure, 0)
2323
ZEND_ARG_INFO(0, callable)
2424
ZEND_END_ARG_INFO()
25+
26+
27+
ZEND_METHOD(Closure, __construct);
28+
ZEND_METHOD(Closure, bind);
29+
ZEND_METHOD(Closure, call);
30+
ZEND_METHOD(Closure, fromCallable);
31+
32+
33+
static const zend_function_entry class_Closure_methods[] = {
34+
ZEND_ME(Closure, __construct, arginfo_class_Closure___construct, ZEND_ACC_PRIVATE)
35+
ZEND_ME(Closure, bind, arginfo_class_Closure_bind, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
36+
ZEND_MALIAS(Closure, bindTo, bind, arginfo_class_Closure_bindTo, ZEND_ACC_PUBLIC)
37+
ZEND_ME(Closure, call, arginfo_class_Closure_call, ZEND_ACC_PUBLIC)
38+
ZEND_ME(Closure, fromCallable, arginfo_class_Closure_fromCallable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
39+
ZEND_FE_END
40+
};

0 commit comments

Comments
 (0)