Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

ConsoleOutput.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 3.91 KiB


001  <?php
002   
003  /*
004   * This file is part of the Symfony package.
005   *
006   * (c) Fabien Potencier <fabien@symfony.com>
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace Symfony\Component\Console\Output;
013   
014  use Symfony\Component\Console\Formatter\OutputFormatterInterface;
015   
016  /**
017   * ConsoleOutput is the default class for all CLI output. It uses STDOUT and STDERR.
018   *
019   * This class is a convenient wrapper around `StreamOutput` for both STDOUT and STDERR.
020   *
021   *     $output = new ConsoleOutput();
022   *
023   * This is equivalent to:
024   *
025   *     $output = new StreamOutput(fopen('php://stdout', 'w'));
026   *     $stdErr = new StreamOutput(fopen('php://stderr', 'w'));
027   *
028   * @author Fabien Potencier <fabien@symfony.com>
029   */
030  class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
031  {
032      private $stderr;
033   
034      /**
035       * @param int                           $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface)
036       * @param bool|null                     $decorated Whether to decorate messages (null for auto-guessing)
037       * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
038       */
039      public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
040      {
041          parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
042   
043          $actualDecorated = $this->isDecorated();
044          $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
045   
046          if (null === $decorated) {
047              $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
048          }
049      }
050   
051      /**
052       * {@inheritdoc}
053       */
054      public function setDecorated($decorated)
055      {
056          parent::setDecorated($decorated);
057          $this->stderr->setDecorated($decorated);
058      }
059   
060      /**
061       * {@inheritdoc}
062       */
063      public function setFormatter(OutputFormatterInterface $formatter)
064      {
065          parent::setFormatter($formatter);
066          $this->stderr->setFormatter($formatter);
067      }
068   
069      /**
070       * {@inheritdoc}
071       */
072      public function setVerbosity($level)
073      {
074          parent::setVerbosity($level);
075          $this->stderr->setVerbosity($level);
076      }
077   
078      /**
079       * {@inheritdoc}
080       */
081      public function getErrorOutput()
082      {
083          return $this->stderr;
084      }
085   
086      /**
087       * {@inheritdoc}
088       */
089      public function setErrorOutput(OutputInterface $error)
090      {
091          $this->stderr = $error;
092      }
093   
094      /**
095       * Returns true if current environment supports writing console output to
096       * STDOUT.
097       *
098       * @return bool
099       */
100      protected function hasStdoutSupport()
101      {
102          return false === $this->isRunningOS400();
103      }
104   
105      /**
106       * Returns true if current environment supports writing console output to
107       * STDERR.
108       *
109       * @return bool
110       */
111      protected function hasStderrSupport()
112      {
113          return false === $this->isRunningOS400();
114      }
115   
116      /**
117       * Checks if current executing environment is IBM iSeries (OS400), which
118       * doesn't properly convert character-encodings between ASCII to EBCDIC.
119       *
120       * @return bool
121       */
122      private function isRunningOS400()
123      {
124          $checks = [
125              \function_exists('php_uname') ? php_uname('s') : '',
126              getenv('OSTYPE'),
127              \PHP_OS,
128          ];
129   
130          return false !== stripos(implode(';', $checks), 'OS400');
131      }
132   
133      /**
134       * @return resource
135       */
136      private function openOutputStream()
137      {
138          if (!$this->hasStdoutSupport()) {
139              return fopen('php://output', 'w');
140          }
141   
142          return @fopen('php://stdout', 'w') ?: fopen('php://output', 'w');
143      }
144   
145      /**
146       * @return resource
147       */
148      private function openErrorStream()
149      {
150          return fopen($this->hasStderrSupport() ? 'php://stderr' : 'php://output', 'w');
151      }
152  }
153