3
3
namespace React \Async ;
4
4
5
5
use React \EventLoop \Loop ;
6
- use React \Promise \CancellablePromiseInterface ;
7
6
use React \Promise \Deferred ;
8
7
use React \Promise \PromiseInterface ;
9
8
use function React \Promise \reject ;
@@ -235,7 +234,7 @@ function coroutine(callable $function, ...$args): PromiseInterface
235
234
$ promise = null ;
236
235
$ deferred = new Deferred (function () use (&$ promise ) {
237
236
// cancel pending promise(s) as long as generator function keeps yielding
238
- while ($ promise instanceof CancellablePromiseInterface ) {
237
+ while ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
239
238
$ temp = $ promise ;
240
239
$ promise = null ;
241
240
$ temp ->cancel ();
@@ -290,7 +289,7 @@ function parallel(array $tasks): PromiseInterface
290
289
$ pending = [];
291
290
$ deferred = new Deferred (function () use (&$ pending ) {
292
291
foreach ($ pending as $ promise ) {
293
- if ($ promise instanceof CancellablePromiseInterface ) {
292
+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
294
293
$ promise ->cancel ();
295
294
}
296
295
}
@@ -309,7 +308,7 @@ function parallel(array $tasks): PromiseInterface
309
308
$ deferred ->reject ($ error );
310
309
311
310
foreach ($ pending as $ promise ) {
312
- if ($ promise instanceof CancellablePromiseInterface ) {
311
+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
313
312
$ promise ->cancel ();
314
313
}
315
314
}
@@ -347,7 +346,7 @@ function series(array $tasks): PromiseInterface
347
346
{
348
347
$ pending = null ;
349
348
$ deferred = new Deferred (function () use (&$ pending ) {
350
- if ($ pending instanceof CancellablePromiseInterface ) {
349
+ if ($ pending instanceof PromiseInterface && \method_exists ( $ pending , ' cancel ' ) ) {
351
350
$ pending ->cancel ();
352
351
}
353
352
$ pending = null ;
@@ -387,7 +386,7 @@ function waterfall(array $tasks): PromiseInterface
387
386
{
388
387
$ pending = null ;
389
388
$ deferred = new Deferred (function () use (&$ pending ) {
390
- if ($ pending instanceof CancellablePromiseInterface ) {
389
+ if ($ pending instanceof PromiseInterface && \method_exists ( $ pending , ' cancel ' ) ) {
391
390
$ pending ->cancel ();
392
391
}
393
392
$ pending = null ;
0 commit comments