Skip to content

Commit b06af4c

Browse files
committed
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.
1 parent 44a67cb commit b06af4c

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

.github/workflows/tests.yml

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ jobs:
6969
- name: Checkout code
7070
uses: actions/checkout@v3
7171

72+
- name: Remove phpspec
73+
run: composer remove phpspec/phpspec
74+
7275
- name: PHPStan
7376
uses: OskarStark/[email protected]
7477
env:

CHANGELOG.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# Change Log
22

3-
## 1.2.1
3+
## 1.2.2 - unreleased
44

5-
### Added - 2023-11-08
5+
### Fixed
6+
7+
- Changed `Promise` to use a template for the exception class that is allowed.
8+
9+
## 1.2.1 - 2023-11-08
10+
11+
### Fixed
612

713
- Fixed PHPDoc for `wait()` and `then()`'s `onRejected` callable
814

src/Promise.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* @author Márk Sági-Kazár <[email protected]>
1515
*
1616
* @template-covariant T
17+
*
18+
* @template E of \Throwable
1719
*/
1820
interface Promise
1921
{
@@ -38,10 +40,10 @@ interface Promise
3840
* If you do not care about one of the cases, you can set the corresponding callable to null
3941
* The callback will be called when the value arrived and never more than once.
4042
*
41-
* @param callable(T): V|null $onFulfilled called when a response will be available
42-
* @param callable(\Throwable): V|null $onRejected called when an exception occurs
43+
* @param callable(T): V|null $onFulfilled called when a response will be available
44+
* @param callable(E): V|null $onRejected called when an exception occurs
4345
*
44-
* @return Promise<V> a new resolved promise with value of the executed callback (onFulfilled / onRejected)
46+
* @return Promise<V, E> a new resolved promise with value of the executed callback (onFulfilled / onRejected)
4547
*
4648
* @template V
4749
*/
@@ -67,7 +69,7 @@ public function getState();
6769
*
6870
* @return ($unwrap is true ? T : null) Resolved value, null if $unwrap is set to false
6971
*
70-
* @throws \Exception the rejection reason if $unwrap is set to true and the request failed
72+
* @throws E the rejection reason if $unwrap is set to true and the request failed
7173
*/
7274
public function wait($unwrap = true);
7375
}

0 commit comments

Comments
 (0)