Skip to content

Commit d85c0f1

Browse files
authored
Merge pull request #20 from WyriHaximus-labs/promise-3
Forward compatibility with react/promise 3
2 parents 069bd23 + 5535436 commit d85c0f1

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
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 & 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\WritableStreamInterface;
109

@@ -153,7 +152,7 @@ public function close()
153152
$this->closed = true;
154153

155154
// try to cancel promise once the stream closes
156-
if ($this->promise instanceof CancellablePromiseInterface) {
155+
if ($this->promise !== null && \method_exists($this->promise, 'cancel')) {
157156
$this->promise->cancel();
158157
}
159158
$this->promise = $this->stream = null;

0 commit comments

Comments
 (0)