index === null) { parent::rewind(); } $this->index = 0; } public function current(): mixed { if ($this->offsetExists($this->index)) { return $this->offsetGet($this->index); } return parent::current(); } public function key(): mixed { return $this->index; } public function next(): void { $this->index++; if (!$this->offsetExists($this->index)) { parent::next(); } } public function valid(): bool { return $this->offsetExists($this->index) || parent::valid(); } }