Skip to content

Commit 936a88b

Browse files
committed
Forward compatibility with react/promise 3
1 parent a6ff7b9 commit 936a88b

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"php": ">=5.3.0",
88
"react/cache": "^1.0 || ^0.6 || ^0.5",
99
"react/event-loop": "^1.0 || ^0.5",
10-
"react/promise": "^2.7 || ^1.2.1",
10+
"react/promise": "^3.0 || ^2.7 || ^1.2.1",
1111
"react/promise-timer": "^1.2"
1212
},
1313
"require-dev": {

src/Query/RetryExecutor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use React\Promise\CancellablePromiseInterface;
66
use React\Promise\Deferred;
7+
use React\Promise\PromiseInterface;
78

89
final class RetryExecutor implements ExecutorInterface
910
{
@@ -24,7 +25,7 @@ public function query(Query $query)
2425
public function tryQuery(Query $query, $retries)
2526
{
2627
$deferred = new Deferred(function () use (&$promise) {
27-
if ($promise instanceof CancellablePromiseInterface) {
28+
if ($promise instanceof CancellablePromiseInterface || (!interface_exists('React\Promise\CancellablePromiseInterface') && \method_exists($promise, 'cancel'))) {
2829
$promise->cancel();
2930
}
3031
});

src/Query/TimeoutExecutor.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace React\Dns\Query;
44

55
use React\EventLoop\LoopInterface;
6-
use React\Promise\Deferred;
7-
use React\Promise\CancellablePromiseInterface;
86
use React\Promise\Timer;
97

108
final class TimeoutExecutor implements ExecutorInterface

tests/Query/RetryExecutorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ protected function expectPromiseOnce($return = null)
323323
$mock
324324
->expects($this->once())
325325
->method('then')
326-
->will($this->returnValue($return));
326+
->will($this->returnValue(Promise\resolve($return)));
327327

328328
return $mock;
329329
}

0 commit comments

Comments
 (0)