Skip to content

Commit

Permalink
Merge pull request #20 from WyriHaximus-labs/promise-3
Browse files Browse the repository at this point in the history
Forward compatibility with react/promise 3
clue authored Mar 9, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 069bd23 + 5535436 commit d85c0f1
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
@@ -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",
3 changes: 1 addition & 2 deletions src/UnwrapReadableStream.php
Original file line number Diff line number Diff line change
@@ -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;
@@ -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;
3 changes: 1 addition & 2 deletions src/UnwrapWritableStream.php
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@

use Evenement\EventEmitter;
use InvalidArgumentException;
use React\Promise\CancellablePromiseInterface;
use React\Promise\PromiseInterface;
use React\Stream\WritableStreamInterface;

@@ -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;

0 comments on commit d85c0f1

Please sign in to comment.