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

StreamOutput.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 3.61 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\Exception\InvalidArgumentException;
015  use Symfony\Component\Console\Formatter\OutputFormatterInterface;
016   
017  /**
018   * StreamOutput writes the output to a given stream.
019   *
020   * Usage:
021   *
022   *     $output = new StreamOutput(fopen('php://stdout', 'w'));
023   *
024   * As `StreamOutput` can use any stream, you can also use a file:
025   *
026   *     $output = new StreamOutput(fopen('/path/to/output.log', 'a', false));
027   *
028   * @author Fabien Potencier <fabien@symfony.com>
029   */
030  class StreamOutput extends Output
031  {
032      private $stream;
033   
034      /**
035       * @param resource                      $stream    A stream resource
036       * @param int                           $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface)
037       * @param bool|null                     $decorated Whether to decorate messages (null for auto-guessing)
038       * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
039       *
040       * @throws InvalidArgumentException When first argument is not a real stream
041       */
042      public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
043      {
044          if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
045              throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
046          }
047   
048          $this->stream = $stream;
049   
050          if (null === $decorated) {
051              $decorated = $this->hasColorSupport();
052          }
053   
054          parent::__construct($verbosity, $decorated, $formatter);
055      }
056   
057      /**
058       * Gets the stream attached to this StreamOutput instance.
059       *
060       * @return resource A stream resource
061       */
062      public function getStream()
063      {
064          return $this->stream;
065      }
066   
067      /**
068       * {@inheritdoc}
069       */
070      protected function doWrite($message, $newline)
071      {
072          if ($newline) {
073              $message .= \PHP_EOL;
074          }
075   
076          @fwrite($this->stream, $message);
077   
078          fflush($this->stream);
079      }
080   
081      /**
082       * Returns true if the stream supports colorization.
083       *
084       * Colorization is disabled if not supported by the stream:
085       *
086       * This is tricky on Windows, because Cygwin, Msys2 etc emulate pseudo
087       * terminals via named pipes, so we can only check the environment.
088       *
089       * Reference: Composer\XdebugHandler\Process::supportsColor
090       * https://github.com/composer/xdebug-handler
091       *
092       * @return bool true if the stream supports colorization, false otherwise
093       */
094      protected function hasColorSupport()
095      {
096          if ('Hyper' === getenv('TERM_PROGRAM')) {
097              return true;
098          }
099   
100          if (\DIRECTORY_SEPARATOR === '\\') {
101              return (\function_exists('sapi_windows_vt100_support')
102                  && @sapi_windows_vt100_support($this->stream))
103                  || false !== getenv('ANSICON')
104                  || 'ON' === getenv('ConEmuANSI')
105                  || 'xterm' === getenv('TERM');
106          }
107   
108          if (\function_exists('stream_isatty')) {
109              return @stream_isatty($this->stream);
110          }
111   
112          if (\function_exists('posix_isatty')) {
113              return @posix_isatty($this->stream);
114          }
115   
116          $stat = @fstat($this->stream);
117          // Check if formatted mode is S_IFCHR
118          return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
119      }
120  }
121