本文整理匯總了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());
}