File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Expand file tree Collapse file tree 3 files changed +17
-5
lines changed 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+ * @implements Promise<T>
912 */
1013final class FulfilledPromise implements Promise
1114{
1215 /**
13- * @var mixed
16+ * @var T
1417 */
1518 private $ result ;
1619
20+ /**
21+ * @param T $result
22+ */
1723 public function __construct ($ result )
1824 {
1925 $ 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,11 @@ 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
4143 *
42- * @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected)
44+ * @return Promise<V> a new resolved promise with value of the executed callback (onFulfilled / onRejected)
45+ * @template V
4346 */
4447 public function then (callable $ onFulfilled = null , callable $ onRejected = null );
4548
@@ -61,7 +64,7 @@ public function getState();
6164 *
6265 * @param bool $unwrap Whether to return resolved value / throw reason or not
6366 *
64- * @return mixed Resolved value, null if $unwrap is set to false
67+ * @return T Resolved value, null if $unwrap is set to false
6568 *
6669 * @throws \Exception the rejection reason if $unwrap is set to true and the request failed
6770 */
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+ * @implements Promise<T>
912 */
1013final class RejectedPromise implements Promise
1114{
You can’t perform that action at this time.
0 commit comments