本文整理汇总了PHP中Writer::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Writer::write方法的具体用法?PHP Writer::write怎么用?PHP Writer::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Writer
的用法示例。
在下文中一共展示了Writer::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPhpParserException
public function testPhpParserException()
{
$traverser = $this->getMock('PhpParser\\NodeTraverser');
$traverser->expects($this->once())->method('traverse')->will($this->throwException(new \PhpParser\Error('error')));
$writer = new Writer($traverser);
$this->setExpectedException('hanneskod\\classtools\\Exception\\RuntimeException');
$writer->write([]);
}
示例2: exampleStripNodes
/**
* Strip statements
*
* @expectOutputRegex #echo 'bar';#
*/
public function exampleStripNodes()
{
$reader = new Reader("<?php require 'Foo.php'; echo 'bar';");
$writer = new Writer();
$writer->apply(new Action\NodeStripper('Expr_Include'));
// Outputs the echo statement
echo $writer->write($reader->readAll());
}
示例3: run
public function run()
{
$writer = new Writer($this->config['parameters'], $this->config['dataFolder']);
$tables = $this->config['storage']['input']['tables'];
foreach ($tables as $table) {
$writer->write($table);
}
}
示例4: testWriteIntegers
public function testWriteIntegers()
{
$w = new Writer(tmpfile(), array('hasHeader' => true));
$numbers = array('zero' => 0, 'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5);
$w->write($numbers);
foreach ($w as $line) {
$this->assertEquals($line, $numbers);
}
}
示例5: generate
public function generate()
{
$parseData = \EventController::callFilter(self::EventName, $this->data->getValue());
$view = new View($this->tpl->getValue());
$view->addHelper(new ViewHelper());
$view->set($parseData);
$content = $view->render();
$writer = new Writer($this->url->getValue());
$writer->write($content);
}
示例6: endElement
/**
* Handles closing elements of the xml file.
*
* @param $name The local name (without prefix), or the empty string if
* Namespace processing is not being performed.
*/
public function endElement($name)
{
if (self::DEBUG) {
print "endElement(" . $name . ") called\n";
}
if ($name == "dataset") {
if ($this->currBuilder !== null) {
$this->sqlWriter->write($this->currBuilder->getTableEndSql());
}
$this->sqlWriter->write(call_user_func(array($this->builderClazz, 'getDatabaseEndSql')));
}
}
示例7: execute
public function execute()
{
$iterator = new \DirectoryIterator($this->inputDir);
$interpreter = new Interpreter();
$operations = [];
foreach ($iterator as $path) {
if ($path->getExtension() === 'rst') {
$operations[] = $interpreter->parse(file_get_contents($path->getRealPath()));
}
}
$operations = array_values(array_filter($operations));
usort($operations, function ($a, $b) {
return strlen($a['path']) - strlen($b['path']);
});
$writer = new Writer($this->outputDir, $this->namespace, $operations);
$writer->write();
}
示例8: write
/**
* 配列をCSV形式で書き出す
* @access public
* @see Writer::write()
*/
function write($arr)
{
$enclosure = preg_quote($this->enclosure);
foreach ($arr as $index => $ar) {
if (!is_string($ar)) {
continue;
}
// 文字列中に"がある場合は""に置換える
// RFC4180
if (mb_strstr($ar, $this->enclosure) !== false) {
$ar = preg_replace('/' . $enclosure . '/', $this->enclosure . $this->enclosure, $ar);
}
// 文字列の場合は囲み文字を追加する
$ar = $this->enclosure . $ar . $this->enclosure;
$arr[$index] = $ar;
}
parent::write(implode($this->delimiter, $arr) . $this->newLineChar);
}
示例9: testSaveGlobalUseStatements
public function testSaveGlobalUseStatements()
{
$reader = new Reader(<<<EOF
<?php
use random\\Exception;
class ClassName
{
}
EOF
);
$expected = <<<EOF
namespace {
use random\\Exception;
class ClassName
{
}
}
EOF;
$writer = new Writer();
$this->assertEquals($expected, $writer->write($reader->read('ClassName')));
}
示例10: writeTable
/**
* Write PHP array, as table. Input array format: keys are strings,
* values are (type,value) tuples.
*
* @param $d
*
* @return Writer
*/
public function writeTable($d)
{
$this->flushBits();
$table_data = new Writer();
foreach ($d as $k => $va) {
list($ftype, $v) = $va;
$table_data->writeShortStr($k);
if ($ftype == 'S') {
$table_data->write('S');
$table_data->writeLongStr($v);
} else {
if ($ftype == 'I') {
$table_data->write('I');
$table_data->_writeSignedLong($v);
} else {
if ($ftype == 'D') {
// 'D' type values are passed Decimal instances.
$table_data->write('D');
$table_data->writeOctet($v->e);
$table_data->_writeSignedLong($v->n);
} else {
if ($ftype == 'T') {
$table_data->write('T');
$table_data->writeTimestamp($v);
} else {
if ($ftype == 'F') {
$table_data->write('F');
$table_data->writeTable($v);
} else {
if ($ftype = 'A') {
$table_data->write('A');
$table_data->writeArray($v);
}
}
}
}
}
}
}
$table_data = $table_data->getvalue();
$this->writeLong(strlen($table_data));
$this->write($table_data);
return $this;
}
示例11: write
public function write($output)
{
return $this->writer->write($output);
}
示例12: testWriteToMimeDir
function testWriteToMimeDir()
{
$result = Writer::write($this->getComponent());
$this->assertEquals("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n", $result);
}
示例13: pipe
function pipe(Writer $writer)
{
while ($v = $this->read()) {
$writer->write($v);
}
}
示例14: appendFile
/**
* @param FileWriter $writer
* @param PhingFile $f
*
* @return void
*/
private function appendFile(Writer $writer, PhingFile $f)
{
$in = $this->getFilteredReader(new FileReader($f));
$text = '';
while (-1 !== ($buffer = $in->read())) {
// -1 indicates EOF
$text .= $buffer;
}
if ($this->fixLastLine && ($text[strlen($text) - 1] !== "\n" || $text[strlen($text) - 1] !== "\r")) {
$text .= $this->eolString;
}
$text = $this->appendHeader($text);
$text = $this->appendFooter($text);
$writer->write($text);
if ($f instanceof PhingFile && $this->to instanceof PhingFile) {
$this->log("Appending contents of " . $f->getPath() . " to " . $this->to->getPath());
}
}
示例15: write
/**
* Returns the document as a string
*
* @param string $format the desired format (optional; if omitted, defaults
* to 'rtf')
* @return string
* @throws InvalidArgumentException if $format is not a string
* @since 0.1.0
*/
public function write($format = 'rtf')
{
$string = '';
// if $format is a string
if (is_string($format)) {
$writer = new Writer();
$string = $writer->write($this->root, $format);
} else {
throw new \InvalidArgumentException(__METHOD__ . "() expects parameter one, format, to be a string");
}
return $string;
}