From 989d6673023166c9c85dcf89d8fe45a8c996093d Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 3 Jan 2024 18:47:59 +0100 Subject: [PATCH] make Promise use template for exception in httplug, we have documentation text that formulates that only specific exceptions may be used for the callback. the change in 1.2.0 to allow any Throwable was incorrect. --- CHANGELOG.md | 10 ++++++++-- src/Promise.php | 9 +++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a10d4e9..cdbf39c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,14 @@ # Change Log -## 1.2.1 +## 1.2.2 - unreleased -### Added - 2023-11-08 +### Fixed + +- Changed `Promise` to use a template for the exception class that is allowed. + +## 1.2.1 - 2023-11-08 + +### Fixed - Fixed PHPDoc for `wait()` and `then()`'s `onRejected` callable diff --git a/src/Promise.php b/src/Promise.php index 81434ae..cf36c5b 100644 --- a/src/Promise.php +++ b/src/Promise.php @@ -14,6 +14,7 @@ * @author Márk Sági-Kazár * * @template-covariant T + * @template E of \Throwable */ interface Promise { @@ -38,10 +39,10 @@ interface Promise * If you do not care about one of the cases, you can set the corresponding callable to null * The callback will be called when the value arrived and never more than once. * - * @param callable(T): V|null $onFulfilled called when a response will be available - * @param callable(\Throwable): V|null $onRejected called when an exception occurs + * @param callable(T): V|null $onFulfilled called when a response will be available + * @param callable(E): V|null $onRejected called when an exception occurs * - * @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected) + * @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected) * * @template V */ @@ -67,7 +68,7 @@ public function getState(); * * @return ($unwrap is true ? T : null) Resolved value, null if $unwrap is set to false * - * @throws \Exception the rejection reason if $unwrap is set to true and the request failed + * @throws E the rejection reason if $unwrap is set to true and the request failed */ public function wait($unwrap = true); }