1
+ <?php
2
+ declare (strict_types=1 );
3
+
4
+ namespace Microsoft \Kiota \Http ;
5
+
6
+ /**
7
+ * Promise represents a value that may not be available yet, but will be resolved at some point in future.
8
+ * It acts like a proxy to the actual value.
9
+ *
10
+ * This interface is an extension of the promises/a+ specification.
11
+ *
12
+ * @see https://promisesaplus.com/
13
+ *
14
+ * @author Joel Wurtz <[email protected] >
15
+ * @author Márk Sági-Kazár <[email protected] >
16
+ *
17
+ * @template-covariant T
18
+ */
19
+ interface Promise extends \Http \Promise \Promise
20
+ {
21
+
22
+ /**
23
+ * Adds behavior for when the promise is resolved or rejected (response will be available, or error happens).
24
+ *
25
+ * If you do not care about one of the cases, you can set the corresponding callable to null
26
+ * The callback will be called when the value arrived and never more than once.
27
+ *
28
+ * @param callable(T): V|null $onFulfilled called when a response will be available
29
+ * @param callable(\Throwable): V|null $onRejected called when an exception occurs
30
+ *
31
+ * @return Promise<V> a new resolved promise with value of the executed callback (onFulfilled / onRejected)
32
+ *
33
+ * @template V
34
+ */
35
+ public function then (?callable $ onFulfilled = null , ?callable $ onRejected = null );
36
+
37
+ /**
38
+ * Wait for the promise to be fulfilled or rejected.
39
+ *
40
+ * When this method returns, the request has been resolved and if callables have been
41
+ * specified, the appropriate one has terminated.
42
+ *
43
+ * When $unwrap is true (the default), the response is returned, or the exception thrown
44
+ * on failure. Otherwise, nothing is returned or thrown.
45
+ *
46
+ * @param bool $unwrap Whether to return resolved value / throw reason or not
47
+ *
48
+ * @return ($unwrap is true ? T : null) Resolved value, null if $unwrap is set to false
49
+ *
50
+ * @throws \Exception the rejection reason if $unwrap is set to true and the request failed
51
+ */
52
+ public function wait ($ unwrap = true );
53
+
54
+ }
0 commit comments