77use Psr \Http \Message \ResponseInterface ;
88
99/**
10- * A deferred allow to return a promise which has not been resolved yet
10+ * A deferred allow to return a promise which has not been resolved yet.
1111 */
1212class Deferred implements Promise
1313{
@@ -36,9 +36,9 @@ public function __construct(callable $waitCallback)
3636 */
3737 public function then (callable $ onFulfilled = null , callable $ onRejected = null )
3838 {
39- $ deferred = new Deferred ($ this ->waitCallback );
39+ $ deferred = new self ($ this ->waitCallback );
4040
41- $ this ->onFulfilledCallbacks [] = function (ResponseInterface $ response ) use ($ onFulfilled , $ deferred ) {
41+ $ this ->onFulfilledCallbacks [] = function (ResponseInterface $ response ) use ($ onFulfilled , $ deferred ) {
4242 try {
4343 if (null !== $ onFulfilled ) {
4444 $ response = $ onFulfilled ($ response );
@@ -49,7 +49,7 @@ public function then(callable $onFulfilled = null, callable $onRejected = null)
4949 }
5050 };
5151
52- $ this ->onRejectedCallbacks [] = function (Exception $ exception ) use ($ onRejected , $ deferred ) {
52+ $ this ->onRejectedCallbacks [] = function (Exception $ exception ) use ($ onRejected , $ deferred ) {
5353 try {
5454 if (null !== $ onRejected ) {
5555 $ response = $ onRejected ($ exception );
@@ -75,11 +75,11 @@ public function getState()
7575 }
7676
7777 /**
78- * Resolve this deferred with a Response
78+ * Resolve this deferred with a Response.
7979 */
8080 public function resolve (ResponseInterface $ response )
8181 {
82- if ($ this -> state !== self :: PENDING ) {
82+ if (self :: PENDING !== $ this -> state ) {
8383 return ;
8484 }
8585
@@ -92,11 +92,11 @@ public function resolve(ResponseInterface $response)
9292 }
9393
9494 /**
95- * Reject this deferred with an Exception
95+ * Reject this deferred with an Exception.
9696 */
9797 public function reject (Exception $ exception )
9898 {
99- if ($ this -> state !== self :: PENDING ) {
99+ if (self :: PENDING !== $ this -> state ) {
100100 return ;
101101 }
102102
@@ -113,7 +113,7 @@ public function reject(Exception $exception)
113113 */
114114 public function wait ($ unwrap = true )
115115 {
116- if ($ this -> state === self :: PENDING ) {
116+ if (self :: PENDING === $ this -> state ) {
117117 $ callback = $ this ->waitCallback ;
118118 $ callback ();
119119 }
@@ -122,7 +122,7 @@ public function wait($unwrap = true)
122122 return ;
123123 }
124124
125- if ($ this -> state === self :: FULFILLED ) {
125+ if (self :: FULFILLED === $ this -> state ) {
126126 return $ this ->value ;
127127 }
128128
0 commit comments