PHP Basics

IteratorTrait

A generic implementation of the Iterator interface.

Internally it iterates over the protected $_data array.

Tags
author

Sebastian Meyer sebastian.meyer@opencultureconsulting.com

template
template

Table of Contents

Methods

current()  : TValue|false
Return the current item.
key()  : TKey|null
Return the current key.
next()  : void
Move forward to next item.
prev()  : void
Move back to previous item.
rewind()  : void
Rewind the iterator to the first item.
valid()  : bool
Check if current position is valid.

Methods

current()

Return the current item.

public current() : TValue|false
APIYes
Attributes
#[ReturnTypeWillChange]
Return values
TValue|false

The current item or FALSE if invalid

key()

Return the current key.

public key() : TKey|null
APIYes
Attributes
#[ReturnTypeWillChange]
Return values
TKey|null

The current key or NULL if invalid

next()

Move forward to next item.

public next() : void
APIYes

prev()

Move back to previous item.

public prev() : void
APIYes

rewind()

Rewind the iterator to the first item.

public rewind() : void
APIYes

valid()

Check if current position is valid.

public valid() : bool
APIYes
Tags
phpstan-assert-if-true

TValue $this->current()

phpstan-assert-if-true

!null $this->key()

Return values
bool

Whether the current position is valid


        
On this page

Search results