Skip to content

Commit 079da38

Browse files
committed
Forward compatibility with upcoming Promise v3
1 parent 55ec42a commit 079da38

File tree

5 files changed

+34
-15
lines changed

5 files changed

+34
-15
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
with:
2929
php-version: ${{ matrix.php }}
3030
coverage: xdebug
31+
env:
32+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3133
- run: composer install
3234
- run: vendor/bin/phpunit --coverage-text
3335
if: ${{ matrix.php >= 7.3 }}
@@ -38,6 +40,7 @@ jobs:
3840
name: PHPUnit (HHVM)
3941
runs-on: ubuntu-18.04
4042
continue-on-error: true
43+
if: false # temporarily skipped until https://github.com/azjezz/setup-hhvm/issues/3 is addressed
4144
steps:
4245
- uses: actions/checkout@v2
4346
- uses: azjezz/setup-hhvm@v1

composer.json

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,41 @@
3131
"fig/http-message-util": "^1.1",
3232
"psr/http-message": "^1.0",
3333
"react/event-loop": "^1.2",
34-
"react/promise": "^2.3 || ^1.2.1",
35-
"react/promise-stream": "^1.1",
36-
"react/socket": "^1.9",
34+
"react/promise": "^3@dev || ^2.1 || ^1.2.1",
35+
"react/promise-stream": "^1.4",
36+
"react/socket": "dev-promise-3 as 1.12.0",
3737
"react/stream": "^1.2",
3838
"ringcentral/psr7": "^1.2"
3939
},
4040
"require-dev": {
4141
"clue/block-react": "^1.5",
42-
"clue/http-proxy-react": "^1.7",
43-
"clue/reactphp-ssh-proxy": "^1.3",
44-
"clue/socks-react": "^1.3",
42+
"clue/http-proxy-react": "dev-promise-v3 as 1.8.0",
43+
"clue/reactphp-ssh-proxy": "dev-promise-v3 as 1.4.0",
44+
"clue/socks-react": "dev-promise-v3 as 1.4.0",
4545
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
4646
},
4747
"autoload": {
4848
"psr-4": { "React\\Http\\": "src" }
4949
},
5050
"autoload-dev": {
5151
"psr-4": { "React\\Tests\\Http\\": "tests" }
52-
}
52+
},
53+
"repositories": [
54+
{
55+
"type": "vcs",
56+
"url": "https://github.com/WyriHaximus-labs/socket"
57+
},
58+
{
59+
"type": "vcs",
60+
"url": "https://github.com/clue-labs/reactphp-http-proxy"
61+
},
62+
{
63+
"type": "vcs",
64+
"url": "https://github.com/clue-labs/reactphp-socks"
65+
},
66+
{
67+
"type": "vcs",
68+
"url": "https://github.com/clue-labs/reactphp-ssh-proxy"
69+
}
70+
]
5371
}

src/Io/StreamingServer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use React\Http\Message\Response;
1010
use React\Http\Message\ServerRequest;
1111
use React\Promise;
12-
use React\Promise\CancellablePromiseInterface;
1312
use React\Promise\PromiseInterface;
1413
use React\Socket\ConnectionInterface;
1514
use React\Socket\ServerInterface;
@@ -158,7 +157,7 @@ public function handleRequest(ConnectionInterface $conn, ServerRequestInterface
158157
}
159158

160159
// cancel pending promise once connection closes
161-
if ($response instanceof CancellablePromiseInterface) {
160+
if ($response instanceof PromiseInterface && \method_exists($response, 'cancel')) {
162161
$conn->on('close', function () use ($response) {
163162
$response->cancel();
164163
});

tests/Io/MiddlewareRunnerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use React\Http\Io\MiddlewareRunner;
1010
use React\Http\Message\ServerRequest;
1111
use React\Promise;
12-
use React\Promise\CancellablePromiseInterface;
1312
use React\Promise\PromiseInterface;
1413
use React\Tests\Http\Middleware\ProcessStack;
1514
use React\Tests\Http\TestCase;
@@ -480,7 +479,7 @@ function (RequestInterface $request) use ($once) {
480479

481480
$promise = $middleware($request);
482481

483-
$this->assertTrue($promise instanceof CancellablePromiseInterface);
482+
$this->assertTrue($promise instanceof PromiseInterface && \method_exists($promise, 'cancel'));
484483
$promise->cancel();
485484
}
486485
}

tests/Middleware/LimitConcurrentRequestsMiddlewareTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function testLimitOneRequestConcurrently()
7979
/**
8080
* Ensure resolve frees up a slot
8181
*/
82-
$deferredA->resolve();
82+
$deferredA->resolve(null);
8383

8484
$this->assertTrue($calledA);
8585
$this->assertTrue($calledB);
@@ -88,7 +88,7 @@ public function testLimitOneRequestConcurrently()
8888
/**
8989
* Ensure reject also frees up a slot
9090
*/
91-
$deferredB->reject();
91+
$deferredB->reject(new \RuntimeException());
9292

9393
$this->assertTrue($calledA);
9494
$this->assertTrue($calledB);
@@ -194,7 +194,7 @@ public function testStreamDoesPauseAndThenResumeWhenDequeued()
194194

195195
$limitHandlers(new ServerRequest('GET', 'https://example.com/', array(), $body), function () {});
196196

197-
$deferred->reject();
197+
$deferred->reject(new \RuntimeException());
198198
}
199199

200200
public function testReceivesBufferedRequestSameInstance()
@@ -452,7 +452,7 @@ public function testReceivesStreamingBodyChangesInstanceWithCustomBodyButSameDat
452452
$req = $request;
453453
});
454454

455-
$deferred->reject();
455+
$deferred->reject(new \RuntimeException());
456456

457457
$this->assertNotSame($request, $req);
458458
$this->assertInstanceOf('Psr\Http\Message\ServerRequestInterface', $req);

0 commit comments

Comments
 (0)