File tree Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -7,39 +7,27 @@ final class Deferred implements PromisorInterface
77 private $ promise ;
88 private $ resolveCallback ;
99 private $ rejectCallback ;
10- private $ canceller ;
1110
1211 public function __construct (callable $ canceller = null )
1312 {
14- $ this ->canceller = $ canceller ;
13+ $ this ->promise = new Promise (function ($ resolve , $ reject ): void {
14+ $ this ->resolveCallback = $ resolve ;
15+ $ this ->rejectCallback = $ reject ;
16+ }, $ canceller );
1517 }
1618
1719 public function promise (): PromiseInterface
1820 {
19- if (null === $ this ->promise ) {
20- $ canceller = $ this ->canceller ;
21- $ this ->canceller = null ;
22-
23- $ this ->promise = new Promise (function ($ resolve , $ reject ): void {
24- $ this ->resolveCallback = $ resolve ;
25- $ this ->rejectCallback = $ reject ;
26- }, $ canceller );
27- }
28-
2921 return $ this ->promise ;
3022 }
3123
3224 public function resolve ($ value = null ): void
3325 {
34- $ this ->promise ();
35-
3626 ($ this ->resolveCallback )($ value );
3727 }
3828
3929 public function reject (\Throwable $ reason ): void
4030 {
41- $ this ->promise ();
42-
4331 ($ this ->rejectCallback )($ reason );
4432 }
4533}
You can’t perform that action at this time.
0 commit comments