本文整理汇总了PHP中Psy\Shell::writeException方法的典型用法代码示例。如果您正苦于以下问题:PHP Shell::writeException方法的具体用法?PHP Shell::writeException怎么用?PHP Shell::writeException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psy\Shell
的用法示例。
在下文中一共展示了Shell::writeException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getClosure
/**
* @return callable
*/
private function getClosure()
{
$closure = function () {
extract($this->shellSoul->getScopeVariables());
try {
$this->shellSoul->addCode($this->code);
// evaluate the current code buffer
ob_start([$this->shellSoul, 'writeStdout'], version_compare(PHP_VERSION, '5.4', '>=') ? 1 : 2);
set_error_handler([$this->shellSoul, 'handleError']);
$_ = eval($this->shellSoul->flushCode() ?: Loop::NOOP_INPUT);
restore_error_handler();
ob_end_flush();
$this->shellSoul->writeReturnValue($_);
} catch (BreakException $_e) {
restore_error_handler();
if (ob_get_level() > 0) {
ob_end_clean();
}
$this->shellSoul->writeException($_e);
return;
} catch (ThrowUpException $_e) {
restore_error_handler();
if (ob_get_level() > 0) {
ob_end_clean();
}
$this->shellSoul->writeException($_e);
throw $_e;
} catch (\Exception $_e) {
restore_error_handler();
if (ob_get_level() > 0) {
ob_end_clean();
}
$this->shellSoul->writeException($_e);
}
$this->shellSoul->setScopeVariables(get_defined_vars());
};
return $closure;
}
示例2: testWriteException
/**
* @dataProvider getRenderedExceptions
*/
public function testWriteException($exception, $expected)
{
$output = $this->getOutput();
$stream = $output->getStream();
$shell = new Shell($this->getConfig());
$shell->setOutput($output);
$shell->writeException($exception);
rewind($stream);
$this->assertEquals($expected, stream_get_contents($stream));
}