33namespace React \Async ;
44
55use React \EventLoop \Loop ;
6- use React \Promise \CancellablePromiseInterface ;
76use React \Promise \Deferred ;
87use React \Promise \PromiseInterface ;
98
@@ -108,7 +107,7 @@ function parallel(array $tasks)
108107 $ pending = array ();
109108 $ deferred = new Deferred (function () use (&$ pending ) {
110109 foreach ($ pending as $ promise ) {
111- if ($ promise instanceof CancellablePromiseInterface ) {
110+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
112111 $ promise ->cancel ();
113112 }
114113 }
@@ -127,7 +126,7 @@ function parallel(array $tasks)
127126 $ deferred ->reject ($ error );
128127
129128 foreach ($ pending as $ promise ) {
130- if ($ promise instanceof CancellablePromiseInterface ) {
129+ if ($ promise instanceof PromiseInterface && \method_exists ( $ promise , ' cancel ' ) ) {
131130 $ promise ->cancel ();
132131 }
133132 }
@@ -165,7 +164,7 @@ function series(array $tasks)
165164{
166165 $ pending = null ;
167166 $ deferred = new Deferred (function () use (&$ pending ) {
168- if ($ pending instanceof CancellablePromiseInterface ) {
167+ if ($ pending instanceof PromiseInterface && \method_exists ( $ pending , ' cancel ' ) ) {
169168 $ pending ->cancel ();
170169 }
171170 $ pending = null ;
@@ -205,7 +204,7 @@ function waterfall(array $tasks)
205204{
206205 $ pending = null ;
207206 $ deferred = new Deferred (function () use (&$ pending ) {
208- if ($ pending instanceof CancellablePromiseInterface ) {
207+ if ($ pending instanceof PromiseInterface && \method_exists ( $ pending , ' cancel ' ) ) {
209208 $ pending ->cancel ();
210209 }
211210 $ pending = null ;
0 commit comments