mirror of
https://github.com/php/php-src.git
synced 2025-01-07 19:44:02 +08:00
- MFH CachingIterator implements Countable
This commit is contained in:
parent
fee1ef3463
commit
58c77d3925
@ -2232,6 +2232,23 @@ SPL_METHOD(CachingIterator, setFlags)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto void CachingIterator::count()
|
||||
Number of cached elements */
|
||||
SPL_METHOD(CachingIterator, count)
|
||||
{
|
||||
spl_dual_it_object *intern;
|
||||
|
||||
intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
|
||||
|
||||
if (!(intern->u.caching.flags & CIT_FULL_CACHE)) {
|
||||
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "%v does not use a full cache (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name);
|
||||
return;
|
||||
}
|
||||
|
||||
RETURN_LONG(zend_hash_num_elements(HASH_OF(intern->u.caching.zcache)));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_caching_it___construct, 0, 0, 1)
|
||||
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
|
||||
@ -2271,6 +2288,7 @@ static zend_function_entry spl_funcs_CachingIterator[] = {
|
||||
SPL_ME(CachingIterator, offsetUnset, arginfo_caching_it_offsetGet, ZEND_ACC_PUBLIC)
|
||||
SPL_ME(CachingIterator, offsetExists, arginfo_caching_it_offsetGet, ZEND_ACC_PUBLIC)
|
||||
SPL_ME(CachingIterator, getCache, NULL, ZEND_ACC_PUBLIC)
|
||||
SPL_ME(CachingIterator, count, NULL, ZEND_ACC_PUBLIC)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
@ -2900,6 +2918,7 @@ PHP_MINIT_FUNCTION(spl_iterators)
|
||||
|
||||
REGISTER_SPL_SUB_CLASS_EX(CachingIterator, IteratorIterator, spl_dual_it_new, spl_funcs_CachingIterator);
|
||||
REGISTER_SPL_IMPLEMENTS(CachingIterator, ArrayAccess);
|
||||
REGISTER_SPL_IMPLEMENTS(CachingIterator, Countable);
|
||||
|
||||
REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CALL_TOSTRING", CIT_CALL_TOSTRING);
|
||||
REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CATCH_GET_CHILD", CIT_CATCH_GET_CHILD);
|
||||
|
Loading…
Reference in New Issue
Block a user