Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 /**
  * @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;
 }
Exemplo n.º 4
0
 /**
  * @expectedException RuntimeException
  */
 public function testFunInvalid()
 {
     Filter\fun('unknown');
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
 public static function createZlibDecompressor()
 {
     return new self(Filter\fun('zlib.inflate', array('window' => 15)));
 }