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
@@ -108,7 +107,7 @@ function parallel(array $tasks)
108
107
$ pending = array ();
109
108
$ deferred = new Deferred (function () use (&$ pending ) {
110
109
foreach ($ pending as $ promise ) {
111
- if ($ promise instanceof CancellablePromiseInterface ) {
110
+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
112
111
$ promise ->cancel ();
113
112
}
114
113
}
@@ -127,7 +126,7 @@ function parallel(array $tasks)
127
126
$ deferred ->reject ($ error );
128
127
129
128
foreach ($ pending as $ promise ) {
130
- if ($ promise instanceof CancellablePromiseInterface ) {
129
+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
131
130
$ promise ->cancel ();
132
131
}
133
132
}
@@ -165,7 +164,7 @@ function series(array $tasks)
165
164
{
166
165
$ pending = null ;
167
166
$ deferred = new Deferred (function () use (&$ pending ) {
168
- if ($ pending instanceof CancellablePromiseInterface ) {
167
+ if ($ pending instanceof PromiseInterface && \method_exists ( $ pending , ' cancel ' ) ) {
169
168
$ pending ->cancel ();
170
169
}
171
170
$ pending = null ;
@@ -205,7 +204,7 @@ function waterfall(array $tasks)
205
204
{
206
205
$ pending = null ;
207
206
$ deferred = new Deferred (function () use (&$ pending ) {
208
- if ($ pending instanceof CancellablePromiseInterface ) {
207
+ if ($ pending instanceof PromiseInterface && \method_exists ( $ pending , ' cancel ' ) ) {
209
208
$ pending ->cancel ();
210
209
}
211
210
$ pending = null ;
0 commit comments