2016-12-29 21:09:49 +01:00
|
|
|
<?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.
|
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
|
|
|
/**
|
2017-05-01 07:32:56 +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
|
|
|
*
|
2017-04-26 19:20:30 +02:00
|
|
|
* @return \Amp\Promise<bool>
|
2016-05-27 22:44:01 +02:00
|
|
|
*
|
2017-04-26 19:20:30 +02:00
|
|
|
* @throws \Error If the prior promise returned from this method has not resolved.
|
2017-05-01 07:32:56 +02:00
|
|
|
* @throws \Throwable The exception used to fail the iterator.
|
2016-05-24 18:47:14 +02:00
|
|
|
*/
|
2017-04-26 19:20:30 +02:00
|
|
|
public function advance(): Promise;
|
|
|
|
|
|
|
|
/**
|
2017-05-01 07:32:56 +02:00
|
|
|
* Gets the last emitted value or throws an exception if the iterator has completed.
|
2017-04-26 19:20:30 +02:00
|
|
|
*
|
2017-05-01 07:32:56 +02:00
|
|
|
* @return mixed Value emitted from the iterator.
|
2017-04-26 19:20:30 +02:00
|
|
|
*
|
2017-05-01 07:32:56 +02:00
|
|
|
* @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.
|
2017-04-26 19:20:30 +02:00
|
|
|
*/
|
|
|
|
public function getCurrent();
|
2016-05-24 18:47:14 +02:00
|
|
|
}
|