diff --git a/composer.json b/composer.json index 1d8c1d7..b79b188 100644 --- a/composer.json +++ b/composer.json @@ -12,13 +12,13 @@ ], "require": { "php": ">=5.3", - "react/promise": "^2.5 || ^1.2.1", + "react/promise": "^3 || ^2.9 || ^1.2.1", "react/stream": "^1.2" }, "require-dev": { "clue/ndjson-react": "^1.0", "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", - "react/http": "^1.4" + "react/http": "^1.8" }, "autoload": { "psr-4": { diff --git a/src/Transformer.php b/src/Transformer.php index c77cdda..c7975a8 100644 --- a/src/Transformer.php +++ b/src/Transformer.php @@ -4,7 +4,6 @@ use Evenement\EventEmitter; use InvalidArgumentException; -use React\Promise\CancellablePromiseInterface; use React\Stream\DuplexStreamInterface; use React\Stream\Util; use React\Stream\WritableStreamInterface; @@ -771,7 +770,7 @@ public function close() $this->queued = array(); foreach ($this->promises as $promise) { - if ($promise instanceof CancellablePromiseInterface) { + if ($promise instanceof PromiseInterface && \method_exists($promise, 'cancel')) { $promise->cancel(); } } diff --git a/tests/TransformerTest.php b/tests/TransformerTest.php index 50a6836..a19d2cb 100644 --- a/tests/TransformerTest.php +++ b/tests/TransformerTest.php @@ -55,7 +55,7 @@ public function testWriteDoesEmitDrainEventAfterHandlerResolves() $through->write('hello'); $through->on('drain', $this->expectCallableOnce()); - $deferred->resolve(); + $deferred->resolve(null); } public function testResumeAfterWriteAfterPauseEmitsDrainEventIfHandlerResolves() @@ -167,7 +167,7 @@ public function testWriteAfterWriteDoesInvokeHandlerAgainAfterPreviousHandlerRes $through->write('hello'); $through->write('world'); - $deferred->resolve(); + $deferred->resolve(null); $this->assertEquals(array('hello', 'world'), $pending); } @@ -362,7 +362,7 @@ public function testEndWithDataAfterWriteAfterWriteDoesInvokeHandlerAgainInCorre $through->write('hello'); $through->write('world'); $through->end('again'); - $deferred->resolve(); + $deferred->resolve(null); $this->assertEquals(array('hello', 'world', 'again'), $pending); } @@ -377,7 +377,7 @@ public function testEndDoesNotEmitDrainEventAfterHandlerResolves() $through->end('hello'); $through->on('drain', $this->expectCallableNever()); - $deferred->resolve(); + $deferred->resolve(null); } public function testEndAfterCloseIsNoop()