1
0
mirror of https://github.com/danog/amp.git synced 2024-12-11 17:09:40 +01:00
amp/lib/Iterator.php

37 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2016-08-16 06:46:26 +02:00
2016-05-24 18:47:14 +02:00
namespace Amp;
2016-06-01 18:37:12 +02:00
/**
2017-04-27 18:18:25 +02:00
* Defines an asynchronous iterator over a set of values that is designed to be used within a coroutine.
*
* @template-covariant TValue
2020-05-13 17:15:21 +02:00
*
* @deprecated Use {@see Stream} instead.
2016-06-01 18:37:12 +02:00
*/
2018-06-18 20:00:01 +02:00
interface Iterator
{
2016-05-24 18:47:14 +02:00
/**
* Succeeds with true if an emitted value is available by calling getCurrent() or false if the iterator has
* resolved. If the iterator fails, the returned promise will fail with the same exception.
2016-05-27 01:20:05 +02:00
*
* @return Promise
* @psalm-return Promise<bool>
2016-05-27 22:44:01 +02:00
*
* @throws \Error If the prior promise returned from this method has not resolved.
* @throws \Throwable The exception used to fail the iterator.
2016-05-24 18:47:14 +02:00
*/
public function advance(): Promise;
/**
* Gets the last emitted value or throws an exception if the iterator has completed.
*
* @return mixed Value emitted from the iterator.
* @psalm-return TValue
*
* @throws \Error If the iterator has resolved or advance() was not called before calling this method.
* @throws \Throwable The exception used to fail the iterator.
*/
public function getCurrent();
2016-05-24 18:47:14 +02:00
}