Skip to content

Commit

Permalink
Forward compatibility with react/promise 3
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Mar 8, 2022
1 parent 069bd23 commit 7e2257a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"require": {
"php": ">=5.3",
"react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4.6",
"react/promise": "^2.1 || ^1.2"
"react/promise": "^3 || ^2.1 || ^1.2"
},
"require-dev": {
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
Expand Down
3 changes: 1 addition & 2 deletions src/UnwrapReadableStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Evenement\EventEmitter;
use InvalidArgumentException;
use React\Promise\CancellablePromiseInterface;
use React\Promise\PromiseInterface;
use React\Stream\ReadableStreamInterface;
use React\Stream\Util;
Expand Down Expand Up @@ -126,7 +125,7 @@ public function close()
$this->closed = true;

// try to cancel promise once the stream closes
if ($this->promise instanceof CancellablePromiseInterface) {
if ($this->promise !== null && \method_exists($this->promise, 'cancel')) {
$this->promise->cancel();
}
$this->promise = null;
Expand Down
2 changes: 1 addition & 1 deletion src/UnwrapWritableStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function close()
$this->closed = true;

// try to cancel promise once the stream closes
if ($this->promise instanceof CancellablePromiseInterface) {
if ($this->promise !== null && \method_exists($this->promise, 'cancel')) {
$this->promise->cancel();
}
$this->promise = $this->stream = null;
Expand Down

0 comments on commit 7e2257a

Please sign in to comment.