本文整理汇总了PHP中Writer类的典型用法代码示例。如果您正苦于以下问题:PHP Writer类的具体用法?PHP Writer怎么用?PHP Writer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Writer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serialize
public static function serialize($var, $simple = false)
{
$stream = new BytesIO();
$writer = new Writer($stream, $simple);
$writer->serialize($var);
return $stream->toString();
}
示例2: 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);
}
}
示例3: 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());
}
示例4: 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([]);
}
示例5: 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);
}
}
示例6: 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);
}
示例7: testRender
public function testRender()
{
$writer = new Writer();
$property = new \ReflectionProperty($writer, 'collection');
$property->setAccessible(true);
$meta = new Meta(array('test' => 'fun'));
$writer->add($meta);
$writer->add($meta);
$this->assertEquals("<meta test=\"fun\" />\n<meta test=\"fun\" />\n", $writer->render());
}
示例8: 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();
}
示例9: testWriteAndRead
public function testWriteAndRead()
{
$config = new Config(array('default' => array('test' => 'foo')));
$this->writer->toFile($this->getTestAssetFileName(), $config);
$config = $this->reader->fromFile($this->getTestAssetFileName());
$this->assertEquals('foo', $config['default']['test']);
}
示例10: testSetException
/**
* @covers Itkg\Batch\State::setException
*/
public function testSetException()
{
$e = new \Exception();
$this->object->setException($e);
$this->assertEquals($e, $this->object->getException());
$this->assertEquals(1, $this->object->getStatus());
}
示例11: testFormatBatch
/**
* test formatBatch
*/
public function testFormatBatch()
{
$text = "it's a test";
$text2 = "it's another test";
$record = array('message' => $text);
$record2 = array('message' => $text2);
$this->assertEquals($text . $text2, $this->object->formatBatch(array($record, $record2)));
}
示例12: dispatch
/**
* Dispatch all raised events.
*
* @param array $events
*/
public function dispatch(array $events)
{
foreach ($events as $event) {
$eventName = $this->getEventName($event);
$this->event->fire($eventName, $event);
$this->log->info("{$eventName} was fired.");
}
}
示例13: init
public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
{
parent::init($survey, $sLanguageCode, $oOptions);
if ($oOptions->output == 'display') {
header("Content-Disposition: attachment; filename=survey_" . $survey->id . "_R_syntax_file.R");
header("Content-type: application/download; charset=UTF-8");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public");
$this->handle = fopen('php://output', 'w');
} elseif ($oOptions->output == 'file') {
$this->handle = fopen($this->filename, 'w');
}
$this->out('data <- read.csv("survey_' . $survey->id . '_R_data_file.csv", quote = "\'\\"", na.strings=c("", "\\"\\""), stringsAsFactors=FALSE)');
$this->out("");
$this->out("");
$oOptions->headingFormat = 'code';
// Always use fieldcodes
// R specific stuff
Yii::app()->loadHelper("export");
$tmpFieldmap = SPSSFieldMap($survey->id);
foreach ($tmpFieldmap as $field => $values) {
$fieldmap[$values['title']] = $values;
if (array_key_exists('sql_name', $values)) {
$fieldmap[$values['sql_name']] = $values;
}
}
$this->customFieldmap = $fieldmap;
}
示例14: init
public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
{
parent::init($survey, $sLanguageCode, $oOptions);
$this->survey = $survey;
if ($oOptions->output == 'display') {
//header("Content-Disposition: attachment; filename=results-survey".$survey->id.".html");
header("Content-type: text/html; charset=UTF-8");
$this->handle = fopen('php://output', 'w');
} elseif ($oOptions->output == 'file') {
$this->handle = fopen($this->filename, 'w');
}
$this->groupMap = array();
$index = 0;
foreach ($oOptions->selectedColumns as $column) {
if (isset($survey->fieldMap[$column])) {
$question = $survey->fieldMap[$column];
} else {
// Token field
$question = array('gid' => 0, 'qid' => '');
}
$question['index'] = $index;
$this->groupMap[intval($question['gid'])][] = $question;
$index++;
}
}
示例15: init
public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
{
parent::init($survey, $sLanguageCode, $oOptions);
App()->setLanguage($sLanguageCode);
if ($oOptions->output == 'display') {
header("Content-Disposition: attachment; filename=results-survey" . $survey->id . ".doc");
header("Content-type: application/vnd.ms-word");
}
$sOutput = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
table {
border-collapse:collapse;
}
td, th {
border:solid black 1.0pt;
}
th {
background: #c0c0c0;
}
</style>';
if ($oOptions->output == 'display') {
echo $sOutput;
} elseif ($oOptions->output == 'file') {
$this->file = fopen($this->filename, 'w');
$this->output = $sOutput;
}
}