From c033d4495048aec8c2254015348ec817569ee326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 25 Mar 2020 09:24:52 +0100 Subject: [PATCH 1/3] Add stubs for SplDoublyLinkedList --- ext/spl/spl_dllist.c | 89 +++++++++----------------- ext/spl/spl_dllist.stub.php | 118 +++++++++++++++++++++++++++++++++++ ext/spl/spl_dllist_arginfo.h | 69 ++++++++++++++++++++ 3 files changed, 217 insertions(+), 59 deletions(-) create mode 100755 ext/spl/spl_dllist.stub.php create mode 100644 ext/spl/spl_dllist_arginfo.h diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 9b9ef4cadd57..293eba9b7b18 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -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 index 000000000000..be92eb7354a2 --- /dev/null +++ b/ext/spl/spl_dllist.stub.php @@ -0,0 +1,118 @@ + Date: Wed, 25 Mar 2020 12:18:42 +0100 Subject: [PATCH 2/3] Address code review comments --- ext/spl/spl_dllist.stub.php | 30 +++++++++++----------- ext/spl/spl_dllist_arginfo.h | 48 ++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/ext/spl/spl_dllist.stub.php b/ext/spl/spl_dllist.stub.php index be92eb7354a2..2c0d95c3dc82 100755 --- a/ext/spl/spl_dllist.stub.php +++ b/ext/spl/spl_dllist.stub.php @@ -1,17 +1,5 @@ Date: Wed, 25 Mar 2020 12:33:38 +0100 Subject: [PATCH 3/3] Return void instead of true --- UPGRADING | 3 +++ ext/spl/spl_dllist.c | 4 ---- ext/spl/spl_dllist.stub.php | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/UPGRADING b/UPGRADING index ae8e27611988..183ded3ab789 100644 --- a/UPGRADING +++ b/UPGRADING @@ -314,6 +314,9 @@ PHP 8.0 UPGRADE NOTES . SplHeap::compare($a, $b) now specifies a method signature. Inheriting classes implementing this method will now have to use a compatible method signature. + . SplDoublyLinkedList::push() now returns void instead of true + . SplDoublyLinkedList::unshift() now returns void instead of true + . SplQueue::enqueue() now returns void instead of true - Standard: . assert() will no longer evaluate string arguments, instead they will be diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 293eba9b7b18..0aa4250fe468 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -567,8 +567,6 @@ SPL_METHOD(SplDoublyLinkedList, push) intern = Z_SPLDLLIST_P(ZEND_THIS); spl_ptr_llist_push(intern->llist, value); - - RETURN_TRUE; } /* }}} */ @@ -585,8 +583,6 @@ SPL_METHOD(SplDoublyLinkedList, unshift) intern = Z_SPLDLLIST_P(ZEND_THIS); spl_ptr_llist_unshift(intern->llist, value); - - RETURN_TRUE; } /* }}} */ diff --git a/ext/spl/spl_dllist.stub.php b/ext/spl/spl_dllist.stub.php index 2c0d95c3dc82..c4101cc75c38 100755 --- a/ext/spl/spl_dllist.stub.php +++ b/ext/spl/spl_dllist.stub.php @@ -17,13 +17,13 @@ public function shift() {} /** * @param mixed $value - * @return bool + * @return void */ public function push($value) {} /** * @param mixed $value - * @return bool + * @return void */ public function unshift($value) {} @@ -105,7 +105,7 @@ class SplQueue extends SplDoublyLinkedList { /** * @param mixed $value - * @return bool + * @return void */ public function enqueue($value) {}