Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ each individual file chunk:

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

$decompressor = ZlibFilterStream::createGzipDecompressor();

Expand Down Expand Up @@ -141,7 +141,6 @@ These inconsistencies exist in the underlying PHP engines and there's little we
* PHP 7 only: Compressing an empty string does not emit any data (not a valid compression stream)
* HHVM only: does not currently support the GZIP and ZLIB format at all (and does not raise an error)
* 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.
* PHP 5.3 only: Tends to SEGFAULT occasionally on shutdown?

Our test suite contains several test cases that exhibit these issues.
If you feel some test case is missing or outdated, we're happy to accept PRs! :)
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
],
"require": {
"php": ">=5.3",
"react/stream": "~0.4.3",
"clue/stream-filter": "~1.3"
"clue/stream-filter": "~1.3",
"react/stream": "^1.0 || ^0.7 || ^0.6"
},
"require-dev": {
"react/event-loop": "~0.4.0|~0.3.0",
"phpunit/phpunit": "^5.0 || ^4.8"
"phpunit/phpunit": "^5.0 || ^4.8",
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3"
},
"suggest": {
"ext-zlib": "Requires ext-zlib extension"
Expand Down
4 changes: 2 additions & 2 deletions examples/gunzip.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

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

$in = new React\Stream\Stream(STDIN, $loop);
$out = new React\Stream\Stream(STDOUT, $loop);
$in = new React\Stream\ReadableResourceStream(STDIN, $loop);
$out = new React\Stream\WritableResourceStream(STDOUT, $loop);

$decompressor = Clue\React\Zlib\ZlibFilterStream::createGzipDecompressor();
$in->pipe($decompressor)->pipe($out);
Expand Down
4 changes: 2 additions & 2 deletions examples/gzip.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

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

$in = new React\Stream\Stream(STDIN, $loop);
$out = new React\Stream\Stream(STDOUT, $loop);
$in = new React\Stream\ReadableResourceStream(STDIN, $loop);
$out = new React\Stream\WritableResourceStream(STDOUT, $loop);

$compressor = Clue\React\Zlib\ZlibFilterStream::createGzipCompressor(1);
$in->pipe($compressor)->pipe($out);
Expand Down
12 changes: 6 additions & 6 deletions src/TransformStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TransformStream extends EventEmitter implements DuplexStreamInterface
public function write($data)
{
if (!$this->writable || $data === '') {
return;
return false;
}

try {
Expand Down Expand Up @@ -57,7 +57,7 @@ public function close()
$this->readable = false;
$this->writable = false;

$this->emit('close', array($this));
$this->emit('close');
}

public function isReadable()
Expand Down Expand Up @@ -98,10 +98,10 @@ public function pipe(WritableStreamInterface $dest, array $options = array())
*/
protected function forwardData($data)
{
if (!$this->readable && $data !== '') {
if (!$this->readable) {
return;
}
$this->emit('data', array($data, $this));
$this->emit('data', array($data));
}

/**
Expand All @@ -121,7 +121,7 @@ protected function forwardEnd()
$this->readable = false;
$this->writable = false;

$this->emit('end', array($this));
$this->emit('end');
$this->close();
}

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

$this->emit('error', array($error, $this));
$this->emit('error', array($error));
$this->close();
}

Expand Down