The IteratorIterator class

(PHP 5 >= 5.1.0, PHP 7, PHP 8)


This iterator wrapper allows the conversion of anything that is Traversable into an Iterator. It is important to understand that most classes that do not implement Iterators have reasons as most likely they do not allow the full Iterator feature set. If so, techniques should be provided to prevent misuse, otherwise expect exceptions or fatal errors.


class IteratorIterator implements OuterIterator {
/* 方法 */
public __construct(Traversable $iterator, ?string $class = null)
public current(): mixed
public key(): mixed
public next(): void
public rewind(): void
public valid(): bool



This class permits access to methods of the inner iterator via the __call magic method.