Skip to content

Commit 5100d35

Browse files
committed
Update all ReactPHP dependencies to latest versions
1 parent 80c988a commit 5100d35

8 files changed

Lines changed: 34 additions & 37 deletions

File tree

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@
1818
},
1919
"require": {
2020
"php": ">=5.3",
21-
"clue/buzz-react": "^1.0",
21+
"clue/buzz-react": "^2.0",
2222
"clue/json-stream": "^0.1",
2323
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
2424
"react/promise": "^2.0 || ^1.1",
2525
"react/promise-stream": "^1.0",
26+
"react/socket": "^1.0",
27+
"react/stream": "^1.0",
2628
"rize/uri-template": "^0.3"
2729
},
2830
"require-dev": {
2931
"clue/block-react": "^1.0 || ^0.3",
3032
"clue/caret-notation": "^0.2",
31-
"clue/tar-react": "^0.2 || ^0.1",
33+
"clue/tar-react": "^0.2",
3234
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35"
3335
}
3436
}

examples/exec-stream.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
// displays the streaming output as it happens.
55

66
use Clue\React\Docker\Client;
7-
use React\Stream\Stream;
7+
use React\Stream\WritableResourceStream;
88

99
require __DIR__ . '/../vendor/autoload.php';
1010

11+
if (DIRECTORY_SEPARATOR === '\\') {
12+
exit('File I/O not supported on Windows' . PHP_EOL);
13+
}
14+
1115
$container = 'asd';
1216
//$cmd = array('echo', 'hello world');
1317
//$cmd = array('sleep', '2');
@@ -22,11 +26,8 @@
2226
$loop = React\EventLoop\Factory::create();
2327
$client = new Client($loop);
2428

25-
$out = new Stream(STDOUT, $loop);
26-
$out->pause();
27-
28-
$stderr = new Stream(STDERR, $loop);
29-
$stderr->pause();
29+
$out = new WritableResourceStream(STDOUT, $loop);
30+
$stderr = new WritableResourceStream(STDERR, $loop);
3031

3132
// unkown exit code by default
3233
$exit = 1;

examples/export.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
// and how we it can be piped into a output tar file.
55

66
use Clue\React\Docker\Client;
7-
use React\Stream\Stream;
7+
use React\Stream\WritableResourceStream;
88

99
require __DIR__ . '/../vendor/autoload.php';
1010

11+
if (DIRECTORY_SEPARATOR === '\\') {
12+
exit('File I/O not supported on Windows' . PHP_EOL);
13+
}
14+
1115
$container = isset($argv[1]) ? $argv[1] : 'asd';
1216
$target = isset($argv[2]) ? $argv[2] : ($container . '.tar');
1317
echo 'Exporting whole container "' . $container . '" to "' . $target .'" (pass as arguments to this example)' . PHP_EOL;
@@ -22,8 +26,7 @@
2226
echo 'ERROR requesting stream' . PHP_EOL . $e;
2327
});
2428

25-
$out = new Stream(fopen($target, 'w'), $loop);
26-
$out->pause();
29+
$out = new WritableResourceStream(fopen($target, 'w'), $loop);
2730
$stream->pipe($out);
2831

2932
$loop->run();

src/Client.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ public function __construct(LoopInterface $loop, $url = null)
4242

4343
if (substr($url, 0, 7) === 'unix://') {
4444
// send everything through a local unix domain socket
45-
$browser = $browser->withSender(
46-
Sender::createFromLoopUnix($loop, $url)
45+
$connector = new \React\Socket\FixedUriConnector(
46+
$url,
47+
new \React\Socket\UnixConnector($loop)
4748
);
4849

4950
// pretend all HTTP URLs to be on localhost
51+
$browser = new Browser($loop, $connector);
5052
$url = 'http://localhost/';
5153
}
5254

tests/ClientTest.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Clue\Tests\React\Docker;
44

5-
use Clue\React\Buzz\Browser;
65
use Clue\React\Docker\Client;
76
use Psr\Http\Message\RequestInterface;
87
use Psr\Http\Message\ResponseInterface;
@@ -13,7 +12,6 @@
1312
class ClientTest extends TestCase
1413
{
1514
private $loop;
16-
private $sender;
1715
private $browser;
1816

1917
private $parser;
@@ -23,9 +21,7 @@ class ClientTest extends TestCase
2321
public function setUp()
2422
{
2523
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
26-
$this->sender = $this->getMockBuilder('Clue\React\Buzz\Io\Sender')->disableOriginalConstructor()->getMock();
27-
$this->browser = new Browser($this->loop, $this->sender);
28-
$this->browser = $this->browser->withBase('http://x/');
24+
$this->browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock();
2925

3026
$this->parser = $this->getMockBuilder('Clue\React\Docker\Io\ResponseParser')->getMock();
3127
$this->streamingParser = $this->getMockBuilder('Clue\React\Docker\Io\StreamingParser')->getMock();
@@ -562,13 +558,8 @@ private function expectRequestFlow($method, $url, ResponseInterface $response, $
562558

563559
private function expectRequest($method, $url, ResponseInterface $response)
564560
{
565-
$that = $this;
566-
$this->sender->expects($this->once())->method('send')->with($this->callback(function (RequestInterface $request) use ($that, $method, $url) {
567-
$that->assertEquals(strtoupper($method), $request->getMethod());
568-
$that->assertEquals('http://x' . $url, (string)$request->getUri());
569-
570-
return true;
571-
}))->will($this->returnPromise($response));
561+
$this->browser->expects($this->any())->method('withOptions')->willReturnSelf();
562+
$this->browser->expects($this->once())->method(strtolower($method))->with($url)->willReturn(\React\Promise\resolve($response));
572563
}
573564

574565
private function createResponse($body = '')

tests/Io/ReadableDemultiplexStreamTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
use Clue\React\Docker\Io\ReadableDemultiplexStream;
66
use Clue\Tests\React\Docker\TestCase;
7-
use React\Stream\ReadableStream;
8-
use React\Stream\WritableStream;
7+
use React\Stream\ThroughStream;
98

109
class ReadableDemultiplexStreamTest extends TestCase
1110
{
@@ -14,7 +13,7 @@ class ReadableDemultiplexStreamTest extends TestCase
1413

1514
public function setUp()
1615
{
17-
$this->stream = new ReadableStream();
16+
$this->stream = new ThroughStream();
1817
$this->parser = new ReadableDemultiplexStream($this->stream);
1918
}
2019

@@ -106,7 +105,7 @@ public function testCloseTwiceWillEmitCloseOnceAndRemoveAllListeners()
106105

107106
public function testPipeWillBeForwardedToTargetStream()
108107
{
109-
$target = new WritableStream();
108+
$target = new ThroughStream();
110109
$target->on('pipe', $this->expectCallableOnceWith($this->parser));
111110

112111
$this->parser->pipe($target);

tests/Io/ReadableJsonStreamTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
use Clue\React\Docker\Io\ReadableJsonStream;
66
use Clue\Tests\React\Docker\TestCase;
7-
use React\Stream\ReadableStream;
8-
use React\Stream\WritableStream;
7+
use React\Stream\ThroughStream;
98

109
class ReadableJsonStreamTest extends TestCase
1110
{
@@ -14,7 +13,7 @@ class ReadableJsonStreamTest extends TestCase
1413

1514
public function setUp()
1615
{
17-
$this->stream = new ReadableStream();
16+
$this->stream = new ThroughStream();
1817
$this->parser = new ReadableJsonStream($this->stream);
1918
}
2019

@@ -129,7 +128,7 @@ public function testCloseTwiceWillEmitCloseOnceAndRemoveAllListeners()
129128

130129
public function testPipeWillBeForwardedToTargetStream()
131130
{
132-
$target = new WritableStream();
131+
$target = new ThroughStream();
133132
$target->on('pipe', $this->expectCallableOnceWith($this->parser));
134133

135134
$this->parser->pipe($target);

tests/Io/StreamingParserTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use React\Promise;
88
use React\Promise\CancellablePromiseInterface;
99
use React\Promise\Deferred;
10-
use React\Stream\ReadableStream;
10+
use React\Stream\ThroughStream;
1111

1212
class StreamingParserTest extends TestCase
1313
{
@@ -79,7 +79,7 @@ public function testDeferredClosedStreamWillReject()
7979

8080
public function testDeferredStreamEventsWillBeEmittedAndBuffered()
8181
{
82-
$stream = new ReadableStream();
82+
$stream = new ThroughStream();
8383

8484
$promise = $this->parser->deferredStream($stream);
8585

@@ -94,7 +94,7 @@ public function testDeferredStreamEventsWillBeEmittedAndBuffered()
9494

9595
public function testDeferredStreamErrorEventWillRejectPromise()
9696
{
97-
$stream = new ReadableStream();
97+
$stream = new ThroughStream();
9898

9999
$promise = $this->parser->deferredStream($stream);
100100

@@ -126,7 +126,7 @@ public function testDeferredCancelingPromiseWillCloseStream()
126126

127127
public function testDemultiplexStreamWillReturnReadable()
128128
{
129-
$stream = new ReadableStream();
129+
$stream = new ThroughStream();
130130

131131
$out = $this->parser->demultiplexStream($stream);
132132

0 commit comments

Comments
 (0)