本文整理汇总了PHP中Symfony\Component\VarDumper\Dumper\CliDumper::defaultOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP CliDumper::defaultOutput方法的具体用法?PHP CliDumper::defaultOutput怎么用?PHP CliDumper::defaultOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\VarDumper\Dumper\CliDumper
的用法示例。
在下文中一共展示了CliDumper::defaultOutput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceDefaultSymfonyLineDumpers
/**
* Replaces the default output stream of Symfony's
* CliDumper and HtmlDumper classes in order to
* be able to run on Google App Engine.
*
* 'php://stdout' is used by CliDumper,
* 'php://output' is used by HtmlDumper,
* both are not supported on GAE.
*/
protected function replaceDefaultSymfonyLineDumpers()
{
HtmlDumper::$defaultOutput = CliDumper::$defaultOutput = function ($line, $depth, $indentPad) {
if (-1 !== $depth) {
echo str_repeat($indentPad, $depth) . $line . PHP_EOL;
}
};
}
示例2: assertResponseStatusWithDebug
/**
* Assert status code, and on failure print the output to assist debugging.
* @param int $code
*/
public function assertResponseStatusWithDebug($code)
{
try {
$actual = $this->response->getStatusCode();
return $this->assertEquals($code, $actual, "Expected status code {$code}, got {$actual}.");
} catch (\PHPUnit_Framework_ExpectationFailedException $e) {
$content = $this->response->getContent();
$json = json_decode($content);
//check to see if the response was valid json, if so assign the object to $content
if (json_last_error() === JSON_ERROR_NONE) {
$content = $json;
}
$originalDefaultOutput = CliDumper::$defaultOutput;
CliDumper::$defaultOutput = 'php://output';
$dumper = new CliDumper();
$dumper->dump((new VarCloner())->cloneVar($content));
CliDumper::$defaultOutput = $originalDefaultOutput;
throw $e;
}
}