$gen * * @return callable():Promise */ function coroutine(callable $gen) : callable { } /** * @template TReturn * * @param callable():(\Generator|TReturn) $gen * * @return Promise */ function call(callable $gen) : Promise { } /** * @template TReturn */ interface Promise { /** * @param callable(?\Throwable, ?TReturn):void $onResolved * * @return void */ public function onResolve(callable $onResolved); } /** * @template TReturn * * @template-implements Promise */ class Success implements Promise { /** * @param TReturn|null $value */ public function __construct($value = null) { } /** * @param callable(?Throwable, ?TReturn):void $onResolved * * @return void */ public function onResolve(callable $onResolved) { } }