當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。