当前位置: 首页>>代码示例>>PHP>>正文


PHP Streams::readableFd方法代码示例

本文整理汇总了PHP中Streams::readableFd方法的典型用法代码示例。如果您正苦于以下问题:PHP Streams::readableFd方法的具体用法?PHP Streams::readableFd怎么用?PHP Streams::readableFd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Streams的用法示例。


在下文中一共展示了Streams::readableFd方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor
  *
  * @param   io.streams.InputStream in
  */
 public function __construct(InputStream $in)
 {
     $this->in = Streams::readableFd($in);
     if (!stream_filter_append($this->in, 'zlib.inflate', STREAM_FILTER_READ)) {
         throw new IOException('Could not append stream filter');
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:12,代码来源:InflatingInputStream.class.php

示例2: __construct

 /**
  * Constructor
  *
  * @param   io.streams.InputStream in
  */
 public function __construct(InputStream $in)
 {
     $this->in = Streams::readableFd($in);
     if (!stream_filter_append($this->in, 'bzip2.decompress', STREAM_FILTER_READ)) {
         throw new \io\IOException('Could not append stream filter');
     }
 }
开发者ID:xp-framework,项目名称:core,代码行数:12,代码来源:Bz2DecompressingInputStream.class.php

示例3: get_contents_read_returns_less_than_size

 public function get_contents_read_returns_less_than_size()
 {
     $f = new File(Streams::readableFd(new class('Test') extends MemoryInputStream
     {
         public function read($size = 4096)
         {
             return parent::read(min(1, $size));
         }
     }));
     $this->assertEquals('Test', FileUtil::getContents($f));
 }
开发者ID:xp-framework,项目名称:core,代码行数:11,代码来源:FileUtilTest.class.php

示例4: __construct

 /**
  * Constructor. Creates a new TextReader on an underlying input
  * stream with a given charset.
  *
  * @param   io.streams.InputStream stream
  * @param   string charset the charset the stream is encoded in or NULL to trigger autodetection by BOM
  */
 public function __construct(InputStream $stream, $charset = NULL)
 {
     parent::__construct($stream);
     $this->in = Streams::readableFd($stream);
     if (NULL === $charset) {
         $charset = $this->detectCharset();
     }
     if (!stream_filter_append($this->in, 'convert.iconv.' . $charset . '/' . xp::ENCODING, STREAM_FILTER_READ)) {
         throw new IOException('Could not append stream filter');
     }
     $this->charset = $charset;
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:19,代码来源:TextReader.class.php

示例5: boxResource

 public function boxResource()
 {
     $fd = Streams::readableFd(new MemoryInputStream('test'));
     try {
         Primitive::boxed($fd);
     } catch (IllegalArgumentException $expected) {
         // OK
     }
     ensure($expected);
     fclose($fd);
     // Necessary, PHP will segfault otherwise
     if ($expected) {
         return;
     }
     $this->fail('Expected exception not caught', NULL, 'lang.IllegalArgumentException');
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:16,代码来源:PrimitiveTest.class.php

示例6: read_while_not_eof

 public function read_while_not_eof()
 {
     $fd = Streams::readableFd(new MemoryInputStream(str_repeat('x', 1024)));
     $l = [];
     while (!feof($fd)) {
         $c = fread($fd, 128);
         $l[] = strlen($c);
     }
     fclose($fd);
     $this->assertEquals([128, 128, 128, 128, 128, 128, 128, 128], $l);
 }
开发者ID:xp-framework,项目名称:core,代码行数:11,代码来源:StreamWrappingTest.class.php

示例7: creating_archive

 public function creating_archive()
 {
     $contents = ['lang/Object.class.php' => '<?php class Object { }', 'lang/Type.class.php' => '<?php class Type extends Object { }'];
     $out = new MemoryOutputStream();
     $a = new Archive(new File(Streams::writeableFd($out)));
     $a->open(Archive::CREATE);
     foreach ($contents as $filename => $bytes) {
         $a->addBytes($filename, $bytes);
     }
     $a->create();
     $file = new File(Streams::readableFd(new MemoryInputStream($out->getBytes())));
     $this->assertEntries(new Archive($file), $contents);
 }
开发者ID:xp-framework,项目名称:core,代码行数:13,代码来源:ArchiveTest.class.php

示例8: whileNotEof

 public function whileNotEof()
 {
     $fd = Streams::readableFd(new MemoryInputStream(str_repeat('x', 1024)));
     $l = array();
     while (!feof($fd)) {
         $c = fread($fd, 128);
         $l[] = strlen($c);
     }
     fclose($fd);
     $this->assertEquals(array(128, 128, 128, 128, 128, 128, 128, 128), $l);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:11,代码来源:StreamWrappingTest.class.php

示例9: newStream

 /**
  * Returns a new EncapsedStream instance
  *
  * @return  io.EncapsedStream
  */
 public function newStream($contents = '', $start = 0, $length = 0)
 {
     return new EncapsedStream(new File(Streams::readableFd(new MemoryInputStream($contents))), $start, $length);
 }
开发者ID:xp-framework,项目名称:core,代码行数:9,代码来源:EncapsedStreamTest.class.php


注:本文中的Streams::readableFd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。