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


PHP Streams::writeableFd方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * @param   io.streams.OutputStream out
  * @param   int lineLength limit maximum line length
  */
 public function __construct(OutputStream $out, $lineLength = 0)
 {
     $params = $lineLength ? array('line-length' => $lineLength, 'line-break-chars' => "\n") : array();
     $this->out = Streams::writeableFd($out);
     if (!stream_filter_append($this->out, 'convert.base64-encode', STREAM_FILTER_WRITE, $params)) {
         throw new IOException('Could not append stream filter');
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:14,代码来源:Base64OutputStream.class.php

示例2: __construct

 /**
  * Constructor
  *
  * @param   io.streams.OutputStream out
  * @param   int level default 6
  * @throws  lang.IllegalArgumentException if the level is not between 0 and 9
  */
 public function __construct(OutputStream $out, $level = 6)
 {
     if ($level < 0 || $level > 9) {
         throw new IllegalArgumentException('Level ' . $level . ' out of range [0..9]');
     }
     $this->out = Streams::writeableFd($out);
     if (!stream_filter_append($this->out, 'zlib.deflate', STREAM_FILTER_WRITE, $level)) {
         fclose($this->out);
         $this->out = NULL;
         throw new IOException('Could not append stream filter');
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:19,代码来源:DeflatingOutputStream.class.php

示例3: __construct

 /**
  * Constructor
  *
  * @param   io.streams.OutputStream out
  * @param   int level default 6
  * @throws  lang.IllegalArgumentException if the level is not between 0 and 9
  */
 public function __construct(OutputStream $out, $level = 6)
 {
     if ($level < 0 || $level > 9) {
         throw new \lang\IllegalArgumentException('Level ' . $level . ' out of range [0..9]');
     }
     $this->out = Streams::writeableFd($out);
     if (!stream_filter_append($this->out, 'bzip2.compress', STREAM_FILTER_WRITE, ['blocks' => $level])) {
         fclose($this->out);
         $this->out = null;
         throw new \io\IOException('Could not append stream filter');
     }
 }
开发者ID:johannes85,项目名称:core,代码行数:19,代码来源:Bz2CompressingOutputStream.class.php

示例4: __construct

 /**
  * Constructor
  *
  * @param   io.streams.OutputStream out
  * @param   int level default 6
  * @throws  lang.IllegalArgumentException if the level is not between 0 and 9
  */
 public function __construct(OutputStream $out, $level = 6)
 {
     if ($level < 0 || $level > 9) {
         throw new \lang\IllegalArgumentException('Level ' . $level . ' out of range [0..9]');
     }
     // Write GZIP format header:
     // * ID1, ID2 (Identification, \x1F, \x8B)
     // * CM       (Compression Method, 8 = deflate)
     // * FLG      (Flags, use 0)
     // * MTIME    (Modification time, Un*x timestamp)
     // * XFL      (Extra flags, 2 = compressor used maximum compression)
     // * OS       (Operating system, 255 = unknown)
     $out->write(pack('CCCCVCC', 0x1f, 0x8b, 8, 0, time(), 2, 255));
     // Now, convert stream to file handle and append deflating filter
     $this->out = Streams::writeableFd($out);
     if (!($this->filter = stream_filter_append($this->out, 'zlib.deflate', STREAM_FILTER_WRITE, $level))) {
         fclose($this->out);
         $this->out = null;
         throw new \io\IOException('Could not append stream filter');
     }
     $this->md = hash_init('crc32b');
 }
开发者ID:xp-framework,项目名称:core,代码行数:29,代码来源:GzCompressingOutputStream.class.php

示例5: set_contents_writes_bytes

 public function set_contents_writes_bytes()
 {
     $out = new MemoryOutputStream();
     FileUtil::setContents(new File(Streams::writeableFd($out)), 'Test');
     $this->assertEquals('Test', $out->getBytes());
 }
开发者ID:xp-framework,项目名称:core,代码行数:6,代码来源:FileUtilTest.class.php

示例6: reading_from_writeable_fd_raises_exception

 public function reading_from_writeable_fd_raises_exception()
 {
     $fd = Streams::writeableFd(new MemoryOutputStream());
     fread($fd, 1024);
 }
开发者ID:xp-framework,项目名称:core,代码行数:5,代码来源: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: readFromWriteableFd

 public function readFromWriteableFd()
 {
     $fd = Streams::writeableFd(new MemoryOutputStream());
     fread($fd, 1024);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:5,代码来源:StreamWrappingTest.class.php

示例9: printStackTrace

 public function printStackTrace()
 {
     $out = new MemoryOutputStream();
     $e = new Throwable('Test');
     create($e)->printStackTrace(Streams::writeableFd($out));
     $this->assertEquals($e->toString(), $out->getBytes());
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:7,代码来源:ExceptionsTest.class.php


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