Skip to content

Commit dda0a2a

Browse files
authored
Merge pull request #6 from thklein/stream-update
Forward compatibility with Stream v0.7, v0.6, v0.5 and upcoming v1.0 (while keeping BC)
2 parents f07f22e + 9e3d84a commit dda0a2a

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ as parsed values instead of just chunks of strings:
2828
"hello w\u00f6rld"\r\n
2929
```
3030
```php
31-
$stdin = new Stream(STDIN, $loop);
31+
$stdin = new ReadableResourceStream(STDIN, $loop);
3232

3333
$stream = new Decoder($stdin);
3434

@@ -118,7 +118,7 @@ and accepts its data through the same interface, but handles any data as complet
118118
JSON elements instead of just chunks of strings:
119119

120120
```php
121-
$stdout = new Stream(STDOUT, $loop);
121+
$stdout = new WritableResourceStream(STDOUT, $loop);
122122

123123
$stream = new Encoder($stdout);
124124

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
},
1616
"require": {
1717
"php": ">=5.3",
18-
"react/stream": "^0.4 || ^0.3"
18+
"react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4 || ^0.3"
1919
},
2020
"require-dev": {
2121
"react/event-loop": " ^0.4 || ^0.3",
22-
"phpunit/phpunit": "^5.0 || ^4.8"
22+
"phpunit/phpunit": "^5.0 || ^4.8",
23+
"react/stream": "^1.0 || ^0.7 || ^0.6"
2324
}
2425
}

examples/validate.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

33
use React\EventLoop\Factory;
4-
use React\Stream\Stream;
4+
use React\Stream\ReadableResourceStream;
5+
use React\Stream\WritableResourceStream;
56
use Clue\React\NDJson\Decoder;
67
use Clue\React\NDJson\Encoder;
78

@@ -10,11 +11,9 @@
1011
$loop = Factory::create();
1112

1213
$exit = 0;
13-
$in = new Stream(STDIN, $loop);
14-
$out = new Stream(STDOUT, $loop);
15-
$out->pause();
16-
$info = new Stream(STDERR, $loop);
17-
$info->pause();
14+
$in = new ReadableResourceStream(STDIN, $loop);
15+
$out = new WritableResourceStream(STDOUT, $loop);
16+
$info = new WritableResourceStream(STDERR, $loop);
1817

1918
$decoder = new Decoder($in);
2019
$encoder = new Encoder($out);

tests/DecoderTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
use React\Stream\ReadableStream;
3+
use React\Stream\ReadableResourceStream;
44
use Clue\React\NDJson\Decoder;
55

66
class DecoderTest extends TestCase
@@ -10,7 +10,10 @@ class DecoderTest extends TestCase
1010

1111
public function setUp()
1212
{
13-
$this->input = new ReadableStream();
13+
$stream = fopen('php://temp', 'r');
14+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
15+
16+
$this->input = new ReadableResourceStream($stream, $loop);
1417
$this->decoder = new Decoder($this->input);
1518
}
1619

tests/EncoderTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
use React\Stream\WritableStream;
3+
use React\Stream\WritableResourceStream;
44
use Clue\React\NDJson\Encoder;
55

66
class EncoderTest extends TestCase
@@ -10,7 +10,10 @@ class EncoderTest extends TestCase
1010

1111
public function setUp()
1212
{
13-
$this->output = new WritableStream();
13+
$stream = fopen('php://temp', 'r+');
14+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
15+
16+
$this->output = new WritableResourceStream($stream, $loop);
1417
$this->encoder = new Encoder($this->output);
1518
}
1619

0 commit comments

Comments
 (0)