14
14
*
15
15
* @internal
16
16
*/
17
- class Promise implements HttpPromise
17
+ final class Promise implements HttpPromise
18
18
{
19
19
/**
20
20
* Promise status.
@@ -69,7 +69,7 @@ public function __construct(LoopInterface $loop)
69
69
*/
70
70
public function then (callable $ onFulfilled = null , callable $ onRejected = null )
71
71
{
72
- $ newPromise = new Promise ($ this ->loop );
72
+ $ newPromise = new self ($ this ->loop );
73
73
74
74
$ onFulfilled = $ onFulfilled !== null ? $ onFulfilled : function (ResponseInterface $ response ) {
75
75
return $ response ;
@@ -79,15 +79,15 @@ public function then(callable $onFulfilled = null, callable $onRejected = null)
79
79
throw $ exception ;
80
80
};
81
81
82
- $ this ->onFulfilled = function (ResponseInterface $ response ) use ($ onFulfilled , $ newPromise ) {
82
+ $ this ->onFulfilled = function (ResponseInterface $ response ) use ($ onFulfilled , $ newPromise ) {
83
83
try {
84
84
$ newPromise ->resolve ($ onFulfilled ($ response ));
85
85
} catch (Exception $ exception ) {
86
86
$ newPromise ->reject ($ exception );
87
87
}
88
88
};
89
89
90
- $ this ->onRejected = function (Exception $ exception ) use ($ onRejected , $ newPromise ) {
90
+ $ this ->onRejected = function (Exception $ exception ) use ($ onRejected , $ newPromise ) {
91
91
try {
92
92
$ newPromise ->resolve ($ onRejected ($ exception ));
93
93
} catch (Exception $ exception ) {
@@ -99,7 +99,7 @@ public function then(callable $onFulfilled = null, callable $onRejected = null)
99
99
}
100
100
101
101
/**
102
- * Resolve this promise
102
+ * Resolve this promise.
103
103
*
104
104
* @param ResponseInterface $response
105
105
*
@@ -121,7 +121,7 @@ public function resolve(ResponseInterface $response)
121
121
}
122
122
123
123
/**
124
- * Reject this promise
124
+ * Reject this promise.
125
125
*
126
126
* @param Exception $exception
127
127
*
0 commit comments