class ConsoleOutput in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Output/ConsoleOutput.php \Symfony\Component\Console\Output\ConsoleOutput
ConsoleOutput is the default class for all CLI output. It uses STDOUT.
This class is a convenient wrapper around `StreamOutput`.
$output = new ConsoleOutput();
This is equivalent to:
$output = new StreamOutput(fopen('php://stdout', 'w'));
@author Fabien Potencier <fabien@symfony.com>
Hierarchy
- class \Symfony\Component\Console\Output\Output implements OutputInterface
- class \Symfony\Component\Console\Output\StreamOutput
- class \Symfony\Component\Console\Output\ConsoleOutput implements ConsoleOutputInterface
- class \Symfony\Component\Console\Output\StreamOutput
Expanded class hierarchy of ConsoleOutput
4 files declare their use of ConsoleOutput
- Application.php in vendor/
symfony/ console/ Application.php - ConsoleOutputTest.php in vendor/
symfony/ console/ Tests/ Output/ ConsoleOutputTest.php - DebugHandlersListenerTest.php in vendor/
symfony/ http-kernel/ Tests/ EventListener/ DebugHandlersListenerTest.php - Shell.php in vendor/
symfony/ console/ Shell.php
File
- vendor/
symfony/ console/ Output/ ConsoleOutput.php, line 29
Namespace
Symfony\Component\Console\OutputView source
class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface {
/**
* @var StreamOutput
*/
private $stderr;
/**
* Constructor.
*
* @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface)
* @param bool|null $decorated Whether to decorate messages (null for auto-guessing)
* @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
*/
public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) {
parent::__construct($this
->openOutputStream(), $verbosity, $decorated, $formatter);
$actualDecorated = $this
->isDecorated();
$this->stderr = new StreamOutput($this
->openErrorStream(), $verbosity, $decorated, $this
->getFormatter());
if (null === $decorated) {
$this
->setDecorated($actualDecorated && $this->stderr
->isDecorated());
}
}
/**
* {@inheritdoc}
*/
public function setDecorated($decorated) {
parent::setDecorated($decorated);
$this->stderr
->setDecorated($decorated);
}
/**
* {@inheritdoc}
*/
public function setFormatter(OutputFormatterInterface $formatter) {
parent::setFormatter($formatter);
$this->stderr
->setFormatter($formatter);
}
/**
* {@inheritdoc}
*/
public function setVerbosity($level) {
parent::setVerbosity($level);
$this->stderr
->setVerbosity($level);
}
/**
* {@inheritdoc}
*/
public function getErrorOutput() {
return $this->stderr;
}
/**
* {@inheritdoc}
*/
public function setErrorOutput(OutputInterface $error) {
$this->stderr = $error;
}
/**
* Returns true if current environment supports writing console output to
* STDOUT.
*
* @return bool
*/
protected function hasStdoutSupport() {
return false === $this
->isRunningOS400();
}
/**
* Returns true if current environment supports writing console output to
* STDERR.
*
* @return bool
*/
protected function hasStderrSupport() {
return false === $this
->isRunningOS400();
}
/**
* Checks if current executing environment is IBM iSeries (OS400), which
* doesn't properly convert character-encodings between ASCII to EBCDIC.
*
* @return bool
*/
private function isRunningOS400() {
$checks = array(
function_exists('php_uname') ? php_uname('s') : '',
getenv('OSTYPE'),
PHP_OS,
);
return false !== stristr(implode(';', $checks), 'OS400');
}
/**
* @return resource
*/
private function openOutputStream() {
$outputStream = $this
->hasStdoutSupport() ? 'php://stdout' : 'php://output';
return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
}
/**
* @return resource
*/
private function openErrorStream() {
$errorStream = $this
->hasStderrSupport() ? 'php://stderr' : 'php://output';
return fopen($errorStream, 'w');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConsoleOutput:: |
private | property | ||
ConsoleOutput:: |
public | function |
Gets the OutputInterface for errors. Overrides ConsoleOutputInterface:: |
|
ConsoleOutput:: |
protected | function | Returns true if current environment supports writing console output to STDERR. | |
ConsoleOutput:: |
protected | function | Returns true if current environment supports writing console output to STDOUT. | |
ConsoleOutput:: |
private | function | Checks if current executing environment is IBM iSeries (OS400), which doesn't properly convert character-encodings between ASCII to EBCDIC. | |
ConsoleOutput:: |
private | function | ||
ConsoleOutput:: |
private | function | ||
ConsoleOutput:: |
public | function |
Sets the decorated flag. Overrides Output:: |
|
ConsoleOutput:: |
public | function |
Sets the OutputInterface used for errors. Overrides ConsoleOutputInterface:: |
|
ConsoleOutput:: |
public | function |
Sets output formatter. Overrides Output:: |
|
ConsoleOutput:: |
public | function |
Sets the verbosity of the output. Overrides Output:: |
|
ConsoleOutput:: |
public | function |
Constructor. Overrides StreamOutput:: |
|
Output:: |
private | property | ||
Output:: |
private | property | ||
Output:: |
public | function |
Returns current output formatter instance. Overrides OutputInterface:: |
|
Output:: |
public | function |
Gets the current verbosity of the output. Overrides OutputInterface:: |
|
Output:: |
public | function | ||
Output:: |
public | function |
Gets the decorated flag. Overrides OutputInterface:: |
|
Output:: |
public | function | ||
Output:: |
public | function | ||
Output:: |
public | function | ||
Output:: |
public | function |
Writes a message to the output. Overrides OutputInterface:: |
|
Output:: |
public | function |
Writes a message to the output and adds a newline at the end. Overrides OutputInterface:: |
|
OutputInterface:: |
constant | |||
OutputInterface:: |
constant | |||
OutputInterface:: |
constant | |||
OutputInterface:: |
constant | |||
OutputInterface:: |
constant | |||
OutputInterface:: |
constant | |||
OutputInterface:: |
constant | |||
OutputInterface:: |
constant | |||
StreamOutput:: |
private | property | ||
StreamOutput:: |
protected | function |
Writes a message to the output. Overrides Output:: |
|
StreamOutput:: |
public | function | Gets the stream attached to this StreamOutput instance. | |
StreamOutput:: |
protected | function | Returns true if the stream supports colorization. |