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 11# Change Log
22
3+ ### Added
4+
5+ - Generic annotations
6+
37## 1.1.0 - 2020-07-07
48
59### Added
Original file line number Diff line number Diff line change 66 * A promise already fulfilled.
77 *
88 * @author Joel Wurtz <joel.wurtz@gmail.com>
9+ *
10+ * @template-covariant T
11+ *
12+ * @implements Promise<T>
913 */
1014final class FulfilledPromise implements Promise
1115{
1216 /**
13- * @var mixed
17+ * @var T
1418 */
1519 private $ result ;
1620
21+ /**
22+ * @param T $result
23+ */
1724 public function __construct ($ result )
1825 {
1926 $ this ->result = $ result ;
Original file line number Diff line number Diff line change 1212 *
1313 * @author Joel Wurtz <joel.wurtz@gmail.com>
1414 * @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
15+ *
16+ * @template-covariant T
1517 */
1618interface Promise
1719{
@@ -36,10 +38,12 @@ interface Promise
3638 * If you do not care about one of the cases, you can set the corresponding callable to null
3739 * The callback will be called when the value arrived and never more than once.
3840 *
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)
4145 *
42- * @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected)
46+ * @template V
4347 */
4448 public function then (callable $ onFulfilled = null , callable $ onRejected = null );
4549
@@ -61,7 +65,7 @@ public function getState();
6165 *
6266 * @param bool $unwrap Whether to return resolved value / throw reason or not
6367 *
64- * @return mixed Resolved value, null if $unwrap is set to false
68+ * @return T Resolved value, null if $unwrap is set to false
6569 *
6670 * @throws \Exception the rejection reason if $unwrap is set to true and the request failed
6771 */
Original file line number Diff line number Diff line change 66 * A rejected promise.
77 *
88 * @author Joel Wurtz <joel.wurtz@gmail.com>
9+ *
10+ * @template-covariant T
11+ *
12+ * @implements Promise<T>
913 */
1014final class RejectedPromise implements Promise
1115{
You can’t perform that action at this time.
0 commit comments