7
7
use Psr \Http \Message \ResponseInterface ;
8
8
9
9
/**
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.
11
11
*/
12
12
class Deferred implements Promise
13
13
{
@@ -36,9 +36,9 @@ public function __construct(callable $waitCallback)
36
36
*/
37
37
public function then (callable $ onFulfilled = null , callable $ onRejected = null )
38
38
{
39
- $ deferred = new Deferred ($ this ->waitCallback );
39
+ $ deferred = new self ($ this ->waitCallback );
40
40
41
- $ this ->onFulfilledCallbacks [] = function (ResponseInterface $ response ) use ($ onFulfilled , $ deferred ) {
41
+ $ this ->onFulfilledCallbacks [] = function (ResponseInterface $ response ) use ($ onFulfilled , $ deferred ) {
42
42
try {
43
43
if (null !== $ onFulfilled ) {
44
44
$ response = $ onFulfilled ($ response );
@@ -49,7 +49,7 @@ public function then(callable $onFulfilled = null, callable $onRejected = null)
49
49
}
50
50
};
51
51
52
- $ this ->onRejectedCallbacks [] = function (Exception $ exception ) use ($ onRejected , $ deferred ) {
52
+ $ this ->onRejectedCallbacks [] = function (Exception $ exception ) use ($ onRejected , $ deferred ) {
53
53
try {
54
54
if (null !== $ onRejected ) {
55
55
$ response = $ onRejected ($ exception );
@@ -75,11 +75,11 @@ public function getState()
75
75
}
76
76
77
77
/**
78
- * Resolve this deferred with a Response
78
+ * Resolve this deferred with a Response.
79
79
*/
80
80
public function resolve (ResponseInterface $ response )
81
81
{
82
- if ($ this -> state !== self :: PENDING ) {
82
+ if (self :: PENDING !== $ this -> state ) {
83
83
return ;
84
84
}
85
85
@@ -92,11 +92,11 @@ public function resolve(ResponseInterface $response)
92
92
}
93
93
94
94
/**
95
- * Reject this deferred with an Exception
95
+ * Reject this deferred with an Exception.
96
96
*/
97
97
public function reject (Exception $ exception )
98
98
{
99
- if ($ this -> state !== self :: PENDING ) {
99
+ if (self :: PENDING !== $ this -> state ) {
100
100
return ;
101
101
}
102
102
@@ -113,7 +113,7 @@ public function reject(Exception $exception)
113
113
*/
114
114
public function wait ($ unwrap = true )
115
115
{
116
- if ($ this -> state === self :: PENDING ) {
116
+ if (self :: PENDING === $ this -> state ) {
117
117
$ callback = $ this ->waitCallback ;
118
118
$ callback ();
119
119
}
@@ -122,7 +122,7 @@ public function wait($unwrap = true)
122
122
return ;
123
123
}
124
124
125
- if ($ this -> state === self :: FULFILLED ) {
125
+ if (self :: FULFILLED === $ this -> state ) {
126
126
return $ this ->value ;
127
127
}
128
128
0 commit comments