diff --git a/src/PromiseInterface.php b/src/PromiseInterface.php index 3f854b94..d2ab2d84 100644 --- a/src/PromiseInterface.php +++ b/src/PromiseInterface.php @@ -2,6 +2,7 @@ namespace React\Promise; +/** @psalm-template T */ interface PromiseInterface { /** @@ -28,9 +29,12 @@ interface PromiseInterface * 2. `$onFulfilled` and `$onRejected` will never be called more * than once. * - * @param callable|null $onFulfilled - * @param callable|null $onRejected - * @return PromiseInterface + * @psalm-template TResolved + * + * @psalm-param callable(T):(PromiseInterface|TResolved)|null $onFulfilled + * @psalm-param callable(mixed):(PromiseInterface|mixed)|null $onRejected + * + * @return PromiseInterface */ public function then(?callable $onFulfilled = null, ?callable $onRejected = null): PromiseInterface; @@ -44,7 +48,7 @@ public function then(?callable $onFulfilled = null, ?callable $onRejected = null * Since the purpose of `done()` is consumption rather than transformation, * `done()` always returns `null`. * - * @param callable|null $onFulfilled + * @param callable(mixed):TResolve|null $onFulfilled * @param callable|null $onRejected * @return void */ @@ -60,8 +64,9 @@ public function done(callable $onFulfilled = null, callable $onRejected = null): * Additionally, you can type hint the `$reason` argument of `$onRejected` to catch * only specific errors. * - * @param callable $onRejected - * @return PromiseInterface + * @param callable(mixed):(PromiseInterface|mixed) $onRejected + * + * @return PromiseInterface */ public function otherwise(callable $onRejected): PromiseInterface; @@ -108,7 +113,7 @@ public function otherwise(callable $onRejected): PromiseInterface; * ``` * * @param callable $onFulfilledOrRejected - * @return PromiseInterface + * @return PromiseInterface */ public function always(callable $onFulfilledOrRejected): PromiseInterface; diff --git a/src/PromisorInterface.php b/src/PromisorInterface.php index 87e999c1..fdfd18ed 100644 --- a/src/PromisorInterface.php +++ b/src/PromisorInterface.php @@ -2,12 +2,13 @@ namespace React\Promise; +/** @psalm-template T */ interface PromisorInterface { /** * Returns the promise of the deferred. * - * @return PromiseInterface + * @return PromiseInterface */ public function promise(): PromiseInterface; }