3
3
namespace Clue \React \Mq ;
4
4
5
5
use React \Promise ;
6
- use React \Promise \CancellablePromiseInterface ;
7
6
use React \Promise \Deferred ;
8
7
use React \Promise \PromiseInterface ;
9
8
@@ -124,7 +123,7 @@ public static function all($concurrency, array $jobs, $handler)
124
123
Promise \all ($ promises )->then ($ resolve , function ($ e ) use ($ promises , $ reject ) {
125
124
// cancel all pending promises if a single promise fails
126
125
foreach (array_reverse ($ promises ) as $ promise ) {
127
- if ($ promise instanceof CancellablePromiseInterface ) {
126
+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
128
127
$ promise ->cancel ();
129
128
}
130
129
}
@@ -135,7 +134,7 @@ public static function all($concurrency, array $jobs, $handler)
135
134
}, function () use ($ promises ) {
136
135
// cancel all pending promises on cancellation
137
136
foreach (array_reverse ($ promises ) as $ promise ) {
138
- if ($ promise instanceof CancellablePromiseInterface ) {
137
+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
139
138
$ promise ->cancel ();
140
139
}
141
140
}
@@ -241,7 +240,7 @@ public static function any($concurrency, array $jobs, $handler)
241
240
Promise \any ($ promises )->then (function ($ result ) use ($ promises , $ resolve ) {
242
241
// cancel all pending promises if a single result is ready
243
242
foreach (array_reverse ($ promises ) as $ promise ) {
244
- if ($ promise instanceof CancellablePromiseInterface ) {
243
+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
245
244
$ promise ->cancel ();
246
245
}
247
246
}
@@ -252,7 +251,7 @@ public static function any($concurrency, array $jobs, $handler)
252
251
}, function () use ($ promises ) {
253
252
// cancel all pending promises on cancellation
254
253
foreach (array_reverse ($ promises ) as $ promise ) {
255
- if ($ promise instanceof CancellablePromiseInterface ) {
254
+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
256
255
$ promise ->cancel ();
257
256
}
258
257
}
@@ -367,7 +366,7 @@ public function __invoke()
367
366
368
367
$ deferred = new Deferred (function ($ _ , $ reject ) use (&$ queue , $ id , &$ deferred ) {
369
368
// forward cancellation to pending operation if it is currently executing
370
- if (isset ($ deferred ->pending ) && $ deferred ->pending instanceof CancellablePromiseInterface ) {
369
+ if (isset ($ deferred ->pending ) && $ deferred ->pending instanceof PromiseInterface && \method_exists ( $ deferred -> pending , ' cancel ' ) ) {
371
370
$ deferred ->pending ->cancel ();
372
371
}
373
372
unset($ deferred ->pending );
0 commit comments