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 | 110 | public function __construct(LoopInterface $loop) |
|
61 | |||
62 | /** |
||
63 | * Allow to apply callable when the promise resolve. |
||
64 | * |
||
65 | * @param callable|null $onFulfilled |
||
66 | * @param callable|null $onRejected |
||
67 | * |
||
68 | * @return Promise |
||
69 | */ |
||
70 | 57 | public function then(callable $onFulfilled = null, callable $onRejected = null) |
|
110 | |||
111 | /** |
||
112 | * Resolve this promise. |
||
113 | * |
||
114 | * @param ResponseInterface $response |
||
115 | * |
||
116 | * @internal |
||
117 | */ |
||
118 | 107 | public function resolve(ResponseInterface $response) |
|
128 | |||
129 | 107 | private function doResolve(ResponseInterface $response) |
|
130 | { |
||
131 | 107 | $onFulfilled = $this->onFulfilled; |
|
132 | |||
133 | 107 | if (null !== $onFulfilled) { |
|
134 | 55 | $onFulfilled($response); |
|
135 | 55 | } |
|
136 | 107 | } |
|
137 | |||
138 | /** |
||
139 | * Reject this promise. |
||
140 | * |
||
141 | * @param Exception $exception |
||
142 | * |
||
143 | * @internal |
||
144 | */ |
||
145 | 3 | public function reject(Exception $exception) |
|
155 | |||
156 | 3 | private function doReject(Exception $exception) |
|
164 | |||
165 | /** |
||
166 | * {@inheritdoc} |
||
167 | */ |
||
168 | 110 | public function getState() |
|
172 | |||
173 | /** |
||
174 | * {@inheritdoc} |
||
175 | */ |
||
176 | 110 | public function wait($unwrap = true) |
|
194 | } |
||
195 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.