PluginProbe
Media Cloud Sync / 1.3.11
Media Cloud Sync v1.3.11
1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 All 34 releases
media-cloud-sync / includes / sdk / s3 / GuzzleHttp / Promise / PromiseInterface.php

PromiseInterface.php in Media Cloud Sync 1.3.11, at includes/sdk/s3/GuzzleHttp/Promise/PromiseInterface.php

81 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace Dudlewebs\WPMCS\s3\GuzzleHttp\Promise;
5
6 /**
7 * A promise represents the eventual result of an asynchronous operation.
8 *
9 * The primary way of interacting with a promise is through its then method,
10 * which registers callbacks to receive either a promise’s eventual value or
11 * the reason why the promise cannot be fulfilled.
12 *
13 * @see https://promisesaplus.com/
14 */
15 interface PromiseInterface
16 {
17 public const PENDING = 'pending';
18 public const FULFILLED = 'fulfilled';
19 public const REJECTED = 'rejected';
20 /**
21 * Appends fulfillment and rejection handlers to the promise, and returns
22 * a new promise resolving to the return value of the called handler.
23 *
24 * @param callable $onFulfilled Invoked when the promise fulfills.
25 * @param callable $onRejected Invoked when the promise is rejected.
26 */
27 public function then(?callable $onFulfilled = null, ?callable $onRejected = null) : PromiseInterface;
28 /**
29 * Appends a rejection handler callback to the promise, and returns a new
30 * promise resolving to the return value of the callback if it is called,
31 * or to its original fulfillment value if the promise is instead
32 * fulfilled.
33 *
34 * @param callable $onRejected Invoked when the promise is rejected.
35 */
36 public function otherwise(callable $onRejected) : PromiseInterface;
37 /**
38 * Get the state of the promise ("pending", "rejected", or "fulfilled").
39 *
40 * The three states can be checked against the constants defined on
41 * PromiseInterface: PENDING, FULFILLED, and REJECTED.
42 */
43 public function getState() : string;
44 /**
45 * Resolve the promise with the given value.
46 *
47 * @param mixed $value
48 *
49 * @throws \RuntimeException if the promise is already resolved.
50 */
51 public function resolve($value) : void;
52 /**
53 * Reject the promise with the given reason.
54 *
55 * @param mixed $reason
56 *
57 * @throws \RuntimeException if the promise is already resolved.
58 */
59 public function reject($reason) : void;
60 /**
61 * Cancels the promise if possible.
62 *
63 * @see https://github.com/promises-aplus/cancellation-spec/issues/7
64 */
65 public function cancel() : void;
66 /**
67 * Waits until the promise completes if possible.
68 *
69 * Pass $unwrap as true to unwrap the result of the promise, either
70 * returning the resolved value or throwing the rejected exception.
71 *
72 * If the promise cannot be waited on, then the promise will be rejected.
73 *
74 * @return mixed
75 *
76 * @throws \LogicException if the promise has no wait function or if the
77 * promise does not settle after waiting.
78 */
79 public function wait(bool $unwrap = \true);
80 }
81