array = $array; } /** * Returns the current element. * * @return mixed Can return any type. */ public function current(): mixed { return current($this->array); } /** * Returns the key of the current element. * * @return mixed Returns scalar on success, or null on failure. */ public function key(): mixed { return key($this->array); } /** * Moves forward to next element. */ public function next(): void { $this->wasValid = next($this->array) !== false; } /** * Rewind the Iterator to the first element. */ public function rewind(): void { $this->wasValid = reset($this->array) !== false; } /** * Checks if current position is valid. * * @return bool Returns true on success or false on failure. */ public function valid(): bool { return $this->wasValid; } }