5
5
namespace Sabre \Event ;
6
6
7
7
use Exception ;
8
- use Throwable ;
9
8
10
9
/**
11
10
* An implementation of the Promise pattern.
@@ -30,17 +29,17 @@ class Promise
30
29
/**
31
30
* The asynchronous operation is pending.
32
31
*/
33
- const PENDING = 0 ;
32
+ public const PENDING = 0 ;
34
33
35
34
/**
36
35
* The asynchronous operation has completed, and has a result.
37
36
*/
38
- const FULFILLED = 1 ;
37
+ public const FULFILLED = 1 ;
39
38
40
39
/**
41
40
* The asynchronous operation has completed with an error.
42
41
*/
43
- const REJECTED = 2 ;
42
+ public const REJECTED = 2 ;
44
43
45
44
/**
46
45
* The current state of this promise.
@@ -128,8 +127,6 @@ public function otherwise(callable $onRejected): Promise
128
127
129
128
/**
130
129
* Marks this promise as fulfilled and sets its return value.
131
- *
132
- * @param mixed $value
133
130
*/
134
131
public function fulfill ($ value = null )
135
132
{
@@ -146,7 +143,7 @@ public function fulfill($value = null)
146
143
/**
147
144
* Marks this promise as rejected, and set its rejection reason.
148
145
*/
149
- public function reject (Throwable $ reason )
146
+ public function reject (\ Throwable $ reason )
150
147
{
151
148
if (self ::PENDING !== $ this ->state ) {
152
149
throw new PromiseAlreadyResolvedException ('This promise is already resolved, and you \'re not allowed to resolve a promise more than once ' );
@@ -169,7 +166,6 @@ public function reject(Throwable $reason)
169
166
* one. In PHP it might be useful to call this on the last promise in a
170
167
* chain.
171
168
*
172
- * @return mixed
173
169
* @psalm-return TReturn
174
170
*/
175
171
public function wait ()
@@ -208,10 +204,8 @@ public function wait()
208
204
*
209
205
* If the promise was fulfilled, this will be the result value. If the
210
206
* promise was rejected, this property hold the rejection reason.
211
- *
212
- * @var mixed
213
207
*/
214
- protected $ value = null ;
208
+ protected $ value ;
215
209
216
210
/**
217
211
* This method is used to call either an onFulfilled or onRejected callback.
@@ -242,7 +236,7 @@ private function invokeCallback(Promise $subPromise, ?callable $callBack = null)
242
236
// immediately fulfill the chained promise.
243
237
$ subPromise ->fulfill ($ result );
244
238
}
245
- } catch (Throwable $ e ) {
239
+ } catch (\ Throwable $ e ) {
246
240
// If the event handler threw an exception, we need to make sure that
247
241
// the chained promise is rejected as well.
248
242
$ subPromise ->reject ($ e );
0 commit comments