Skip to content

Commit 859c0e5

Browse files
committed
Forward compatibility with upcoming Promise v3
1 parent 988ba38 commit 859c0e5

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
],
1313
"require": {
1414
"php": ">=5.3",
15-
"react/promise": "^2.5 || ^1.2.1",
15+
"react/promise": "^3 || ^2.9 || ^1.2.1",
1616
"react/stream": "^1.2"
1717
},
1818
"require-dev": {
1919
"clue/ndjson-react": "^1.0",
2020
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
21-
"react/http": "^1.4"
21+
"react/http": "^1.8"
2222
},
2323
"autoload": {
2424
"psr-4": {

src/Transformer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Evenement\EventEmitter;
66
use InvalidArgumentException;
7-
use React\Promise\CancellablePromiseInterface;
87
use React\Stream\DuplexStreamInterface;
98
use React\Stream\Util;
109
use React\Stream\WritableStreamInterface;
@@ -771,7 +770,7 @@ public function close()
771770
$this->queued = array();
772771

773772
foreach ($this->promises as $promise) {
774-
if ($promise instanceof CancellablePromiseInterface) {
773+
if ($promise instanceof PromiseInterface && \method_exists($promise, 'cancel')) {
775774
$promise->cancel();
776775
}
777776
}

tests/TransformerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testWriteDoesEmitDrainEventAfterHandlerResolves()
5555
$through->write('hello');
5656

5757
$through->on('drain', $this->expectCallableOnce());
58-
$deferred->resolve();
58+
$deferred->resolve(null);
5959
}
6060

6161
public function testResumeAfterWriteAfterPauseEmitsDrainEventIfHandlerResolves()
@@ -167,7 +167,7 @@ public function testWriteAfterWriteDoesInvokeHandlerAgainAfterPreviousHandlerRes
167167
$through->write('hello');
168168
$through->write('world');
169169

170-
$deferred->resolve();
170+
$deferred->resolve(null);
171171

172172
$this->assertEquals(array('hello', 'world'), $pending);
173173
}
@@ -362,7 +362,7 @@ public function testEndWithDataAfterWriteAfterWriteDoesInvokeHandlerAgainInCorre
362362
$through->write('hello');
363363
$through->write('world');
364364
$through->end('again');
365-
$deferred->resolve();
365+
$deferred->resolve(null);
366366

367367
$this->assertEquals(array('hello', 'world', 'again'), $pending);
368368
}
@@ -377,7 +377,7 @@ public function testEndDoesNotEmitDrainEventAfterHandlerResolves()
377377
$through->end('hello');
378378

379379
$through->on('drain', $this->expectCallableNever());
380-
$deferred->resolve();
380+
$deferred->resolve(null);
381381
}
382382

383383
public function testEndAfterCloseIsNoop()

0 commit comments

Comments
 (0)