iterator = new Internal\PrivateIterator( function (callable $emit, callable $complete, callable $fail) { $this->emit = $emit; $this->complete = $complete; $this->fail = $fail; } ); } /** * @return \Amp\Iterator */ public function getIterator(): Iterator { return $this->iterator; } /** * Emits a value to the iterator. * * @param mixed $value * * @return \Amp\Promise */ public function emit($value): Promise { return ($this->emit)($value); } /** * Completes the iterator. */ public function complete() { ($this->complete)(); } /** * Fails the iterator with the given reason. * * @param \Throwable $reason */ public function fail(\Throwable $reason) { ($this->fail)($reason); } } } else { production: // PHP 7 production environment (zend.assertions=0) /** * An optimized version of Emitter for production environments that is itself the iterator. Eval is used to * prevent IDEs and other tools from reporting multiple definitions. */ eval('namespace Amp; final class Emitter implements Iterator { use Internal\Producer { emit as public; complete as public; fail as public; } public function getIterator(): Iterator { return $this; } }'); } } catch (\AssertionError $exception) { goto development; // zend.assertions=1 and assert.exception=1, use development definition. } // @codeCoverageIgnoreEnd