33namespace Clue \React \Mq ;
44
55use React \Promise ;
6- use React \Promise \CancellablePromiseInterface ;
76use React \Promise \Deferred ;
87use React \Promise \PromiseInterface ;
98
@@ -124,7 +123,7 @@ public static function all($concurrency, array $jobs, $handler)
124123 Promise \all ($ promises )->then ($ resolve , function ($ e ) use ($ promises , $ reject ) {
125124 // cancel all pending promises if a single promise fails
126125 foreach (array_reverse ($ promises ) as $ promise ) {
127- if ($ promise instanceof CancellablePromiseInterface ) {
126+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
128127 $ promise ->cancel ();
129128 }
130129 }
@@ -135,7 +134,7 @@ public static function all($concurrency, array $jobs, $handler)
135134 }, function () use ($ promises ) {
136135 // cancel all pending promises on cancellation
137136 foreach (array_reverse ($ promises ) as $ promise ) {
138- if ($ promise instanceof CancellablePromiseInterface ) {
137+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
139138 $ promise ->cancel ();
140139 }
141140 }
@@ -241,7 +240,7 @@ public static function any($concurrency, array $jobs, $handler)
241240 Promise \any ($ promises )->then (function ($ result ) use ($ promises , $ resolve ) {
242241 // cancel all pending promises if a single result is ready
243242 foreach (array_reverse ($ promises ) as $ promise ) {
244- if ($ promise instanceof CancellablePromiseInterface ) {
243+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
245244 $ promise ->cancel ();
246245 }
247246 }
@@ -252,7 +251,7 @@ public static function any($concurrency, array $jobs, $handler)
252251 }, function () use ($ promises ) {
253252 // cancel all pending promises on cancellation
254253 foreach (array_reverse ($ promises ) as $ promise ) {
255- if ($ promise instanceof CancellablePromiseInterface ) {
254+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
256255 $ promise ->cancel ();
257256 }
258257 }
@@ -367,7 +366,7 @@ public function __invoke()
367366
368367 $ deferred = new Deferred (function ($ _ , $ reject ) use (&$ queue , $ id , &$ deferred ) {
369368 // 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 ' ) ) {
371370 $ deferred ->pending ->cancel ();
372371 }
373372 unset($ deferred ->pending );
0 commit comments