[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
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 14 use Symfony\Component\Console\Formatter\OutputFormatterInterface; 15 16 /** 17 * ConsoleOutput is the default class for all CLI output. It uses STDOUT. 18 * 19 * This class is a convenient wrapper around `StreamOutput`. 20 * 21 * $output = new ConsoleOutput(); 22 * 23 * This is equivalent to: 24 * 25 * $output = new StreamOutput(fopen('php://stdout', 'w')); 26 * 27 * @author Fabien Potencier <fabien@symfony.com> 28 */ 29 class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface 30 { 31 private $stderr; 32 33 /** 34 * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) 35 * @param bool|null $decorated Whether to decorate messages (null for auto-guessing) 36 * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) 37 */ 38 public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) 39 { 40 parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter); 41 42 $actualDecorated = $this->isDecorated(); 43 $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter()); 44 45 if (null === $decorated) { 46 $this->setDecorated($actualDecorated && $this->stderr->isDecorated()); 47 } 48 } 49 50 /** 51 * {@inheritdoc} 52 */ 53 public function setDecorated($decorated) 54 { 55 parent::setDecorated($decorated); 56 $this->stderr->setDecorated($decorated); 57 } 58 59 /** 60 * {@inheritdoc} 61 */ 62 public function setFormatter(OutputFormatterInterface $formatter) 63 { 64 parent::setFormatter($formatter); 65 $this->stderr->setFormatter($formatter); 66 } 67 68 /** 69 * {@inheritdoc} 70 */ 71 public function setVerbosity($level) 72 { 73 parent::setVerbosity($level); 74 $this->stderr->setVerbosity($level); 75 } 76 77 /** 78 * {@inheritdoc} 79 */ 80 public function getErrorOutput() 81 { 82 return $this->stderr; 83 } 84 85 /** 86 * {@inheritdoc} 87 */ 88 public function setErrorOutput(OutputInterface $error) 89 { 90 $this->stderr = $error; 91 } 92 93 /** 94 * Returns true if current environment supports writing console output to 95 * STDOUT. 96 * 97 * @return bool 98 */ 99 protected function hasStdoutSupport() 100 { 101 return false === $this->isRunningOS400(); 102 } 103 104 /** 105 * Returns true if current environment supports writing console output to 106 * STDERR. 107 * 108 * @return bool 109 */ 110 protected function hasStderrSupport() 111 { 112 return false === $this->isRunningOS400(); 113 } 114 115 /** 116 * Checks if current executing environment is IBM iSeries (OS400), which 117 * doesn't properly convert character-encodings between ASCII to EBCDIC. 118 * 119 * @return bool 120 */ 121 private function isRunningOS400() 122 { 123 $checks = array( 124 \function_exists('php_uname') ? php_uname('s') : '', 125 getenv('OSTYPE'), 126 PHP_OS, 127 ); 128 129 return false !== stripos(implode(';', $checks), 'OS400'); 130 } 131 132 /** 133 * @return resource 134 */ 135 private function openOutputStream() 136 { 137 $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output'; 138 139 return @fopen($outputStream, 'w') ?: fopen('php://output', 'w'); 140 } 141 142 /** 143 * @return resource 144 */ 145 private function openErrorStream() 146 { 147 $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output'; 148 149 return fopen($errorStream, 'w'); 150 } 151 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |