1 | <?php |
||
17 | final class Promise implements HttpPromise |
||
18 | { |
||
19 | /** |
||
20 | * Promise status. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | private $state = HttpPromise::PENDING; |
||
25 | |||
26 | /** |
||
27 | * PSR7 received response. |
||
28 | * |
||
29 | * @var ResponseInterface |
||
30 | */ |
||
31 | private $response; |
||
32 | |||
33 | /** |
||
34 | * Execution error. |
||
35 | * |
||
36 | * @var Exception |
||
37 | */ |
||
38 | private $exception; |
||
39 | |||
40 | /** |
||
41 | * @var callable|null |
||
42 | */ |
||
43 | private $onFulfilled; |
||
44 | |||
45 | /** |
||
46 | * @var callable|null |
||
47 | */ |
||
48 | private $onRejected; |
||
49 | |||
50 | /** |
||
51 | * React Event Loop used for synchronous processing. |
||
52 | * |
||
53 | * @var LoopInterface |
||
54 | */ |
||
55 | private $loop; |
||
56 | |||
57 | public function __construct(LoopInterface $loop) |
||
61 | |||
62 | 105 | /** |
|
63 | 105 | * Allow to apply callable when the promise resolve. |
|
64 | 108 | * |
|
65 | * @param callable|null $onFulfilled |
||
66 | 3 | * @param callable|null $onRejected |
|
67 | 3 | * |
|
68 | 3 | * @return Promise |
|
69 | 108 | */ |
|
70 | 108 | public function then(callable $onFulfilled = null, callable $onRejected = null) |
|
108 | |||
109 | /** |
||
110 | * Resolve this promise. |
||
111 | 108 | * |
|
112 | * @param ResponseInterface $response |
||
113 | 108 | * |
|
114 | * @internal |
||
115 | 108 | */ |
|
116 | public function resolve(ResponseInterface $response) |
||
126 | 108 | ||
127 | 108 | private function doResolve(ResponseInterface $response) |
|
135 | 104 | ||
136 | /** |
||
137 | 3 | * Reject this promise. |
|
138 | * |
||
139 | * @param Exception $exception |
||
140 | * |
||
141 | * @internal |
||
142 | */ |
||
143 | public function reject(Exception $exception) |
||
153 | |||
154 | private function doReject(Exception $exception) |
||
162 | |||
163 | /** |
||
164 | * {@inheritdoc} |
||
165 | */ |
||
166 | public function getState() |
||
170 | |||
171 | /** |
||
172 | * {@inheritdoc} |
||
173 | */ |
||
174 | public function wait($unwrap = true) |
||
188 | } |
||
189 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.