The CachingIterator class

(PHP 5, PHP 7, PHP 8)

Introduction

This object supports cached iteration over another iterator.

Class synopsis

classCachingIteratorextendsIteratorIteratorimplementsArrayAccess, Countable, Stringable {
publicconstintCALL_TOSTRING;
publicconstintCATCH_GET_CHILD;
publicconstintFULL_CACHE;
public__construct(Iterator$iterator, int$flags = CachingIterator::CALL_TOSTRING)
publiccount(): int
publiccurrent(): mixed
publicgetCache(): array
publicgetFlags(): int
publichasNext(): bool
publickey(): scalar
publicnext(): void
publicoffsetGet(string$key): mixed
publicoffsetSet(string$key, mixed$value): void
publicoffsetUnset(string$key): void
publicrewind(): void
publicsetFlags(int$flags): void
publicvalid(): bool
}

Predefined Constants

CachingIterator::CALL_TOSTRING

Convert every element to string.

CachingIterator::CATCH_GET_CHILD

Don't throw exception in accessing children.

CachingIterator::TOSTRING_USE_KEY

Use key for conversion to string.

CachingIterator::TOSTRING_USE_CURRENT

Use current for conversion to string.

CachingIterator::TOSTRING_USE_INNER

Use inner for conversion to string.

CachingIterator::FULL_CACHE

Cache all read data.

Changelog

VersionDescription
8.0.0CachingIterator implements Stringable now.

Table of Contents

To Top