]> granicus.if.org Git - php/commitdiff
Add stubs for SplDoublyLinkedList
authorMáté Kocsis <kocsismate@woohoolabs.com>
Wed, 25 Mar 2020 08:24:52 +0000 (09:24 +0100)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Wed, 25 Mar 2020 14:01:24 +0000 (15:01 +0100)
Closes GH-5293

ext/spl/spl_dllist.c
ext/spl/spl_dllist.stub.php [new file with mode: 0755]
ext/spl/spl_dllist_arginfo.h [new file with mode: 0644]

index 9b9ef4cadd577261655e8a4a6f95cba85b5dc4b5..293eba9b7b18f37feb02c359ad5c603eeb7554ca 100644 (file)
@@ -30,6 +30,7 @@
 #include "spl_engine.h"
 #include "spl_iterators.h"
 #include "spl_dllist.h"
+#include "spl_dllist_arginfo.h"
 #include "spl_exceptions.h"
 
 zend_object_handlers spl_handler_SplDoublyLinkedList;
@@ -1097,7 +1098,7 @@ SPL_METHOD(SplDoublyLinkedList, rewind)
 }
 /* }}} */
 
-/* {{{ proto mixed|NULL SplDoublyLinkedList::current()
+/* {{{ proto mixed SplDoublyLinkedList::current()
    Return current datastructure entry */
 SPL_METHOD(SplDoublyLinkedList, current)
 {
@@ -1153,12 +1154,7 @@ SPL_METHOD(SplDoublyLinkedList, serialize)
        /* done */
        PHP_VAR_SERIALIZE_DESTROY(var_hash);
 
-       if (buf.s) {
-               RETURN_NEW_STR(buf.s);
-       } else {
-               RETURN_NULL();
-       }
-
+       RETURN_NEW_STR(buf.s);
 } /* }}} */
 
 /* {{{ proto void SplDoublyLinkedList::unserialize(string serialized)
@@ -1379,69 +1375,44 @@ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object
 }
 /* }}} */
 
-/*  Function/Class/Method definitions */
-ZEND_BEGIN_ARG_INFO(arginfo_dllist_setiteratormode, 0)
-       ZEND_ARG_INFO(0, mode)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_dllist_push, 0)
-       ZEND_ARG_INFO(0, value)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_dllist_offsetGet, 0, 0, 1)
-       ZEND_ARG_INFO(0, index)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_dllist_offsetSet, 0, 0, 2)
-       ZEND_ARG_INFO(0, index)
-       ZEND_ARG_INFO(0, newval)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_dllist_void, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_dllist_serialized, 0)
-       ZEND_ARG_INFO(0, serialized)
-ZEND_END_ARG_INFO();
-
 static const zend_function_entry spl_funcs_SplQueue[] = {
-       SPL_MA(SplQueue, enqueue, SplDoublyLinkedList, push,  arginfo_dllist_push, ZEND_ACC_PUBLIC)
-       SPL_MA(SplQueue, dequeue, SplDoublyLinkedList, shift, arginfo_dllist_void, ZEND_ACC_PUBLIC)
+       SPL_MA(SplQueue, enqueue, SplDoublyLinkedList, push,  arginfo_class_SplQueue_enqueue, ZEND_ACC_PUBLIC)
+       SPL_MA(SplQueue, dequeue, SplDoublyLinkedList, shift, arginfo_class_SplQueue_dequeue, ZEND_ACC_PUBLIC)
        PHP_FE_END
 };
 
 static const zend_function_entry spl_funcs_SplDoublyLinkedList[] = {
-       SPL_ME(SplDoublyLinkedList, pop,             arginfo_dllist_void,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, shift,           arginfo_dllist_void,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, push,            arginfo_dllist_push,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, unshift,         arginfo_dllist_push,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, top,             arginfo_dllist_void,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, bottom,          arginfo_dllist_void,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, isEmpty,         arginfo_dllist_void,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, setIteratorMode, arginfo_dllist_setiteratormode, ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, getIteratorMode, arginfo_dllist_void,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, pop,             arginfo_class_SplDoublyLinkedList_pop,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, shift,           arginfo_class_SplDoublyLinkedList_shift,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, push,            arginfo_class_SplDoublyLinkedList_push,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, unshift,         arginfo_class_SplDoublyLinkedList_unshift,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, top,             arginfo_class_SplDoublyLinkedList_top,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, bottom,          arginfo_class_SplDoublyLinkedList_bottom,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, isEmpty,         arginfo_class_SplDoublyLinkedList_isEmpty,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, setIteratorMode, arginfo_class_SplDoublyLinkedList_setIteratorMode, ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, getIteratorMode, arginfo_class_SplDoublyLinkedList_getIteratorMode,            ZEND_ACC_PUBLIC)
        /* Countable */
-       SPL_ME(SplDoublyLinkedList, count,           arginfo_dllist_void,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, count,           arginfo_class_SplDoublyLinkedList_count,            ZEND_ACC_PUBLIC)
        /* ArrayAccess */
-       SPL_ME(SplDoublyLinkedList, offsetExists,    arginfo_dllist_offsetGet,       ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, offsetGet,       arginfo_dllist_offsetGet,       ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, offsetSet,       arginfo_dllist_offsetSet,       ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, offsetUnset,     arginfo_dllist_offsetGet,       ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, offsetExists,    arginfo_class_SplDoublyLinkedList_offsetExists,       ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, offsetGet,       arginfo_class_SplDoublyLinkedList_offsetGet,       ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, offsetSet,       arginfo_class_SplDoublyLinkedList_offsetSet,       ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, offsetUnset,     arginfo_class_SplDoublyLinkedList_offsetUnset,       ZEND_ACC_PUBLIC)
 
-       SPL_ME(SplDoublyLinkedList, add,             arginfo_dllist_offsetSet,       ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, add,             arginfo_class_SplDoublyLinkedList_add,       ZEND_ACC_PUBLIC)
 
        /* Iterator */
-       SPL_ME(SplDoublyLinkedList, rewind,          arginfo_dllist_void,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, current,         arginfo_dllist_void,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, key,             arginfo_dllist_void,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, next,            arginfo_dllist_void,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, prev,            arginfo_dllist_void,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList, valid,           arginfo_dllist_void,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, rewind,          arginfo_class_SplDoublyLinkedList_rewind,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, current,         arginfo_class_SplDoublyLinkedList_current,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, key,             arginfo_class_SplDoublyLinkedList_key,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, next,            arginfo_class_SplDoublyLinkedList_next,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, prev,            arginfo_class_SplDoublyLinkedList_prev,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, valid,           arginfo_class_SplDoublyLinkedList_valid,            ZEND_ACC_PUBLIC)
        /* Serializable */
-       SPL_ME(SplDoublyLinkedList,  unserialize,    arginfo_dllist_serialized,      ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList,  serialize,      arginfo_dllist_void,            ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList,  __unserialize,    arginfo_dllist_serialized,    ZEND_ACC_PUBLIC)
-       SPL_ME(SplDoublyLinkedList,  __serialize,      arginfo_dllist_void,          ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList,  unserialize,    arginfo_class_SplDoublyLinkedList_unserialize,      ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList,  serialize,      arginfo_class_SplDoublyLinkedList_serialize,            ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList,  __unserialize,    arginfo_class_SplDoublyLinkedList___unserialize,    ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList,  __serialize,      arginfo_class_SplDoublyLinkedList___serialize,          ZEND_ACC_PUBLIC)
        PHP_FE_END
 };
 /* }}} */
diff --git a/ext/spl/spl_dllist.stub.php b/ext/spl/spl_dllist.stub.php
new file mode 100755 (executable)
index 0000000..2c0d95c
--- /dev/null
@@ -0,0 +1,118 @@
+<?php
+
+class SplDoublyLinkedList implements Iterator, Countable, ArrayAccess, Serializable
+{
+    /**
+     * @param mixed $index
+     * @param mixed $value
+     * @return void
+     */
+    public function add($index, $value) {}
+
+    /** @return mixed */
+    public function pop() {}
+
+    /** @return mixed */
+    public function shift() {}
+
+    /**
+     * @param mixed $value
+     * @return bool
+     */
+    public function push($value) {}
+
+    /**
+     * @param mixed $value
+     * @return bool
+     */
+    public function unshift($value) {}
+
+    /** @return mixed */
+    public function top() {}
+
+    /** @return mixed */
+    public function bottom() {}
+
+    /** @return int */
+    public function count() {}
+
+    /** @return bool */
+    public function isEmpty() {}
+
+    /** @return int */
+    public function setIteratorMode(int $mode) {}
+
+    /** @return int */
+    public function getIteratorMode() {}
+
+    /**
+     * @param int $index
+     * @return bool
+     */
+    public function offsetExists($index) {}
+
+    /**
+     * @param mixed $index
+     * @return mixed
+     */
+    public function offsetGet($index) {}
+
+    /**
+     * @param mixed $index
+     * @param mixed $value
+     * @return void
+     */
+    public function offsetSet($index, $value) {}
+
+    /**
+     * @param mixed $index
+     * @return void
+     */
+    public function offsetUnset($index) {}
+
+    /** @return void */
+    public function rewind() {}
+
+    /** @return mixed */
+    public function current() {}
+
+    /** @return int */
+    public function key() {}
+
+    /** @return void */
+    public function prev() {}
+
+    /** @return void */
+    public function next() {}
+
+    /** @return bool */
+    public function valid() {}
+
+    /** @return void */
+    public function unserialize(string $serialized) {}
+
+    /** @return string */
+    public function serialize() {}
+
+    /** @return array */
+    public function __serialize() {}
+
+    /** @return void */
+    public function __unserialize(array $data) {}
+}
+
+class SplQueue extends SplDoublyLinkedList
+{
+    /**
+     * @param mixed $value
+     * @return bool
+     */
+    public function enqueue($value) {}
+
+    /** @return mixed */
+    public function dequeue() {}
+}
+
+class SplStack extends SplDoublyLinkedList
+{
+}
diff --git a/ext/spl/spl_dllist_arginfo.h b/ext/spl/spl_dllist_arginfo.h
new file mode 100644 (file)
index 0000000..5085ca3
--- /dev/null
@@ -0,0 +1,69 @@
+/* This is a generated file, edit the .stub.php file instead. */
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_add, 0, 0, 2)
+       ZEND_ARG_INFO(0, index)
+       ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_pop, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_SplDoublyLinkedList_shift arginfo_class_SplDoublyLinkedList_pop
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_push, 0, 0, 1)
+       ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_SplDoublyLinkedList_unshift arginfo_class_SplDoublyLinkedList_push
+
+#define arginfo_class_SplDoublyLinkedList_top arginfo_class_SplDoublyLinkedList_pop
+
+#define arginfo_class_SplDoublyLinkedList_bottom arginfo_class_SplDoublyLinkedList_pop
+
+#define arginfo_class_SplDoublyLinkedList_count arginfo_class_SplDoublyLinkedList_pop
+
+#define arginfo_class_SplDoublyLinkedList_isEmpty arginfo_class_SplDoublyLinkedList_pop
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_setIteratorMode, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_SplDoublyLinkedList_getIteratorMode arginfo_class_SplDoublyLinkedList_pop
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_offsetExists, 0, 0, 1)
+       ZEND_ARG_INFO(0, index)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_SplDoublyLinkedList_offsetGet arginfo_class_SplDoublyLinkedList_offsetExists
+
+#define arginfo_class_SplDoublyLinkedList_offsetSet arginfo_class_SplDoublyLinkedList_add
+
+#define arginfo_class_SplDoublyLinkedList_offsetUnset arginfo_class_SplDoublyLinkedList_offsetExists
+
+#define arginfo_class_SplDoublyLinkedList_rewind arginfo_class_SplDoublyLinkedList_pop
+
+#define arginfo_class_SplDoublyLinkedList_current arginfo_class_SplDoublyLinkedList_pop
+
+#define arginfo_class_SplDoublyLinkedList_key arginfo_class_SplDoublyLinkedList_pop
+
+#define arginfo_class_SplDoublyLinkedList_prev arginfo_class_SplDoublyLinkedList_pop
+
+#define arginfo_class_SplDoublyLinkedList_next arginfo_class_SplDoublyLinkedList_pop
+
+#define arginfo_class_SplDoublyLinkedList_valid arginfo_class_SplDoublyLinkedList_pop
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_unserialize, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, serialized, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_SplDoublyLinkedList_serialize arginfo_class_SplDoublyLinkedList_pop
+
+#define arginfo_class_SplDoublyLinkedList___serialize arginfo_class_SplDoublyLinkedList_pop
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList___unserialize, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_SplQueue_enqueue arginfo_class_SplDoublyLinkedList_push
+
+#define arginfo_class_SplQueue_dequeue arginfo_class_SplDoublyLinkedList_pop