22
33namespace React \Async ;
44
5- use React \EventLoop \Loop ;
6- use React \Promise \CancellablePromiseInterface ;
75use React \Promise \Deferred ;
86use React \Promise \Promise ;
97use React \Promise \PromiseInterface ;
@@ -199,7 +197,7 @@ function async(callable $function): callable
199197 }, function () use (&$ fiber ): void {
200198 FiberMap::cancel ($ fiber );
201199 $ promise = FiberMap::getPromise ($ fiber );
202- if ($ promise instanceof CancellablePromiseInterface ) {
200+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
203201 $ promise ->cancel ();
204202 }
205203 });
@@ -535,7 +533,7 @@ function parallel(iterable $tasks): PromiseInterface
535533 $ pending = [];
536534 $ deferred = new Deferred (function () use (&$ pending ) {
537535 foreach ($ pending as $ promise ) {
538- if ($ promise instanceof CancellablePromiseInterface ) {
536+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
539537 $ promise ->cancel ();
540538 }
541539 }
@@ -549,7 +547,7 @@ function parallel(iterable $tasks): PromiseInterface
549547 $ deferred ->reject ($ error );
550548
551549 foreach ($ pending as $ promise ) {
552- if ($ promise instanceof CancellablePromiseInterface ) {
550+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
553551 $ promise ->cancel ();
554552 }
555553 }
@@ -593,7 +591,7 @@ function series(iterable $tasks): PromiseInterface
593591{
594592 $ pending = null ;
595593 $ deferred = new Deferred (function () use (&$ pending ) {
596- if ($ pending instanceof CancellablePromiseInterface ) {
594+ if ($ pending instanceof PromiseInterface && \method_exists ( $ pending , ' cancel ' ) ) {
597595 $ pending ->cancel ();
598596 }
599597 $ pending = null ;
@@ -644,7 +642,7 @@ function waterfall(iterable $tasks): PromiseInterface
644642{
645643 $ pending = null ;
646644 $ deferred = new Deferred (function () use (&$ pending ) {
647- if ($ pending instanceof CancellablePromiseInterface ) {
645+ if ($ pending instanceof PromiseInterface && \method_exists ( $ pending , ' cancel ' ) ) {
648646 $ pending ->cancel ();
649647 }
650648 $ pending = null ;
0 commit comments