summaryrefslogtreecommitdiff
path: root/ext/spl
diff options
context:
space:
mode:
authorTyson Andre <tysonandre775@hotmail.com>2017-07-02 10:10:59 -0400
committerSara Golemon <pollita@php.net>2017-07-02 10:37:28 -0400
commit96fe07e0062393d04188aa79f66979fc6bd4fee8 (patch)
tree81b7f90f996ba80d2d4d6057a7d5e46b6012d6f7 /ext/spl
parent04d7595e58ed13c0c25d190e2a91c3d6a3d031ab (diff)
downloadphp-git-96fe07e0062393d04188aa79f66979fc6bd4fee8.tar.gz
Fixes Bug #71412 Incorrect ArrayIterator __construct signature
ArrayIterator doesn't have a getIterator method(), or an iterator setter, and I don't think it makes sense for it to have one.
Diffstat (limited to 'ext/spl')
-rw-r--r--ext/spl/spl_array.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index c31ddf80ec..7d157c91c7 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -153,7 +153,7 @@ static zend_always_inline uint32_t *spl_array_get_pos_ptr(HashTable *ht, spl_arr
static void spl_array_object_free_storage(zend_object *object)
{
spl_array_object *intern = spl_array_from_obj(object);
-
+
if (intern->ht_iter != (uint32_t) -1) {
zend_hash_iterator_del(intern->ht_iter);
}
@@ -1192,8 +1192,7 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object,
/* }}} */
/* {{{ proto void ArrayObject::__construct([array|object ar = array() [, int flags = 0 [, string iterator_class = "ArrayIterator"]]])
- proto void ArrayIterator::__construct([array|object ar = array() [, int flags = 0]])
- Constructs a new array iterator from a path. */
+ Constructs a new array object from an array or object. */
SPL_METHOD(Array, __construct)
{
zval *object = getThis();
@@ -1222,6 +1221,31 @@ SPL_METHOD(Array, __construct)
}
/* }}} */
+/* {{{ proto void ArrayIterator::__construct([array|object ar = array() [, int flags = 0]])
+ Constructs a new array iterator from an array or object. */
+SPL_METHOD(ArrayIterator, __construct)
+{
+ zval *object = getThis();
+ spl_array_object *intern;
+ zval *array;
+ zend_long ar_flags = 0;
+
+ if (ZEND_NUM_ARGS() == 0) {
+ return; /* nothing to do */
+ }
+
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "z|l", &array, &ar_flags) == FAILURE) {
+ return;
+ }
+
+ intern = Z_SPLARRAY_P(object);
+
+ ar_flags &= ~SPL_ARRAY_INT_MASK;
+
+ spl_array_set_array(object, intern, array, ar_flags, ZEND_NUM_ARGS() == 1);
+}
+ /* }}} */
+
/* {{{ proto void ArrayObject::setIteratorClass(string iterator_class)
Set the class used in getIterator. */
SPL_METHOD(Array, setIteratorClass)
@@ -1839,6 +1863,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_array___construct, 0, 0, 0)
ZEND_ARG_INFO(0, iterator_class)
ZEND_END_ARG_INFO()
+/* ArrayIterator::__construct and ArrayObject::__construct have different signatures */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_array_iterator___construct, 0, 0, 0)
+ ZEND_ARG_INFO(0, array)
+ ZEND_ARG_INFO(0, ar_flags)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_array_offsetGet, 0, 0, 1)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
@@ -1907,7 +1937,7 @@ static const zend_function_entry spl_funcs_ArrayObject[] = {
};
static const zend_function_entry spl_funcs_ArrayIterator[] = {
- SPL_ME(Array, __construct, arginfo_array___construct, ZEND_ACC_PUBLIC)
+ SPL_ME(ArrayIterator, __construct, arginfo_array_iterator___construct, ZEND_ACC_PUBLIC)
SPL_ME(Array, offsetExists, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
SPL_ME(Array, offsetGet, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
SPL_ME(Array, offsetSet, arginfo_array_offsetSet, ZEND_ACC_PUBLIC)