Skip to content

Commit 0812e40

Browse files
authored
Merge pull request #13 from clue-labs/deps
Update to Stream v0.6 API and forward compatibility with Stream v1.0
2 parents 818af49 + ddf1984 commit 0812e40

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ each individual file chunk:
3434

3535
```php
3636
$loop = React\EventLoop\Factory::create();
37-
$stream = new Stream(fopen('access.log.gz', 'r'), $loop);
37+
$stream = new React\Stream\ReadableResourceStream(fopen('access.log.gz', 'r'), $loop);
3838

3939
$decompressor = ZlibFilterStream::createGzipDecompressor();
4040

@@ -141,7 +141,6 @@ These inconsistencies exist in the underlying PHP engines and there's little we
141141
* PHP 7 only: Compressing an empty string does not emit any data (not a valid compression stream)
142142
* HHVM only: does not currently support the GZIP and ZLIB format at all (and does not raise an error)
143143
* HHVM only: The [`zlib.deflate` filter function](https://github.com/facebook/hhvm/blob/fee8ae39ce395c7b9b8910dfde6f22a7745aea83/hphp/system/php/stream/default-filters.php#L77) buffers the whole string. This means that compressing a stream of 100 MB actually stores the whole string in memory before invoking the underlying compression algorithm.
144-
* PHP 5.3 only: Tends to SEGFAULT occasionally on shutdown?
145144

146145
Our test suite contains several test cases that exhibit these issues.
147146
If you feel some test case is missing or outdated, we're happy to accept PRs! :)

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
],
1313
"require": {
1414
"php": ">=5.3",
15-
"react/stream": "~0.4.3",
16-
"clue/stream-filter": "~1.3"
15+
"clue/stream-filter": "~1.3",
16+
"react/stream": "^1.0 || ^0.7 || ^0.6"
1717
},
1818
"require-dev": {
19-
"react/event-loop": "~0.4.0|~0.3.0",
20-
"phpunit/phpunit": "^5.0 || ^4.8"
19+
"phpunit/phpunit": "^5.0 || ^4.8",
20+
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3"
2121
},
2222
"suggest": {
2323
"ext-zlib": "Requires ext-zlib extension"

examples/gunzip.php

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

55
$loop = React\EventLoop\Factory::create();
66

7-
$in = new React\Stream\Stream(STDIN, $loop);
8-
$out = new React\Stream\Stream(STDOUT, $loop);
7+
$in = new React\Stream\ReadableResourceStream(STDIN, $loop);
8+
$out = new React\Stream\WritableResourceStream(STDOUT, $loop);
99

1010
$decompressor = Clue\React\Zlib\ZlibFilterStream::createGzipDecompressor();
1111
$in->pipe($decompressor)->pipe($out);

examples/gzip.php

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

55
$loop = React\EventLoop\Factory::create();
66

7-
$in = new React\Stream\Stream(STDIN, $loop);
8-
$out = new React\Stream\Stream(STDOUT, $loop);
7+
$in = new React\Stream\ReadableResourceStream(STDIN, $loop);
8+
$out = new React\Stream\WritableResourceStream(STDOUT, $loop);
99

1010
$compressor = Clue\React\Zlib\ZlibFilterStream::createGzipCompressor(1);
1111
$in->pipe($compressor)->pipe($out);

src/TransformStream.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TransformStream extends EventEmitter implements DuplexStreamInterface
2020
public function write($data)
2121
{
2222
if (!$this->writable || $data === '') {
23-
return;
23+
return false;
2424
}
2525

2626
try {
@@ -57,7 +57,7 @@ public function close()
5757
$this->readable = false;
5858
$this->writable = false;
5959

60-
$this->emit('close', array($this));
60+
$this->emit('close');
6161
}
6262

6363
public function isReadable()
@@ -98,10 +98,10 @@ public function pipe(WritableStreamInterface $dest, array $options = array())
9898
*/
9999
protected function forwardData($data)
100100
{
101-
if (!$this->readable && $data !== '') {
101+
if (!$this->readable) {
102102
return;
103103
}
104-
$this->emit('data', array($data, $this));
104+
$this->emit('data', array($data));
105105
}
106106

107107
/**
@@ -121,7 +121,7 @@ protected function forwardEnd()
121121
$this->readable = false;
122122
$this->writable = false;
123123

124-
$this->emit('end', array($this));
124+
$this->emit('end');
125125
$this->close();
126126
}
127127

@@ -143,7 +143,7 @@ protected function forwardError(Exception $error)
143143
$this->readable = false;
144144
$this->writable = false;
145145

146-
$this->emit('error', array($error, $this));
146+
$this->emit('error', array($error));
147147
$this->close();
148148
}
149149

0 commit comments

Comments
 (0)