Skip to content

Add stubs for SplDoublyLinkedList #5293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
93 changes: 30 additions & 63 deletions ext/spl/spl_dllist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -566,8 +567,6 @@ SPL_METHOD(SplDoublyLinkedList, push)

intern = Z_SPLDLLIST_P(ZEND_THIS);
spl_ptr_llist_push(intern->llist, value);

RETURN_TRUE;
}
/* }}} */

Expand All @@ -584,8 +583,6 @@ SPL_METHOD(SplDoublyLinkedList, unshift)

intern = Z_SPLDLLIST_P(ZEND_THIS);
spl_ptr_llist_unshift(intern->llist, value);

RETURN_TRUE;
}
/* }}} */

Expand Down Expand Up @@ -1097,7 +1094,7 @@ SPL_METHOD(SplDoublyLinkedList, rewind)
}
/* }}} */

/* {{{ proto mixed|NULL SplDoublyLinkedList::current()
/* {{{ proto mixed SplDoublyLinkedList::current()
Return current datastructure entry */
SPL_METHOD(SplDoublyLinkedList, current)
{
Expand Down Expand Up @@ -1153,12 +1150,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)
Expand Down Expand Up @@ -1379,69 +1371,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
};
/* }}} */
Expand Down
118 changes: 118 additions & 0 deletions ext/spl/spl_dllist.stub.php
Original file line number Diff line number Diff line change
@@ -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 void
*/
public function push($value) {}

/**
* @param mixed $value
* @return void
*/
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 void
*/
public function enqueue($value) {}

/** @return mixed */
public function dequeue() {}
}

class SplStack extends SplDoublyLinkedList
{
}
69 changes: 69 additions & 0 deletions ext/spl/spl_dllist_arginfo.h
Original file line number Diff line number Diff line change
@@ -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