SplFixedArray Is Now An IteratorAggregate

SplFixedArray`` used to be an Iterator, and is now an IteratorAggregate.

They don’t have strictly identical behaviors. They’re both iterable but they go about it two completely different ways: Iterator means the object modifies itself during iteration, and IteratorAggregater means the object remains unchanged because it uses a proxy object to handle iteration.

Note that is it not possible to extends both at the same time: they are incompatible.

PHP code

<?php
$array = new SplFixedArray(5);

var_dump($array instanceof Iterator);
var_dump($array instanceof IteratorAggregate);

?>

Before

bool(true)
bool(false)

After

bool(false)
bool(true)

PHP version change

This behavior changed in 8.0

See Also