Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward compatibility with upcoming Promise v3 #26

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
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
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\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
Original file line number Diff line number Diff line change
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