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