From 32b4f1d728a55d76970971826d872bc8f7987598 Mon Sep 17 00:00:00 2001 From: Warxcell Date: Tue, 29 Nov 2022 17:52:45 +0200 Subject: [PATCH] Add generics --- src/Executor/Promise/Promise.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Executor/Promise/Promise.php b/src/Executor/Promise/Promise.php index b0dbb0c7a..f5026a4ae 100644 --- a/src/Executor/Promise/Promise.php +++ b/src/Executor/Promise/Promise.php @@ -9,6 +9,7 @@ /** * Convenience wrapper for promises represented by Promise Adapter. + * @template T */ class Promise { @@ -30,6 +31,17 @@ public function __construct($adoptedPromise, PromiseAdapter $adapter) $this->adapter = $adapter; } + /** + * @template TFulfilled of mixed + * @template TRejected of mixed + * @param (callable(T): (Promise|TFulfilled))|null $onFulfilled + * @param (callable(mixed): (Promise|TRejected))|null $onRejected + * @return Promise<( + * $onFulfilled is not null + * ? ($onRejected is not null ? TFulfilled|TRejected : TFulfilled) + * : ($onRejected is not null ? TRejected : T) + * )> + */ public function then(?callable $onFulfilled = null, ?callable $onRejected = null): Promise { return $this->adapter->then($this, $onFulfilled, $onRejected);