1414final class Deferred implements Promise
1515{
1616 private $ value ;
17-
1817 private $ failure ;
19-
2018 private $ state ;
21-
2219 private $ waitCallback ;
23-
2420 private $ onFulfilledCallbacks ;
25-
2621 private $ onRejectedCallbacks ;
2722
2823 public function __construct (callable $ waitCallback )
@@ -81,12 +76,12 @@ public function getState(): string
8176 */
8277 public function resolve (ResponseInterface $ response ): void
8378 {
84- if (self ::PENDING !== $ this ->state ) {
79+ if (Promise ::PENDING !== $ this ->state ) {
8580 return ;
8681 }
8782
8883 $ this ->value = $ response ;
89- $ this ->state = self ::FULFILLED ;
84+ $ this ->state = Promise ::FULFILLED ;
9085
9186 foreach ($ this ->onFulfilledCallbacks as $ onFulfilledCallback ) {
9287 $ onFulfilledCallback ($ response );
@@ -98,12 +93,12 @@ public function resolve(ResponseInterface $response): void
9893 */
9994 public function reject (Exception $ exception ): void
10095 {
101- if (self ::PENDING !== $ this ->state ) {
96+ if (Promise ::PENDING !== $ this ->state ) {
10297 return ;
10398 }
10499
105100 $ this ->failure = $ exception ;
106- $ this ->state = self ::REJECTED ;
101+ $ this ->state = Promise ::REJECTED ;
107102
108103 foreach ($ this ->onRejectedCallbacks as $ onRejectedCallback ) {
109104 $ onRejectedCallback ($ exception );
@@ -115,16 +110,16 @@ public function reject(Exception $exception): void
115110 */
116111 public function wait ($ unwrap = true )
117112 {
118- if (self ::PENDING === $ this ->state ) {
113+ if (Promise ::PENDING === $ this ->state ) {
119114 $ callback = $ this ->waitCallback ;
120115 $ callback ();
121116 }
122117
123118 if (!$ unwrap ) {
124- return ;
119+ return null ;
125120 }
126121
127- if (self ::FULFILLED === $ this ->state ) {
122+ if (Promise ::FULFILLED === $ this ->state ) {
128123 return $ this ->value ;
129124 }
130125
0 commit comments