Skip to content

Commit 32b4f1d

Browse files
committed
Add generics
1 parent 7a78690 commit 32b4f1d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Executor/Promise/Promise.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/**
1111
* Convenience wrapper for promises represented by Promise Adapter.
12+
* @template T
1213
*/
1314
class Promise
1415
{
@@ -30,6 +31,17 @@ public function __construct($adoptedPromise, PromiseAdapter $adapter)
3031
$this->adapter = $adapter;
3132
}
3233

34+
/**
35+
* @template TFulfilled of mixed
36+
* @template TRejected of mixed
37+
* @param (callable(T): (Promise<TFulfilled>|TFulfilled))|null $onFulfilled
38+
* @param (callable(mixed): (Promise<TRejected>|TRejected))|null $onRejected
39+
* @return Promise<(
40+
* $onFulfilled is not null
41+
* ? ($onRejected is not null ? TFulfilled|TRejected : TFulfilled)
42+
* : ($onRejected is not null ? TRejected : T)
43+
* )>
44+
*/
3345
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): Promise
3446
{
3547
return $this->adapter->then($this, $onFulfilled, $onRejected);

0 commit comments

Comments
 (0)