Has public yield, complete, and fail methods. */ private $source; public function __construct() { $this->source = new Internal\YieldSource; } /** * Returns a Stream that can be given to an API consumer. This method may be called only once! * * @return Stream * * @psalm-return Stream * * @throws \Error If this method is called more than once. */ public function stream(): Stream { return $this->source->stream(); } /** * Yields a value to the stream. * * @param mixed $value * * @psalm-param TValue $value * * @return Promise Resolves with null when the yielded value has been consumed or fails with * {@see DisposedException} if the stream has been destroyed. */ public function yield($value): Promise { return $this->source->yield($value); } /** * Completes the stream. * * @return void */ public function complete() { $this->source->complete(); } /** * Fails the stream with the given reason. * * @param \Throwable $reason * * @return void */ public function fail(\Throwable $reason) { $this->source->fail($reason); } }