class InfiniteIterator extends IteratorIterator (View source)

The InfiniteIterator allows one to infinitely iterate over an iterator without having to manually rewind the iterator upon reaching its end.

Methods

__construct(Traversable $iterator)

Constructs an InfiniteIterator

Iterator|null
getInnerIterator()

Get the inner iterator

void
rewind()

Rewind to the first element

bool
valid()

Checks if the iterator is valid

mixed
key()

Get the key of the current element

mixed
current()

Get the current value

void
next()

Moves the inner Iterator forward or rewinds it

Details

__construct(Traversable $iterator)

Constructs an InfiniteIterator

Parameters

Traversable $iterator

Iterator|null getInnerIterator()

Get the inner iterator

Return Value

Iterator|null

The inner iterator for the current entry.

void rewind()

Rewind to the first element

Return Value

void

Any returned value is ignored.

bool valid()

Checks if the iterator is valid

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.

mixed key()

Get the key of the current element

Return Value

mixed

TKey on success, or null on failure.

mixed current()

Get the current value

Return Value

mixed

Can return any type.

void next()

Moves the inner Iterator forward or rewinds it

Return Value

void

Any returned value is ignored.