Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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