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

StreamOutput.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 3.27 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\Exception\RuntimeException;
 016  use Symfony\Component\Console\Formatter\OutputFormatterInterface;
 017   
 018  /**
 019   * StreamOutput writes the output to a given stream.
 020   *
 021   * Usage:
 022   *
 023   * $output = new StreamOutput(fopen('php://stdout', 'w'));
 024   *
 025   * As `StreamOutput` can use any stream, you can also use a file:
 026   *
 027   * $output = new StreamOutput(fopen('/path/to/output.log', 'a', false));
 028   *
 029   * @author Fabien Potencier <fabien@symfony.com>
 030   */
 031  class StreamOutput extends Output
 032  {
 033      private $stream;
 034   
 035      /**
 036       * Constructor.
 037       *
 038       * @param resource                      $stream    A stream resource
 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       * @throws InvalidArgumentException When first argument is not a real stream
 044       */
 045      public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
 046      {
 047          if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) {
 048              throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
 049          }
 050   
 051          $this->stream = $stream;
 052   
 053          if (null === $decorated) {
 054              $decorated = $this->hasColorSupport();
 055          }
 056   
 057          parent::__construct($verbosity, $decorated, $formatter);
 058      }
 059   
 060      /**
 061       * Gets the stream attached to this StreamOutput instance.
 062       *
 063       * @return resource A stream resource
 064       */
 065      public function getStream()
 066      {
 067          return $this->stream;
 068      }
 069   
 070      /**
 071       * {@inheritdoc}
 072       */
 073      protected function doWrite($message, $newline)
 074      {
 075          if (false === @fwrite($this->stream, $message) || ($newline && (false === @fwrite($this->stream, PHP_EOL)))) {
 076              // should never happen
 077              throw new RuntimeException('Unable to write output.');
 078          }
 079   
 080          fflush($this->stream);
 081      }
 082   
 083      /**
 084       * Returns true if the stream supports colorization.
 085       *
 086       * Colorization is disabled if not supported by the stream:
 087       *
 088       *  -  Windows != 10.0.10586 without Ansicon, ConEmu or Mintty
 089       *  -  non tty consoles
 090       *
 091       * @return bool true if the stream supports colorization, false otherwise
 092       */
 093      protected function hasColorSupport()
 094      {
 095          if (DIRECTORY_SEPARATOR === '\\') {
 096              return
 097                  '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD
 098                  || false !== getenv('ANSICON')
 099                  || 'ON' === getenv('ConEmuANSI')
 100                  || 'xterm' === getenv('TERM');
 101          }
 102   
 103          return function_exists('posix_isatty') && @posix_isatty($this->stream);
 104      }
 105  }
 106