Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • ConsoleOutput
  • NullOutput
  • Output
  • StreamOutput

Interfaces

  • ConsoleOutputInterface
  • OutputInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
  1: <?php
  2: 
  3: /*
  4:  * This file is part of the Symfony package.
  5:  *
  6:  * (c) Fabien Potencier <fabien@symfony.com>
  7:  *
  8:  * For the full copyright and license information, please view the LICENSE
  9:  * file that was distributed with this source code.
 10:  */
 11: 
 12: namespace Symfony\Component\Console\Output;
 13: 
 14: use Symfony\Component\Console\Formatter\OutputFormatterInterface;
 15: use Symfony\Component\Console\Output\ConsoleOutputInterface;
 16: 
 17: /**
 18:  * ConsoleOutput is the default class for all CLI output. It uses STDOUT.
 19:  *
 20:  * This class is a convenient wrapper around `StreamOutput`.
 21:  *
 22:  *     $output = new ConsoleOutput();
 23:  *
 24:  * This is equivalent to:
 25:  *
 26:  *     $output = new StreamOutput(fopen('php://stdout', 'w'));
 27:  *
 28:  * @author Fabien Potencier <fabien@symfony.com>
 29:  *
 30:  * @api
 31:  */
 32: class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
 33: {
 34:     private $stderr;
 35: 
 36:     /**
 37:      * Constructor.
 38:      *
 39:      * @param integer                  $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL,
 40:      *                                                                 self::VERBOSITY_VERBOSE)
 41:      * @param Boolean                  $decorated Whether to decorate messages or not (null for auto-guessing)
 42:      * @param OutputFormatterInterface $formatter Output formatter instance
 43:      *
 44:      * @api
 45:      */
 46:     public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
 47:     {
 48:         $outputStream = 'php://stdout';
 49:         if (!$this->hasStdoutSupport()) {
 50:             $outputStream = 'php://output';
 51:         }
 52: 
 53:         parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter);
 54: 
 55:         $this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $formatter);
 56:     }
 57: 
 58:     public function setDecorated($decorated)
 59:     {
 60:         parent::setDecorated($decorated);
 61:         $this->stderr->setDecorated($decorated);
 62:     }
 63: 
 64:     public function setFormatter(OutputFormatterInterface $formatter)
 65:     {
 66:         parent::setFormatter($formatter);
 67:         $this->stderr->setFormatter($formatter);
 68:     }
 69: 
 70:     public function setVerbosity($level)
 71:     {
 72:         parent::setVerbosity($level);
 73:         $this->stderr->setVerbosity($level);
 74:     }
 75: 
 76:     /**
 77:      * @return OutputInterface
 78:      */
 79:     public function getErrorOutput()
 80:     {
 81:         return $this->stderr;
 82:     }
 83: 
 84:     public function setErrorOutput(OutputInterface $error)
 85:     {
 86:         $this->stderr = $error;
 87:     }
 88: 
 89:     /**
 90:      * Returns true if current environment supports writing console output to
 91:      * STDOUT.
 92:      *
 93:      * IBM iSeries (OS400) exhibits character-encoding issues when writing to
 94:      * STDOUT and doesn't properly convert ASCII to EBCDIC, resulting in garbage
 95:      * output.
 96:      *
 97:      * @return boolean
 98:      */
 99:     protected function hasStdoutSupport()
100:     {
101:         return ('OS400' != php_uname('s'));
102:     }
103: }
104: 
php-coveralls API documentation generated by ApiGen 2.8.0