1414 *
1515 * @internal
1616 */
17- class Promise implements HttpPromise
17+ final class Promise implements HttpPromise
1818{
1919 /**
2020 * Promise status.
@@ -69,7 +69,7 @@ public function __construct(LoopInterface $loop)
6969 */
7070 public function then (callable $ onFulfilled = null , callable $ onRejected = null )
7171 {
72- $ newPromise = new Promise ($ this ->loop );
72+ $ newPromise = new self ($ this ->loop );
7373
7474 $ onFulfilled = $ onFulfilled !== null ? $ onFulfilled : function (ResponseInterface $ response ) {
7575 return $ response ;
@@ -79,15 +79,15 @@ public function then(callable $onFulfilled = null, callable $onRejected = null)
7979 throw $ exception ;
8080 };
8181
82- $ this ->onFulfilled = function (ResponseInterface $ response ) use ($ onFulfilled , $ newPromise ) {
82+ $ this ->onFulfilled = function (ResponseInterface $ response ) use ($ onFulfilled , $ newPromise ) {
8383 try {
8484 $ newPromise ->resolve ($ onFulfilled ($ response ));
8585 } catch (Exception $ exception ) {
8686 $ newPromise ->reject ($ exception );
8787 }
8888 };
8989
90- $ this ->onRejected = function (Exception $ exception ) use ($ onRejected , $ newPromise ) {
90+ $ this ->onRejected = function (Exception $ exception ) use ($ onRejected , $ newPromise ) {
9191 try {
9292 $ newPromise ->resolve ($ onRejected ($ exception ));
9393 } catch (Exception $ exception ) {
@@ -99,7 +99,7 @@ public function then(callable $onFulfilled = null, callable $onRejected = null)
9999 }
100100
101101 /**
102- * Resolve this promise
102+ * Resolve this promise.
103103 *
104104 * @param ResponseInterface $response
105105 *
@@ -121,7 +121,7 @@ public function resolve(ResponseInterface $response)
121121 }
122122
123123 /**
124- * Reject this promise
124+ * Reject this promise.
125125 *
126126 * @param Exception $exception
127127 *
0 commit comments