Skip to content

Commit

Permalink
Merge pull request #26 from clue-labs/promise-v3
Browse files Browse the repository at this point in the history
Forward compatibility with upcoming Promise v3
  • Loading branch information
SimonFrings committed Mar 13, 2023
2 parents 3ea74b3 + 859c0e5 commit f178d40
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -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": {
Expand Down
3 changes: 1 addition & 2 deletions src/Transformer.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/TransformerTest.php
Expand Up @@ -55,7 +55,7 @@ public function testWriteDoesEmitDrainEventAfterHandlerResolves()
$through->write('hello');

$through->on('drain', $this->expectCallableOnce());
$deferred->resolve();
$deferred->resolve(null);
}

public function testResumeAfterWriteAfterPauseEmitsDrainEventIfHandlerResolves()
Expand Down Expand Up @@ -167,7 +167,7 @@ public function testWriteAfterWriteDoesInvokeHandlerAgainAfterPreviousHandlerRes
$through->write('hello');
$through->write('world');

$deferred->resolve();
$deferred->resolve(null);

$this->assertEquals(array('hello', 'world'), $pending);
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -377,7 +377,7 @@ public function testEndDoesNotEmitDrainEventAfterHandlerResolves()
$through->end('hello');

$through->on('drain', $this->expectCallableNever());
$deferred->resolve();
$deferred->resolve(null);
}

public function testEndAfterCloseIsNoop()
Expand Down

0 comments on commit f178d40

Please sign in to comment.