File tree Expand file tree Collapse file tree 4 files changed +24
-5
lines changed Expand file tree Collapse file tree 4 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 1
1
# Change Log
2
2
3
+ ### Added
4
+
5
+ - Generic annotations
6
+
3
7
## 1.1.0 - 2020-07-07
4
8
5
9
### Added
Original file line number Diff line number Diff line change 6
6
* A promise already fulfilled.
7
7
*
8
8
* @author Joel Wurtz <joel.wurtz@gmail.com>
9
+ *
10
+ * @template-covariant T
11
+ *
12
+ * @implements Promise<T>
9
13
*/
10
14
final class FulfilledPromise implements Promise
11
15
{
12
16
/**
13
- * @var mixed
17
+ * @var T
14
18
*/
15
19
private $ result ;
16
20
21
+ /**
22
+ * @param T $result
23
+ */
17
24
public function __construct ($ result )
18
25
{
19
26
$ this ->result = $ result ;
Original file line number Diff line number Diff line change 12
12
*
13
13
* @author Joel Wurtz <joel.wurtz@gmail.com>
14
14
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
15
+ *
16
+ * @template-covariant T
15
17
*/
16
18
interface Promise
17
19
{
@@ -36,10 +38,12 @@ interface Promise
36
38
* If you do not care about one of the cases, you can set the corresponding callable to null
37
39
* The callback will be called when the value arrived and never more than once.
38
40
*
39
- * @param callable|null $onFulfilled called when a response will be available
40
- * @param callable|null $onRejected called when an exception occurs
41
+ * @param callable(T): V|null $onFulfilled called when a response will be available
42
+ * @param callable(\Exception): V|null $onRejected called when an exception occurs
43
+ *
44
+ * @return Promise<V> a new resolved promise with value of the executed callback (onFulfilled / onRejected)
41
45
*
42
- * @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected)
46
+ * @template V
43
47
*/
44
48
public function then (callable $ onFulfilled = null , callable $ onRejected = null );
45
49
@@ -61,7 +65,7 @@ public function getState();
61
65
*
62
66
* @param bool $unwrap Whether to return resolved value / throw reason or not
63
67
*
64
- * @return mixed Resolved value, null if $unwrap is set to false
68
+ * @return T Resolved value, null if $unwrap is set to false
65
69
*
66
70
* @throws \Exception the rejection reason if $unwrap is set to true and the request failed
67
71
*/
Original file line number Diff line number Diff line change 6
6
* A rejected promise.
7
7
*
8
8
* @author Joel Wurtz <joel.wurtz@gmail.com>
9
+ *
10
+ * @template-covariant T
11
+ *
12
+ * @implements Promise<T>
9
13
*/
10
14
final class RejectedPromise implements Promise
11
15
{
You can’t perform that action at this time.
0 commit comments