Skip to content

Commit

Permalink
Add generics
Browse files Browse the repository at this point in the history
  • Loading branch information
Warxcell committed Nov 29, 2022
1 parent 7a78690 commit 32b4f1d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Executor/Promise/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/**
* Convenience wrapper for promises represented by Promise Adapter.
* @template T
*/
class Promise
{
Expand All @@ -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>|TFulfilled))|null $onFulfilled
* @param (callable(mixed): (Promise<TRejected>|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);
Expand Down

0 comments on commit 32b4f1d

Please sign in to comment.