diff --git a/composer.json b/composer.json index 609b5f5..7fd2b90 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "require": { "php": ">=5.3.2", "react/event-loop": "^1.2", - "react/promise": "^2.8 || ^1.2.1" + "react/promise": "^3.0 || ^2.8 || ^1.2.1" }, "require-dev": { "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" diff --git a/src/functions.php b/src/functions.php index e4d3fec..d8aaed0 100644 --- a/src/functions.php +++ b/src/functions.php @@ -3,7 +3,6 @@ namespace React\Async; use React\EventLoop\Loop; -use React\Promise\CancellablePromiseInterface; use React\Promise\Deferred; use React\Promise\PromiseInterface; @@ -108,7 +107,7 @@ function parallel(array $tasks) $pending = array(); $deferred = new Deferred(function () use (&$pending) { foreach ($pending as $promise) { - if ($promise instanceof CancellablePromiseInterface) { + if ($promise instanceof PromiseInterface && \method_exists($promise, 'cancel')) { $promise->cancel(); } } @@ -127,7 +126,7 @@ function parallel(array $tasks) $deferred->reject($error); foreach ($pending as $promise) { - if ($promise instanceof CancellablePromiseInterface) { + if ($promise instanceof PromiseInterface && \method_exists($promise, 'cancel')) { $promise->cancel(); } } @@ -165,7 +164,7 @@ function series(array $tasks) { $pending = null; $deferred = new Deferred(function () use (&$pending) { - if ($pending instanceof CancellablePromiseInterface) { + if ($pending instanceof PromiseInterface && \method_exists($pending, 'cancel')) { $pending->cancel(); } $pending = null; @@ -205,7 +204,7 @@ function waterfall(array $tasks) { $pending = null; $deferred = new Deferred(function () use (&$pending) { - if ($pending instanceof CancellablePromiseInterface) { + if ($pending instanceof PromiseInterface && \method_exists($pending, 'cancel')) { $pending->cancel(); } $pending = null; diff --git a/tests/SeriesTest.php b/tests/SeriesTest.php index 7cedf91..188651d 100644 --- a/tests/SeriesTest.php +++ b/tests/SeriesTest.php @@ -87,7 +87,7 @@ public function testSeriesWillCancelFirstPendingPromiseWhenCallingCancelOnResult $tasks = array( function () { return new Promise(function ($resolve) { - $resolve(); + $resolve(null); }); }, function () use (&$cancelled) { diff --git a/tests/WaterfallTest.php b/tests/WaterfallTest.php index b0c5c3c..4643d82 100644 --- a/tests/WaterfallTest.php +++ b/tests/WaterfallTest.php @@ -94,7 +94,7 @@ public function testWaterfallWillCancelFirstPendingPromiseWhenCallingCancelOnRes $tasks = array( function () { return new Promise(function ($resolve) { - $resolve(); + $resolve(null); }); }, function () use (&$cancelled) {