TYPO3  7.6
vendor/symfony/console/Output/ConsoleOutput.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Symfony\Component\Console\Output;
13 
15 
32 {
36  private $stderr;
37 
47  public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
48  {
49  parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
50 
51  $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
52  }
53 
57  public function setDecorated($decorated)
58  {
59  parent::setDecorated($decorated);
60  $this->stderr->setDecorated($decorated);
61  }
62 
67  {
68  parent::setFormatter($formatter);
69  $this->stderr->setFormatter($formatter);
70  }
71 
75  public function setVerbosity($level)
76  {
77  parent::setVerbosity($level);
78  $this->stderr->setVerbosity($level);
79  }
80 
84  public function getErrorOutput()
85  {
86  return $this->stderr;
87  }
88 
92  public function setErrorOutput(OutputInterface $error)
93  {
94  $this->stderr = $error;
95  }
96 
103  protected function hasStdoutSupport()
104  {
105  return false === $this->isRunningOS400();
106  }
107 
114  protected function hasStderrSupport()
115  {
116  return false === $this->isRunningOS400();
117  }
118 
125  private function isRunningOS400()
126  {
127  return 'OS400' === php_uname('s');
128  }
129 
133  private function openOutputStream()
134  {
135  $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
136 
137  return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
138  }
139 
143  private function openErrorStream()
144  {
145  $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
146 
147  return fopen($errorStream, 'w');
148  }
149 }