@@ -43,14 +43,12 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
43
43
*/
44
44
public function __construct ($ verbosity = self ::VERBOSITY_NORMAL , $ decorated = null , OutputFormatterInterface $ formatter = null )
45
45
{
46
- $ outputStream = 'php://stdout ' ;
47
- if (!$ this ->hasStdoutSupport ()) {
48
- $ outputStream = 'php://output ' ;
49
- }
46
+ $ outputStream = $ this ->hasStdoutSupport () ? 'php://stdout ' : 'php://output ' ;
47
+ $ errorStream = $ this ->hasStderrSupport () ? 'php://stderr ' : 'php://output ' ;
50
48
51
49
parent ::__construct (fopen ($ outputStream , 'w ' ), $ verbosity , $ decorated , $ formatter );
52
50
53
- $ this ->stderr = new StreamOutput (fopen (' php://stderr ' , 'w ' ), $ verbosity , $ decorated , $ this ->getFormatter ());
51
+ $ this ->stderr = new StreamOutput (fopen ($ errorStream , 'w ' ), $ verbosity , $ decorated , $ this ->getFormatter ());
54
52
}
55
53
56
54
/**
@@ -100,14 +98,32 @@ public function setErrorOutput(OutputInterface $error)
100
98
* Returns true if current environment supports writing console output to
101
99
* STDOUT.
102
100
*
103
- * IBM iSeries (OS400) exhibits character-encoding issues when writing to
104
- * STDOUT and doesn't properly convert ASCII to EBCDIC, resulting in garbage
105
- * output.
106
- *
107
101
* @return bool
108
102
*/
109
103
protected function hasStdoutSupport ()
110
104
{
111
- return ('OS400 ' != php_uname ('s ' ));
105
+ return false === $ this ->isRunningOS400 ();
106
+ }
107
+
108
+ /**
109
+ * Returns true if current environment supports writing console output to
110
+ * STDERR.
111
+ *
112
+ * @return bool
113
+ */
114
+ protected function hasStderrSupport ()
115
+ {
116
+ return false === $ this ->isRunningOS400 ();
117
+ }
118
+
119
+ /**
120
+ * Checks if current executing environment is IBM iSeries (OS400), which
121
+ * doesn't properly convert character-encodings between ASCII to EBCDIC.
122
+ *
123
+ * @return bool
124
+ */
125
+ private function isRunningOS400 ()
126
+ {
127
+ return 'OS400 ' === php_uname ('s ' );
112
128
}
113
129
}
0 commit comments