The Generator class

(PHP 5 >= 5.5.0, PHP 7, PHP 8)

Introduction

Generator objects are returned from generators.

Caution

Generator objects cannot be instantiated via new.

Class synopsis

final class Generator implements Iterator {
/* Methods */
public function current(): mixed
public function getReturn(): mixed
public function key(): mixed
public function next(): void
public function rewind(): void
public function send(mixed $value): mixed
public function throw(Throwable $exception): mixed
public function valid(): bool
public function __wakeup(): void
}

See Also

See also object iteration.

Table of Contents