On Mon, Jul 3, 2017 at 5:27 PM, Johannes Schlüter <johan...@schlueters.de> wrote: > > Wouldn't SPL's NoRewindIterator be enough? > > $nit = new NoRewindIterator($it); > > foreach ($nit as $row) { > break; > } > foreach ($nit as $row) { > // continues same iteration > }
I had not noticed this class :) My motivation was to be able to use iterators and readers interchangeably. Readers are easier to implement as classes. Iterators have the benefit of the generator syntax. The idea is to have a library where some stuff is implemented as reader classes, and some other things are implemented as iterator classes. Then for the actual operational code, I need to choose to use either iterator syntax or reader syntax. So either I need adapters for all iterators, or I need adapters for all readers. The NoRewindIterator would make it more viable to work with iterator syntax on operation level. So yes, it is a helpful hint. Not sure if it makes me fully happy. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php