<?php
class test implements IteratorAggregate {
public function getIterator() {
return new ArrayIterator([1,2,3]);
}
}
foreach(new test() as $t) {
echo $t, PHP_EOL;
}
Deprecated: Return type of test::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/jIuJt on line 4
1
2
3