12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- /*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Symfony\Component\Console\Output;
- use Symfony\Component\Console\Formatter\OutputFormatterInterface;
- /**
- * 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>
- *
- * @api
- */
- class ConsoleOutput extends StreamOutput
- {
- /**
- * Constructor.
- *
- * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL,
- * self::VERBOSITY_VERBOSE)
- * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing)
- * @param OutputFormatter $formatter Output formatter instance
- *
- * @api
- */
- public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
- {
- $outputStream = 'php://stdout';
- if (!$this->hasStdoutSupport()) {
- $outputStream = 'php://output';
- }
- parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter);
- }
- /**
- * Returns true if current environment supports writing console output to
- * STDOUT.
- *
- * IBM iSeries (OS400) exhibits character-encoding issues when writing to
- * STDOUT and doesn't properly convert ASCII to EBCDIC, resulting in garbage
- * output.
- *
- * @return boolean
- */
- protected function hasStdoutSupport()
- {
- return ('OS400' != php_uname('s'));
- }
- }
|