Fix ZPP of MultipleIterator::detachIterator() and MultipleIterator::containsIterator()

This commit is contained in:
Máté Kocsis 2020-03-16 10:27:48 +01:00
parent 04a44e1f08
commit c3554eb2c4
No known key found for this signature in database
GPG Key ID: FD055E41728BF310
3 changed files with 37 additions and 13 deletions

View File

@ -719,12 +719,7 @@ SPL_METHOD(SplObjectStorage, 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 SplObjectStorage::unserialize(string serialized)
@ -1046,6 +1041,35 @@ SPL_METHOD(MultipleIterator, attachIterator)
}
/* }}} */
/* {{{ proto void MultipleIterator::detachIterator(Iterator iterator)
Detaches an iterator */
SPL_METHOD(MultipleIterator, detachIterator)
{
zval *iterator;
spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &iterator, zend_ce_iterator) == FAILURE) {
RETURN_THROWS();
}
spl_object_storage_detach(intern, iterator);
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
intern->index = 0;
} /* }}} */
/* {{{ proto bool MultipleIterator::containsIterator(Iterator iterator)
Determine whether the iterator exists */
SPL_METHOD(MultipleIterator, containsIterator)
{
zval *iterator;
spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &iterator, zend_ce_iterator) == FAILURE) {
RETURN_THROWS();
}
RETURN_BOOL(spl_object_storage_contains(intern, iterator));
} /* }}} */
/* {{{ proto void MultipleIterator::rewind()
Rewind all attached iterator instances */
SPL_METHOD(MultipleIterator, rewind)
@ -1239,8 +1263,8 @@ static const zend_function_entry spl_funcs_MultipleIterator[] = {
SPL_ME(MultipleIterator, getFlags, arginfo_class_MultipleIterator_getFlags, 0)
SPL_ME(MultipleIterator, setFlags, arginfo_class_MultipleIterator_setFlags, 0)
SPL_ME(MultipleIterator, attachIterator, arginfo_class_MultipleIterator_attachIterator, 0)
SPL_MA(MultipleIterator, detachIterator, SplObjectStorage, detach, arginfo_class_MultipleIterator_detachIterator, 0)
SPL_MA(MultipleIterator, containsIterator, SplObjectStorage, contains, arginfo_class_MultipleIterator_containsIterator, 0)
SPL_ME(MultipleIterator, detachIterator, arginfo_class_MultipleIterator_detachIterator, 0)
SPL_ME(MultipleIterator, containsIterator, arginfo_class_MultipleIterator_containsIterator, 0)
SPL_MA(MultipleIterator, countIterators, SplObjectStorage, count, arginfo_class_MultipleIterator_countIterators, 0)
/* Iterator */
SPL_ME(MultipleIterator, rewind, arginfo_class_MultipleIterator_rewind, 0)

View File

@ -71,7 +71,7 @@ class SplObjectStorage implements Countable, Iterator, Serializable, ArrayAccess
/** @return void */
public function unserialize(string $serialized) {}
/** @return string|null */
/** @return string */
public function serialize() {}
/**
@ -82,7 +82,7 @@ class SplObjectStorage implements Countable, Iterator, Serializable, ArrayAccess
/**
* @param object $object
* @return string
* @return mixed
*/
public function offsetGet($object) {}
@ -127,10 +127,10 @@ class MultipleIterator implements Iterator
public function attachIterator(Iterator $iterator, $info = null) {}
/** @return void */
public function detachIterator(object $iterator) {}
public function detachIterator(Iterator $iterator) {}
/** @return bool */
public function containsIterator(object $iterator) {}
public function containsIterator(Iterator $iterator) {}
/** @return int */
public function countIterators() {}

View File

@ -95,7 +95,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MultipleIterator_attachIterator, 0, 0, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MultipleIterator_detachIterator, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, iterator, IS_OBJECT, 0)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_MultipleIterator_containsIterator arginfo_class_MultipleIterator_detachIterator