Skip to content

Commit ce5de65

Browse files
committed
Forward compatibility with react/promise 3
1 parent 069bd23 commit ce5de65

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"require": {
3737
"php": ">=5.3",
3838
"react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4.6",
39-
"react/promise": "^2.1 || ^1.2"
39+
"react/promise": "^3 || ^2.1 || ^1.2"
4040
},
4141
"require-dev": {
4242
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",

src/UnwrapReadableStream.php

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

55
use Evenement\EventEmitter;
66
use InvalidArgumentException;
7-
use React\Promise\CancellablePromiseInterface;
87
use React\Promise\PromiseInterface;
98
use React\Stream\ReadableStreamInterface;
109
use React\Stream\Util;
@@ -126,7 +125,7 @@ public function close()
126125
$this->closed = true;
127126

128127
// try to cancel promise once the stream closes
129-
if ($this->promise instanceof CancellablePromiseInterface) {
128+
if ($this->promise !== null && \method_exists($this->promise, 'cancel')) {
130129
$this->promise->cancel();
131130
}
132131
$this->promise = null;

src/UnwrapWritableStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function close()
153153
$this->closed = true;
154154

155155
// try to cancel promise once the stream closes
156-
if ($this->promise instanceof CancellablePromiseInterface) {
156+
if ($this->promise instanceof CancellablePromiseInterface || (method_exists($this->promise, 'cancel') && $this->promise instanceof PromiseInterface)) {
157157
$this->promise->cancel();
158158
}
159159
$this->promise = $this->stream = null;

0 commit comments

Comments
 (0)