Skip to content

Commit 2e8ccce

Browse files
committed
Add stubs for SplDoublyLinkedList
Closes GH-5293
1 parent b7c6244 commit 2e8ccce

File tree

3 files changed

+217
-59
lines changed

3 files changed

+217
-59
lines changed

ext/spl/spl_dllist.c

+30-59
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "spl_engine.h"
3131
#include "spl_iterators.h"
3232
#include "spl_dllist.h"
33+
#include "spl_dllist_arginfo.h"
3334
#include "spl_exceptions.h"
3435

3536
zend_object_handlers spl_handler_SplDoublyLinkedList;
@@ -1097,7 +1098,7 @@ SPL_METHOD(SplDoublyLinkedList, rewind)
10971098
}
10981099
/* }}} */
10991100

1100-
/* {{{ proto mixed|NULL SplDoublyLinkedList::current()
1101+
/* {{{ proto mixed SplDoublyLinkedList::current()
11011102
Return current datastructure entry */
11021103
SPL_METHOD(SplDoublyLinkedList, current)
11031104
{
@@ -1153,12 +1154,7 @@ SPL_METHOD(SplDoublyLinkedList, serialize)
11531154
/* done */
11541155
PHP_VAR_SERIALIZE_DESTROY(var_hash);
11551156

1156-
if (buf.s) {
1157-
RETURN_NEW_STR(buf.s);
1158-
} else {
1159-
RETURN_NULL();
1160-
}
1161-
1157+
RETURN_NEW_STR(buf.s);
11621158
} /* }}} */
11631159

11641160
/* {{{ proto void SplDoublyLinkedList::unserialize(string serialized)
@@ -1379,69 +1375,44 @@ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object
13791375
}
13801376
/* }}} */
13811377

1382-
/* Function/Class/Method definitions */
1383-
ZEND_BEGIN_ARG_INFO(arginfo_dllist_setiteratormode, 0)
1384-
ZEND_ARG_INFO(0, mode)
1385-
ZEND_END_ARG_INFO()
1386-
1387-
ZEND_BEGIN_ARG_INFO(arginfo_dllist_push, 0)
1388-
ZEND_ARG_INFO(0, value)
1389-
ZEND_END_ARG_INFO()
1390-
1391-
ZEND_BEGIN_ARG_INFO_EX(arginfo_dllist_offsetGet, 0, 0, 1)
1392-
ZEND_ARG_INFO(0, index)
1393-
ZEND_END_ARG_INFO()
1394-
1395-
ZEND_BEGIN_ARG_INFO_EX(arginfo_dllist_offsetSet, 0, 0, 2)
1396-
ZEND_ARG_INFO(0, index)
1397-
ZEND_ARG_INFO(0, newval)
1398-
ZEND_END_ARG_INFO()
1399-
1400-
ZEND_BEGIN_ARG_INFO(arginfo_dllist_void, 0)
1401-
ZEND_END_ARG_INFO()
1402-
1403-
ZEND_BEGIN_ARG_INFO(arginfo_dllist_serialized, 0)
1404-
ZEND_ARG_INFO(0, serialized)
1405-
ZEND_END_ARG_INFO();
1406-
14071378
static const zend_function_entry spl_funcs_SplQueue[] = {
1408-
SPL_MA(SplQueue, enqueue, SplDoublyLinkedList, push, arginfo_dllist_push, ZEND_ACC_PUBLIC)
1409-
SPL_MA(SplQueue, dequeue, SplDoublyLinkedList, shift, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1379+
SPL_MA(SplQueue, enqueue, SplDoublyLinkedList, push, arginfo_class_SplQueue_enqueue, ZEND_ACC_PUBLIC)
1380+
SPL_MA(SplQueue, dequeue, SplDoublyLinkedList, shift, arginfo_class_SplQueue_dequeue, ZEND_ACC_PUBLIC)
14101381
PHP_FE_END
14111382
};
14121383

14131384
static const zend_function_entry spl_funcs_SplDoublyLinkedList[] = {
1414-
SPL_ME(SplDoublyLinkedList, pop, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1415-
SPL_ME(SplDoublyLinkedList, shift, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1416-
SPL_ME(SplDoublyLinkedList, push, arginfo_dllist_push, ZEND_ACC_PUBLIC)
1417-
SPL_ME(SplDoublyLinkedList, unshift, arginfo_dllist_push, ZEND_ACC_PUBLIC)
1418-
SPL_ME(SplDoublyLinkedList, top, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1419-
SPL_ME(SplDoublyLinkedList, bottom, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1420-
SPL_ME(SplDoublyLinkedList, isEmpty, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1421-
SPL_ME(SplDoublyLinkedList, setIteratorMode, arginfo_dllist_setiteratormode, ZEND_ACC_PUBLIC)
1422-
SPL_ME(SplDoublyLinkedList, getIteratorMode, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1385+
SPL_ME(SplDoublyLinkedList, pop, arginfo_class_SplDoublyLinkedList_pop, ZEND_ACC_PUBLIC)
1386+
SPL_ME(SplDoublyLinkedList, shift, arginfo_class_SplDoublyLinkedList_shift, ZEND_ACC_PUBLIC)
1387+
SPL_ME(SplDoublyLinkedList, push, arginfo_class_SplDoublyLinkedList_push, ZEND_ACC_PUBLIC)
1388+
SPL_ME(SplDoublyLinkedList, unshift, arginfo_class_SplDoublyLinkedList_unshift, ZEND_ACC_PUBLIC)
1389+
SPL_ME(SplDoublyLinkedList, top, arginfo_class_SplDoublyLinkedList_top, ZEND_ACC_PUBLIC)
1390+
SPL_ME(SplDoublyLinkedList, bottom, arginfo_class_SplDoublyLinkedList_bottom, ZEND_ACC_PUBLIC)
1391+
SPL_ME(SplDoublyLinkedList, isEmpty, arginfo_class_SplDoublyLinkedList_isEmpty, ZEND_ACC_PUBLIC)
1392+
SPL_ME(SplDoublyLinkedList, setIteratorMode, arginfo_class_SplDoublyLinkedList_setIteratorMode, ZEND_ACC_PUBLIC)
1393+
SPL_ME(SplDoublyLinkedList, getIteratorMode, arginfo_class_SplDoublyLinkedList_getIteratorMode, ZEND_ACC_PUBLIC)
14231394
/* Countable */
1424-
SPL_ME(SplDoublyLinkedList, count, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1395+
SPL_ME(SplDoublyLinkedList, count, arginfo_class_SplDoublyLinkedList_count, ZEND_ACC_PUBLIC)
14251396
/* ArrayAccess */
1426-
SPL_ME(SplDoublyLinkedList, offsetExists, arginfo_dllist_offsetGet, ZEND_ACC_PUBLIC)
1427-
SPL_ME(SplDoublyLinkedList, offsetGet, arginfo_dllist_offsetGet, ZEND_ACC_PUBLIC)
1428-
SPL_ME(SplDoublyLinkedList, offsetSet, arginfo_dllist_offsetSet, ZEND_ACC_PUBLIC)
1429-
SPL_ME(SplDoublyLinkedList, offsetUnset, arginfo_dllist_offsetGet, ZEND_ACC_PUBLIC)
1397+
SPL_ME(SplDoublyLinkedList, offsetExists, arginfo_class_SplDoublyLinkedList_offsetExists, ZEND_ACC_PUBLIC)
1398+
SPL_ME(SplDoublyLinkedList, offsetGet, arginfo_class_SplDoublyLinkedList_offsetGet, ZEND_ACC_PUBLIC)
1399+
SPL_ME(SplDoublyLinkedList, offsetSet, arginfo_class_SplDoublyLinkedList_offsetSet, ZEND_ACC_PUBLIC)
1400+
SPL_ME(SplDoublyLinkedList, offsetUnset, arginfo_class_SplDoublyLinkedList_offsetUnset, ZEND_ACC_PUBLIC)
14301401

1431-
SPL_ME(SplDoublyLinkedList, add, arginfo_dllist_offsetSet, ZEND_ACC_PUBLIC)
1402+
SPL_ME(SplDoublyLinkedList, add, arginfo_class_SplDoublyLinkedList_add, ZEND_ACC_PUBLIC)
14321403

14331404
/* Iterator */
1434-
SPL_ME(SplDoublyLinkedList, rewind, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1435-
SPL_ME(SplDoublyLinkedList, current, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1436-
SPL_ME(SplDoublyLinkedList, key, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1437-
SPL_ME(SplDoublyLinkedList, next, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1438-
SPL_ME(SplDoublyLinkedList, prev, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1439-
SPL_ME(SplDoublyLinkedList, valid, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1405+
SPL_ME(SplDoublyLinkedList, rewind, arginfo_class_SplDoublyLinkedList_rewind, ZEND_ACC_PUBLIC)
1406+
SPL_ME(SplDoublyLinkedList, current, arginfo_class_SplDoublyLinkedList_current, ZEND_ACC_PUBLIC)
1407+
SPL_ME(SplDoublyLinkedList, key, arginfo_class_SplDoublyLinkedList_key, ZEND_ACC_PUBLIC)
1408+
SPL_ME(SplDoublyLinkedList, next, arginfo_class_SplDoublyLinkedList_next, ZEND_ACC_PUBLIC)
1409+
SPL_ME(SplDoublyLinkedList, prev, arginfo_class_SplDoublyLinkedList_prev, ZEND_ACC_PUBLIC)
1410+
SPL_ME(SplDoublyLinkedList, valid, arginfo_class_SplDoublyLinkedList_valid, ZEND_ACC_PUBLIC)
14401411
/* Serializable */
1441-
SPL_ME(SplDoublyLinkedList, unserialize, arginfo_dllist_serialized, ZEND_ACC_PUBLIC)
1442-
SPL_ME(SplDoublyLinkedList, serialize, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1443-
SPL_ME(SplDoublyLinkedList, __unserialize, arginfo_dllist_serialized, ZEND_ACC_PUBLIC)
1444-
SPL_ME(SplDoublyLinkedList, __serialize, arginfo_dllist_void, ZEND_ACC_PUBLIC)
1412+
SPL_ME(SplDoublyLinkedList, unserialize, arginfo_class_SplDoublyLinkedList_unserialize, ZEND_ACC_PUBLIC)
1413+
SPL_ME(SplDoublyLinkedList, serialize, arginfo_class_SplDoublyLinkedList_serialize, ZEND_ACC_PUBLIC)
1414+
SPL_ME(SplDoublyLinkedList, __unserialize, arginfo_class_SplDoublyLinkedList___unserialize, ZEND_ACC_PUBLIC)
1415+
SPL_ME(SplDoublyLinkedList, __serialize, arginfo_class_SplDoublyLinkedList___serialize, ZEND_ACC_PUBLIC)
14451416
PHP_FE_END
14461417
};
14471418
/* }}} */

ext/spl/spl_dllist.stub.php

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
3+
class SplDoublyLinkedList implements Iterator, Countable, ArrayAccess, Serializable
4+
{
5+
/**
6+
* @param mixed $index
7+
* @param mixed $value
8+
* @return void
9+
*/
10+
public function add($index, $value) {}
11+
12+
/** @return mixed */
13+
public function pop() {}
14+
15+
/** @return mixed */
16+
public function shift() {}
17+
18+
/**
19+
* @param mixed $value
20+
* @return bool
21+
*/
22+
public function push($value) {}
23+
24+
/**
25+
* @param mixed $value
26+
* @return bool
27+
*/
28+
public function unshift($value) {}
29+
30+
/** @return mixed */
31+
public function top() {}
32+
33+
/** @return mixed */
34+
public function bottom() {}
35+
36+
/** @return int */
37+
public function count() {}
38+
39+
/** @return bool */
40+
public function isEmpty() {}
41+
42+
/** @return int */
43+
public function setIteratorMode(int $mode) {}
44+
45+
/** @return int */
46+
public function getIteratorMode() {}
47+
48+
/**
49+
* @param int $index
50+
* @return bool
51+
*/
52+
public function offsetExists($index) {}
53+
54+
/**
55+
* @param mixed $index
56+
* @return mixed
57+
*/
58+
public function offsetGet($index) {}
59+
60+
/**
61+
* @param mixed $index
62+
* @param mixed $value
63+
* @return void
64+
*/
65+
public function offsetSet($index, $value) {}
66+
67+
/**
68+
* @param mixed $index
69+
* @return void
70+
*/
71+
public function offsetUnset($index) {}
72+
73+
/** @return void */
74+
public function rewind() {}
75+
76+
/** @return mixed */
77+
public function current() {}
78+
79+
/** @return int */
80+
public function key() {}
81+
82+
/** @return void */
83+
public function prev() {}
84+
85+
/** @return void */
86+
public function next() {}
87+
88+
/** @return bool */
89+
public function valid() {}
90+
91+
/** @return void */
92+
public function unserialize(string $serialized) {}
93+
94+
/** @return string */
95+
public function serialize() {}
96+
97+
/** @return array */
98+
public function __serialize() {}
99+
100+
/** @return void */
101+
public function __unserialize(array $data) {}
102+
}
103+
104+
class SplQueue extends SplDoublyLinkedList
105+
{
106+
/**
107+
* @param mixed $value
108+
* @return bool
109+
*/
110+
public function enqueue($value) {}
111+
112+
/** @return mixed */
113+
public function dequeue() {}
114+
}
115+
116+
class SplStack extends SplDoublyLinkedList
117+
{
118+
}

ext/spl/spl_dllist_arginfo.h

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_add, 0, 0, 2)
4+
ZEND_ARG_INFO(0, index)
5+
ZEND_ARG_INFO(0, value)
6+
ZEND_END_ARG_INFO()
7+
8+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_pop, 0, 0, 0)
9+
ZEND_END_ARG_INFO()
10+
11+
#define arginfo_class_SplDoublyLinkedList_shift arginfo_class_SplDoublyLinkedList_pop
12+
13+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_push, 0, 0, 1)
14+
ZEND_ARG_INFO(0, value)
15+
ZEND_END_ARG_INFO()
16+
17+
#define arginfo_class_SplDoublyLinkedList_unshift arginfo_class_SplDoublyLinkedList_push
18+
19+
#define arginfo_class_SplDoublyLinkedList_top arginfo_class_SplDoublyLinkedList_pop
20+
21+
#define arginfo_class_SplDoublyLinkedList_bottom arginfo_class_SplDoublyLinkedList_pop
22+
23+
#define arginfo_class_SplDoublyLinkedList_count arginfo_class_SplDoublyLinkedList_pop
24+
25+
#define arginfo_class_SplDoublyLinkedList_isEmpty arginfo_class_SplDoublyLinkedList_pop
26+
27+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_setIteratorMode, 0, 0, 1)
28+
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
29+
ZEND_END_ARG_INFO()
30+
31+
#define arginfo_class_SplDoublyLinkedList_getIteratorMode arginfo_class_SplDoublyLinkedList_pop
32+
33+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_offsetExists, 0, 0, 1)
34+
ZEND_ARG_INFO(0, index)
35+
ZEND_END_ARG_INFO()
36+
37+
#define arginfo_class_SplDoublyLinkedList_offsetGet arginfo_class_SplDoublyLinkedList_offsetExists
38+
39+
#define arginfo_class_SplDoublyLinkedList_offsetSet arginfo_class_SplDoublyLinkedList_add
40+
41+
#define arginfo_class_SplDoublyLinkedList_offsetUnset arginfo_class_SplDoublyLinkedList_offsetExists
42+
43+
#define arginfo_class_SplDoublyLinkedList_rewind arginfo_class_SplDoublyLinkedList_pop
44+
45+
#define arginfo_class_SplDoublyLinkedList_current arginfo_class_SplDoublyLinkedList_pop
46+
47+
#define arginfo_class_SplDoublyLinkedList_key arginfo_class_SplDoublyLinkedList_pop
48+
49+
#define arginfo_class_SplDoublyLinkedList_prev arginfo_class_SplDoublyLinkedList_pop
50+
51+
#define arginfo_class_SplDoublyLinkedList_next arginfo_class_SplDoublyLinkedList_pop
52+
53+
#define arginfo_class_SplDoublyLinkedList_valid arginfo_class_SplDoublyLinkedList_pop
54+
55+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_unserialize, 0, 0, 1)
56+
ZEND_ARG_TYPE_INFO(0, serialized, IS_STRING, 0)
57+
ZEND_END_ARG_INFO()
58+
59+
#define arginfo_class_SplDoublyLinkedList_serialize arginfo_class_SplDoublyLinkedList_pop
60+
61+
#define arginfo_class_SplDoublyLinkedList___serialize arginfo_class_SplDoublyLinkedList_pop
62+
63+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList___unserialize, 0, 0, 1)
64+
ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0)
65+
ZEND_END_ARG_INFO()
66+
67+
#define arginfo_class_SplQueue_enqueue arginfo_class_SplDoublyLinkedList_push
68+
69+
#define arginfo_class_SplQueue_dequeue arginfo_class_SplDoublyLinkedList_pop

0 commit comments

Comments
 (0)