本文整理汇总了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');
}
}
示例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');
}
}
示例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');
}
}
示例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');
}
示例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());
}
示例6: reading_from_writeable_fd_raises_exception
public function reading_from_writeable_fd_raises_exception()
{
$fd = Streams::writeableFd(new MemoryOutputStream());
fread($fd, 1024);
}
示例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);
}
示例8: readFromWriteableFd
public function readFromWriteableFd()
{
$fd = Streams::writeableFd(new MemoryOutputStream());
fread($fd, 1024);
}
示例9: printStackTrace
public function printStackTrace()
{
$out = new MemoryOutputStream();
$e = new Throwable('Test');
create($e)->printStackTrace(Streams::writeableFd($out));
$this->assertEquals($e->toString(), $out->getBytes());
}