Skip to content

Commit

Permalink
merged 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 11, 2012
2 parents 8169674 + 754671f commit ec3d45f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Application.php
Expand Up @@ -746,7 +746,7 @@ public function asXml($namespace = null, $asDom = false)
}

/**
* Renders a catched exception.
* Renders a caught exception.
*
* @param Exception $e An exception instance
* @param OutputInterface $output An OutputInterface instance
Expand Down
23 changes: 22 additions & 1 deletion Output/ConsoleOutput.php
Expand Up @@ -46,7 +46,13 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
*/
public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
{
parent::__construct(fopen('php://stdout', 'w'), $verbosity, $decorated, $formatter);
$outputStream = 'php://stdout';
if (!$this->hasStdoutSupport()) {
$outputStream = 'php://output';
}

parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter);

$this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $formatter);
}

Expand Down Expand Up @@ -80,4 +86,19 @@ public function setErrorOutput(OutputInterface $error)
{
$this->stderr = $error;
}

/**
* Returns true if current environment supports writing console output to
* STDOUT.
*
* IBM iSeries (OS400) exhibits character-encoding issues when writing to
* STDOUT and doesn't properly convert ASCII to EBCDIC, resulting in garbage
* output.
*
* @return boolean
*/
protected function hasStdoutSupport()
{
return ('OS400' != php_uname('s'));
}
}

0 comments on commit ec3d45f

Please sign in to comment.