function TesterTrait::initOutput
Initializes the output property.
Available options:
- decorated: Sets the output decorated flag
- verbosity: Sets the output verbosity flag
- capture_stderr_separately: Make output of stdOut and stdErr separately available
2 calls to TesterTrait::initOutput()
- ApplicationTester::run in vendor/
symfony/ console/ Tester/ ApplicationTester.php - Executes the application.
- CommandTester::execute in vendor/
symfony/ console/ Tester/ CommandTester.php - Executes the command.
File
-
vendor/
symfony/ console/ Tester/ TesterTrait.php, line 131
Class
- TesterTrait
- @author Amrouche Hamza <hamza.simperfit@gmail.com>
Namespace
Symfony\Component\Console\TesterCode
private function initOutput(array $options) : void {
$this->captureStreamsIndependently = $options['capture_stderr_separately'] ?? false;
if (!$this->captureStreamsIndependently) {
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
if (isset($options['decorated'])) {
$this->output
->setDecorated($options['decorated']);
}
if (isset($options['verbosity'])) {
$this->output
->setVerbosity($options['verbosity']);
}
}
else {
$this->output = new ConsoleOutput($options['verbosity'] ?? ConsoleOutput::VERBOSITY_NORMAL, $options['decorated'] ?? null);
$errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
$errorOutput->setFormatter($this->output
->getFormatter());
$errorOutput->setVerbosity($this->output
->getVerbosity());
$errorOutput->setDecorated($this->output
->isDecorated());
$reflectedOutput = new \ReflectionObject($this->output);
$strErrProperty = $reflectedOutput->getProperty('stderr');
$strErrProperty->setValue($this->output, $errorOutput);
$reflectedParent = $reflectedOutput->getParentClass();
$streamProperty = $reflectedParent->getProperty('stream');
$streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
}
}