2019-02-06 02:00:13 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @template TReturn
|
|
|
|
* @param callable():\Generator<mixed, mixed, mixed, TReturn> $gen
|
2019-02-06 21:52:43 +01:00
|
|
|
* @return callable():Promise<TReturn>
|
2019-02-06 02:00:13 +01:00
|
|
|
*/
|
2019-02-06 21:52:43 +01:00
|
|
|
function coroutine(callable $gen) : callable {}
|
2019-02-06 02:00:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @template TReturn
|
2019-02-06 15:14:02 +01:00
|
|
|
* @param callable():(\Generator<mixed, mixed, mixed, TReturn>|TReturn) $gen
|
2019-02-06 02:00:13 +01:00
|
|
|
* @return Promise<TReturn>
|
|
|
|
*/
|
|
|
|
function call(callable $gen) : Promise {}
|
|
|
|
|
2019-02-06 15:14:02 +01:00
|
|
|
|
2019-02-06 02:00:13 +01:00
|
|
|
/**
|
|
|
|
* @template TReturn
|
|
|
|
*/
|
|
|
|
interface Promise {
|
|
|
|
/**
|
2019-05-21 00:25:11 +02:00
|
|
|
* @param callable(?\Throwable, ?TReturn):void $onResolved
|
2019-02-06 02:00:13 +01:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function onResolve(callable $onResolved);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @template TReturn
|
|
|
|
*
|
|
|
|
* @template-implements Promise<TReturn>
|
|
|
|
*/
|
|
|
|
class Success implements Promise {
|
2019-02-06 15:14:02 +01:00
|
|
|
/**
|
|
|
|
* @param TReturn|null $value
|
|
|
|
*/
|
|
|
|
public function __construct($value = null) {}
|
2019-02-06 02:00:13 +01:00
|
|
|
/**
|
2019-05-21 00:25:11 +02:00
|
|
|
* @param callable(?Throwable, ?TReturn):void $onResolved
|
2019-02-06 02:00:13 +01:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function onResolve(callable $onResolved) {}
|
|
|
|
}
|