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 9, 2022
1 parent 069bd23 commit 5535436
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 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
3 changes: 1 addition & 2 deletions src/UnwrapWritableStream.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\WritableStreamInterface;

Expand Down Expand Up @@ -153,7 +152,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 5535436

Please sign in to comment.