I am iterating an ArrayObject inside of the object itself. Lets see:
class EventsBag extends ArrayObject{
    public function toJson(){
        $events = [];
        $iterator = $this->getIterator();
        while ($iterator->valid()){
            $events[] = $iterator->current();
            $iterator->next();
        }
        return $events;
    }
}
Calling toJson() never ends the script execution:
$events = new EventsBag(['a', 'b']);
var_dump($events->toJson());
I have debugged the script, and the while control never get out. I do not get why this happends.
