@@ 41-51 (lines=11) @@ | ||
38 | * @return PromiseInterface |
|
39 | * @rejects Error|Exception|string|null |
|
40 | */ |
|
41 | public static function doReject($promiseOrValue = null) |
|
42 | { |
|
43 | if (!$promiseOrValue instanceof PromiseInterface) |
|
44 | { |
|
45 | return new PromiseRejected($promiseOrValue); |
|
46 | } |
|
47 | ||
48 | return self::doResolve($promiseOrValue)->then(function($value) { |
|
49 | return new PromiseRejected($value); |
|
50 | }); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * Cancel Promise or value. |
|
@@ 60-76 (lines=17) @@ | ||
57 | * @return PromiseInterface |
|
58 | * @cancels Error|Exception|string|null |
|
59 | */ |
|
60 | public static function doCancel($promiseOrValue = null) |
|
61 | { |
|
62 | if (!$promiseOrValue instanceof PromiseInterface) |
|
63 | { |
|
64 | return new PromiseCancelled($promiseOrValue); |
|
65 | } |
|
66 | ||
67 | return self::doResolve($promiseOrValue) |
|
68 | ->then( |
|
69 | function($value) { |
|
70 | return new PromiseCancelled($value); |
|
71 | }, |
|
72 | function($value) { |
|
73 | return new PromiseCancelled($value); |
|
74 | } |
|
75 | ); |
|
76 | } |
|
77 | ||
78 | /** |
|
79 | * Return Promise that will resolve only once all the items in $promisesOrValues have resolved. |