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