/** * @param StreamInterface $stream * @param mixed|null $readFilterOptions * @param mixed|null $writeFilterOptions deprecated since 1.5, will be removed in 2.0 */ public function __construct(StreamInterface $stream, $readFilterOptions = null, $writeFilterOptions = null) { $this->readFilterCallback = Filter\fun($this->readFilter(), $readFilterOptions); $this->writeFilterCallback = Filter\fun($this->writeFilter(), $writeFilterOptions); if (null !== $writeFilterOptions) { @trigger_error('The $writeFilterOptions argument is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED); } $this->stream = $stream; }
public function testFunZlibInflateBig() { if (defined('HHVM_VERSION')) { $this->markTestSkipped('Not supported on HHVM (final chunk will not be emitted)'); } $inflate = StreamFilter\fun('zlib.inflate'); $expected = str_repeat('hello', 10); $bytes = gzdeflate($expected); $ret = ''; foreach (str_split($bytes, 2) as $chunk) { $ret .= $inflate($chunk); } $ret .= $inflate(); $this->assertEquals($expected, $ret); }
/** * @param StreamInterface $stream * @param mixed|null $readFilterOptions * @param mixed|null $writeFilterOptions */ public function __construct(StreamInterface $stream, $readFilterOptions = null, $writeFilterOptions = null) { $this->readFilterCallback = Filter\fun($this->getReadFilter(), $readFilterOptions); $this->writeFilterCallback = Filter\fun($this->getWriteFilter(), $writeFilterOptions); $this->stream = $stream; }
/** * @expectedException RuntimeException */ public function testFunInvalid() { Filter\fun('unknown'); }
public function testAppendFunDechunk() { if (defined('HHVM_VERSION')) { $this->markTestSkipped('Not supported on HHVM (dechunk filter does not exist)'); } $stream = $this->createStream(); StreamFilter\append($stream, StreamFilter\fun('dechunk'), STREAM_FILTER_WRITE); fwrite($stream, "2\r\nhe\r\n"); fwrite($stream, "3\r\nllo\r\n"); fwrite($stream, "0\r\n\r\n"); rewind($stream); $this->assertEquals('hello', stream_get_contents($stream)); fclose($stream); }
public static function createZlibDecompressor() { return new self(Filter\fun('zlib.inflate', array('window' => 15))); }