From ec2d71923e81daebda179d17707f641b449d7afe Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Tue, 8 Oct 2019 18:06:46 +0200 Subject: [PATCH] Forward compatibility with react/promise 3 --- composer.json | 2 +- src/UnwrapReadableStream.php | 2 +- src/UnwrapWritableStream.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 7fe0bc3..68cef83 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,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": "dev-master as 3.0.0 || ^2.1 || ^1.2" }, "require-dev": { "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3", diff --git a/src/UnwrapReadableStream.php b/src/UnwrapReadableStream.php index acd23be..cafa040 100644 --- a/src/UnwrapReadableStream.php +++ b/src/UnwrapReadableStream.php @@ -126,7 +126,7 @@ public function close() $this->closed = true; // try to cancel promise once the stream closes - if ($this->promise instanceof CancellablePromiseInterface) { + if ($this->promise instanceof CancellablePromiseInterface || (method_exists($this->promise, 'cancel') && $this->promise instanceof PromiseInterface)) { $this->promise->cancel(); } $this->promise = null; diff --git a/src/UnwrapWritableStream.php b/src/UnwrapWritableStream.php index f19e706..636382b 100644 --- a/src/UnwrapWritableStream.php +++ b/src/UnwrapWritableStream.php @@ -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 instanceof CancellablePromiseInterface || (method_exists($this->promise, 'cancel') && $this->promise instanceof PromiseInterface)) { $this->promise->cancel(); } $this->promise = $this->stream = null;