當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Writer::write方法代碼示例

本文整理匯總了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([]);
 }
開發者ID:bonroyage,項目名稱:classtools,代碼行數:8,代碼來源:WriterTest.php

示例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());
 }
開發者ID:bonroyage,項目名稱:classtools,代碼行數:13,代碼來源:TransformerExamples.php

示例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);
     }
 }
開發者ID:keboola,項目名稱:gd-metrics-writer,代碼行數:8,代碼來源:Application.php

示例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);
     }
 }
開發者ID:mmerian,項目名稱:csv,代碼行數:9,代碼來源:WriterTest.php

示例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);
 }
開發者ID:gudwin,項目名稱:extasy,代碼行數:10,代碼來源:Page.php

示例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')));
     }
 }
開發者ID:RafalFilipek,項目名稱:Propel2,代碼行數:18,代碼來源:XmlToDataSQL.php

示例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();
 }
開發者ID:php-opencloud,項目名稱:scraper,代碼行數:17,代碼來源:Finder.php

示例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);
 }
開發者ID:weiweiabc109,項目名稱:test_project1,代碼行數:23,代碼來源:CsvWriter.class.php

示例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')));
    }
開發者ID:bonroyage,項目名稱:classtools,代碼行數:21,代碼來源:UseStmtTranslationTest.php

示例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;
 }
開發者ID:zircote,項目名稱:amqp,代碼行數:52,代碼來源:Writer.php

示例11: write

 public function write($output)
 {
     return $this->writer->write($output);
 }
開發者ID:syhol,項目名稱:asclay,代碼行數:4,代碼來源:TerminalFacade.php

示例12: testWriteToMimeDir

 function testWriteToMimeDir()
 {
     $result = Writer::write($this->getComponent());
     $this->assertEquals("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n", $result);
 }
開發者ID:ddolbik,項目名稱:sabre-vobject,代碼行數:5,代碼來源:WriterTest.php

示例13: pipe

 function pipe(Writer $writer)
 {
     while ($v = $this->read()) {
         $writer->write($v);
     }
 }
開發者ID:jgswift,項目名稱:qio,代碼行數:6,代碼來源:Reader.php

示例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());
     }
 }
開發者ID:kenguest,項目名稱:phing,代碼行數:24,代碼來源:AppendTask.php

示例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;
 }
開發者ID:jstewmc,項目名稱:rtf,代碼行數:21,代碼來源:Document.php


注:本文中的Writer::write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。