Issue: https://github.com/php/php-src/issues/7952
Comment Author: mvorisek
> This is correct as far as I know: iterators do not promise that they are rewound and valid when
> constructed, and are generally in an undefined state (though individual iterator classes may decide
> otherwise). If they did, ones that invoke code like CallbackIterator or Generator would have to
> immediately execute on construction.
It is true that the rewind call invokes the callback (https://3v4l.org/bCi90).
I think the issue should be solved
a) by rewinding, eg. initializing, on the 1st use (when valid, current,
... is called)
b) throwing when used /wo any rewind called as the current behaviour is dangerous,
other iterators are usable without rewinding
I highly prefer a), as this would unify the behaviour with the non-callbacked, commonly used
iterators.