]> granicus.if.org Git - php/commitdiff
Generate method entries for Closure
authorMáté Kocsis <kocsismate@woohoolabs.com>
Tue, 19 May 2020 11:56:30 +0000 (13:56 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Tue, 19 May 2020 12:19:37 +0000 (14:19 +0200)
Zend/zend_closures.c
Zend/zend_closures.stub.php
Zend/zend_closures_arginfo.h

index 02df3504ccf16be231f0422c70ca74df896541d3..6bd5a8716b2ced7685ebcdd7f6f1b2d968eece92 100644 (file)
@@ -600,20 +600,11 @@ ZEND_COLD ZEND_METHOD(Closure, __construct)
 }
 /* }}} */
 
-static const zend_function_entry closure_functions[] = {
-       ZEND_ME(Closure, __construct, arginfo_class_Closure___construct, ZEND_ACC_PRIVATE)
-       ZEND_ME(Closure, bind, arginfo_class_Closure_bind, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       ZEND_MALIAS(Closure, bindTo, bind, arginfo_class_Closure_bindTo, ZEND_ACC_PUBLIC)
-       ZEND_ME(Closure, call, arginfo_class_Closure_call, ZEND_ACC_PUBLIC)
-       ZEND_ME(Closure, fromCallable, arginfo_class_Closure_fromCallable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       ZEND_FE_END
-};
-
 void zend_register_closure_ce(void) /* {{{ */
 {
        zend_class_entry ce;
 
-       INIT_CLASS_ENTRY(ce, "Closure", closure_functions);
+       INIT_CLASS_ENTRY(ce, "Closure", class_Closure_methods);
        zend_ce_closure = zend_register_internal_class(&ce);
        zend_ce_closure->ce_flags |= ZEND_ACC_FINAL;
        zend_ce_closure->create_object = zend_closure_new;
index 65ad4635dae8ae2c4795590d0d48292e11dd139e..75202c5df77952256e9b0eeb09e25c7c996eb092 100644 (file)
@@ -1,21 +1,19 @@
 <?php
 
-Class Closure
+/** @generate-function-entries */
+
+final class Closure
 {
     private function __construct() {}
 
-    /** @return ?Closure */
-    public static function bind(Closure $closure, ?object $newthis, $newscope = UNKNOWN) {}
+    public static function bind(Closure $closure, ?object $newthis, $newscope = UNKNOWN): ?Closure {}
 
-    /** @return ?Closure */
-    public function bindTo(?object $newthis, $newscope = UNKNOWN) {}
+    /** @alias Closure::bind */
+    public function bindTo(?object $newthis, $newscope = UNKNOWN): ?Closure {}
 
     /** @return mixed */
     public function call(object $newthis, ...$parameters) {}
 
-    /**
-     * @param callable $callable Not a proper type annotation due to bug #78770
-     * @return Closure
-     */
-    public function fromCallable($callable) {}
+    /** @param callable $callable Not a proper type annotation due to bug #78770 */
+    public static function fromCallable($callable): Closure {}
 }
index 91d019dc947e71539a2c671bf88abe87cdb9483b..a1eddd7bc13819e443e755ba91553a469e840b2c 100644 (file)
@@ -3,13 +3,13 @@
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Closure___construct, 0, 0, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Closure_bind, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Closure_bind, 0, 2, Closure, 1)
        ZEND_ARG_OBJ_INFO(0, closure, Closure, 0)
        ZEND_ARG_TYPE_INFO(0, newthis, IS_OBJECT, 1)
        ZEND_ARG_INFO(0, newscope)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Closure_bindTo, 0, 0, 1)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Closure_bindTo, 0, 1, Closure, 1)
        ZEND_ARG_TYPE_INFO(0, newthis, IS_OBJECT, 1)
        ZEND_ARG_INFO(0, newscope)
 ZEND_END_ARG_INFO()
@@ -19,6 +19,22 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Closure_call, 0, 0, 1)
        ZEND_ARG_VARIADIC_INFO(0, parameters)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Closure_fromCallable, 0, 0, 1)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Closure_fromCallable, 0, 1, Closure, 0)
        ZEND_ARG_INFO(0, callable)
 ZEND_END_ARG_INFO()
+
+
+ZEND_METHOD(Closure, __construct);
+ZEND_METHOD(Closure, bind);
+ZEND_METHOD(Closure, call);
+ZEND_METHOD(Closure, fromCallable);
+
+
+static const zend_function_entry class_Closure_methods[] = {
+       ZEND_ME(Closure, __construct, arginfo_class_Closure___construct, ZEND_ACC_PRIVATE)
+       ZEND_ME(Closure, bind, arginfo_class_Closure_bind, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       ZEND_MALIAS(Closure, bindTo, bind, arginfo_class_Closure_bindTo, ZEND_ACC_PUBLIC)
+       ZEND_ME(Closure, call, arginfo_class_Closure_call, ZEND_ACC_PUBLIC)
+       ZEND_ME(Closure, fromCallable, arginfo_class_Closure_fromCallable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       ZEND_FE_END
+};