@@ -46,12 +46,9 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
46
46
*/
47
47
public function __construct ($ verbosity = self ::VERBOSITY_NORMAL , $ decorated = null , OutputFormatterInterface $ formatter = null )
48
48
{
49
- $ outputStream = $ this ->hasStdoutSupport () ? 'php://stdout ' : 'php://output ' ;
50
- $ errorStream = $ this ->hasStderrSupport () ? 'php://stderr ' : 'php://output ' ;
51
-
52
- parent ::__construct (fopen ($ outputStream , 'w ' ), $ verbosity , $ decorated , $ formatter );
49
+ parent ::__construct ($ this ->openOutputStream (), $ verbosity , $ decorated , $ formatter );
53
50
54
- $ this ->stderr = new StreamOutput (fopen ( $ errorStream , ' w ' ), $ verbosity , $ decorated , $ this ->getFormatter ());
51
+ $ this ->stderr = new StreamOutput ($ this -> openErrorStream ( ), $ verbosity , $ decorated , $ this ->getFormatter ());
55
52
}
56
53
57
54
/**
@@ -129,4 +126,24 @@ private function isRunningOS400()
129
126
{
130
127
return 'OS400 ' === php_uname ('s ' );
131
128
}
129
+
130
+ /**
131
+ * @return resource
132
+ */
133
+ private function openOutputStream ()
134
+ {
135
+ $ outputStream = $ this ->hasStdoutSupport () ? 'php://stdout ' : 'php://output ' ;
136
+
137
+ return @fopen ($ outputStream , 'w ' ) ?: fopen ('php://output ' , 'w ' );
138
+ }
139
+
140
+ /**
141
+ * @return resource
142
+ */
143
+ private function openErrorStream ()
144
+ {
145
+ $ errorStream = $ this ->hasStderrSupport () ? 'php://stderr ' : 'php://output ' ;
146
+
147
+ return fopen ($ errorStream , 'w ' );
148
+ }
132
149
}
0 commit comments