本文整理汇总了PHP中Symfony\Component\Process\Process::clearErrorOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::clearErrorOutput方法的具体用法?PHP Process::clearErrorOutput怎么用?PHP Process::clearErrorOutput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Process\Process
的用法示例。
在下文中一共展示了Process::clearErrorOutput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processScript
/**
* {@inheritdoc}
*/
public function processScript(CliScript $script)
{
$log = $this->getLog();
$log->info('Executing "{script}" script', ['script' => $script->getScript()]);
// New process, with timeout
$process = new Process($script->getScript());
$process->setTimeout($script->getTimeout());
// Run process
$process->run(function ($type, $buffer) use($log) {
// Trim
$buffer = trim($buffer);
// Don't log empty output
if (empty($buffer)) {
return;
}
if (Process::OUT === $type) {
$log->debug($buffer);
return;
}
$log->error($buffer);
});
// Abort if process failed
if (!$process->isSuccessful()) {
// Remove the error output
$process->clearErrorOutput();
// Throw failure
throw new ScriptFailedException(sprintf('Script "%s" has filed', $script->getScript()));
}
}
示例2: testFlushErrorOutput
public function testFlushErrorOutput()
{
$p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
$p->run();
$p->clearErrorOutput();
$this->assertEmpty($p->getErrorOutput());
}