emitter = new class implements Iterator { use Internal\Producer { emit as public; complete as public; fail as public; } }; $this->iterator = new Internal\PrivateIterator($this->emitter); } /** * @return \Amp\Iterator */ public function iterate(): Iterator { return $this->iterator; } /** * Emits a value to the iterator. * * @param mixed $value * * @return \Amp\Promise */ public function emit($value): Promise { return $this->emitter->emit($value); } /** * Completes the iterator. */ public function complete() { $this->emitter->complete(); } /** * Fails the iterator with the given reason. * * @param \Throwable $reason */ public function fail(\Throwable $reason) { $this->emitter->fail($reason); } }