2
2
3
3
namespace React \Async ;
4
4
5
- use React \EventLoop \Loop ;
6
- use React \Promise \CancellablePromiseInterface ;
7
5
use React \Promise \Deferred ;
8
6
use React \Promise \Promise ;
9
7
use React \Promise \PromiseInterface ;
@@ -199,7 +197,7 @@ function async(callable $function): callable
199
197
}, function () use (&$ fiber ): void {
200
198
FiberMap::cancel ($ fiber );
201
199
$ promise = FiberMap::getPromise ($ fiber );
202
- if ($ promise instanceof CancellablePromiseInterface ) {
200
+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
203
201
$ promise ->cancel ();
204
202
}
205
203
});
@@ -535,7 +533,7 @@ function parallel(iterable $tasks): PromiseInterface
535
533
$ pending = [];
536
534
$ deferred = new Deferred (function () use (&$ pending ) {
537
535
foreach ($ pending as $ promise ) {
538
- if ($ promise instanceof CancellablePromiseInterface ) {
536
+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
539
537
$ promise ->cancel ();
540
538
}
541
539
}
@@ -549,7 +547,7 @@ function parallel(iterable $tasks): PromiseInterface
549
547
$ deferred ->reject ($ error );
550
548
551
549
foreach ($ pending as $ promise ) {
552
- if ($ promise instanceof CancellablePromiseInterface ) {
550
+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
553
551
$ promise ->cancel ();
554
552
}
555
553
}
@@ -593,7 +591,7 @@ function series(iterable $tasks): PromiseInterface
593
591
{
594
592
$ pending = null ;
595
593
$ deferred = new Deferred (function () use (&$ pending ) {
596
- if ($ pending instanceof CancellablePromiseInterface ) {
594
+ if ($ pending instanceof PromiseInterface && \method_exists ( $ pending , ' cancel ' ) ) {
597
595
$ pending ->cancel ();
598
596
}
599
597
$ pending = null ;
@@ -644,7 +642,7 @@ function waterfall(iterable $tasks): PromiseInterface
644
642
{
645
643
$ pending = null ;
646
644
$ deferred = new Deferred (function () use (&$ pending ) {
647
- if ($ pending instanceof CancellablePromiseInterface ) {
645
+ if ($ pending instanceof PromiseInterface && \method_exists ( $ pending , ' cancel ' ) ) {
648
646
$ pending ->cancel ();
649
647
}
650
648
$ pending = null ;
0 commit comments