Skip to content

Commit

Permalink
make Promise use template for exception
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dbu committed Jan 3, 2024
1 parent 44a67cb commit 989d667
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
9 changes: 5 additions & 4 deletions src/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @author Márk Sági-Kazár <[email protected]>
*
* @template-covariant T
* @template E of \Throwable
*/
interface Promise
{
Expand All @@ -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<V> a new resolved promise with value of the executed callback (onFulfilled / onRejected)
* @return Promise<V, E> a new resolved promise with value of the executed callback (onFulfilled / onRejected)
*
* @template V
*/
Expand All @@ -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);
}

0 comments on commit 989d667

Please sign in to comment.