CachingIterator 类

(PHP 5, PHP 7, PHP 8)

简介

该对象支持在另一迭代器上缓存迭代。

类摘要

class CachingIterator extends IteratorIterator implements ArrayAccess, Countable, Stringable {
/* 常量 */
public const int CALL_TOSTRING;
public const int CATCH_GET_CHILD;
public const int TOSTRING_USE_KEY;
public const int TOSTRING_USE_INNER;
public const int FULL_CACHE;
/* 方法 */
public function __construct(Iterator $iterator, int $flags = CachingIterator::CALL_TOSTRING)
public function count(): int
public function current(): mixed
public function getCache(): array
public function getFlags(): int
public function hasNext(): bool
public function key(): scalar
public function next(): void
public function offsetExists(string $key): bool
public function offsetGet(string $key): mixed
public function offsetSet(string $key, mixed $value): void
public function offsetUnset(string $key): void
public function rewind(): void
public function setFlags(int $flags): void
public function __toString(): string
public function valid(): bool
/* 继承的方法 */
public function IteratorIterator::current(): mixed
public function IteratorIterator::key(): mixed
public function IteratorIterator::next(): void
public function IteratorIterator::rewind(): void
public function IteratorIterator::valid(): bool
}

预定义常量

CachingIterator::CALL_TOSTRING

每个元素转换为字符串。

CachingIterator::CATCH_GET_CHILD

访问子元素时不要抛出异常。

CachingIterator::TOSTRING_USE_KEY

转换为字符串时使用 key

CachingIterator::TOSTRING_USE_CURRENT

转换为字符串时使用 current

CachingIterator::TOSTRING_USE_INNER

转换为字符串时使用 inner

CachingIterator::FULL_CACHE

缓存所有读取的数据。

更新日志

版本 说明
8.0.0 CachingIterator 现在实现了 Stringable

目录