Return the output to write to

@param  bool $stdErr
@return \Symfony\Component\Console\Output\OutputInterface
341249
private function getOutputToWriteTo($stdErr = false)
    {
        if ($stdErr && $this->output instanceof ConsoleOutputInterface) {
            return $this->output->getErrorOutput();
        }

        return $this->output;
    }
45540
public function write($str) {
        if (feof($this->outputHandle)) {
            trigger_error('Called LogFormatter::write() but file handle was closed.', E_USER_WARNING);
            return;
        }
        fwrite($this->outputHandle, $str);
    }
375130
public function setOutputStreams( $stdout = STDOUT, $stderr = STDERR )
    {
        $this->stdout = $stdout;
        $this->stderr = $stderr;
    }
1146251
def _read_stderr(self):
        
        output = self._decode(self._process.readAllStandardError().data())
        if self._formatter:
            self._formatter.append_message(output, output_format=OutputFormat.ErrorMessageFormat)
        else:
            self.insertPlainText(output)
565486
public function quoter($quoter = null)
    {
        if ($quoter !== null) {
            $this->_quoter = $quoter;
        }
        return $this->_quoter;
    }
1261440
public function stderr($msg, $status = self::STATUS_FAIL)
    {
        $msg = "<strong>".$msg."</strong>";
        $msg = $this->removeColors($msg);
        $msg = $this->replaceEOLs($msg);

        if (defined('STDERR')) {
            fwrite(STDERR, $msg);
        } else {
            echo $msg;
            if (count(\ob_get_status()) !== 0) {
                ob_flush();
            }
        }
        return $this;
    }
1047062
private function doWrite($messages, $newline, $stderr, $verbosity)
    {
        $sfVerbosity = $this->verbosityMap[$verbosity];
        if ($sfVerbosity > $this->output->getVerbosity()) {
            return;
        }

        $this->getOutputToWriteTo($stderr)->write($messages, $newline, $sfVerbosity);
    }
322939
def _redirect_stderr():
    
    sys.stderr.flush()
    stderr_fileno = sys.stderr.fileno()
    orig_stderr = os.dup(stderr_fileno)
    devnull = os.open(os.devnull, os.O_WRONLY)
    os.dup2(devnull, stderr_fileno)
    os.close(devnull)
    return orig_stderr
28958
def get_simple_output(self, stderr=STDOUT):
        
        args = shlex.split(self.cmd)
        proc = Popen(args, stdout=PIPE, stderr=stderr)
        return proc.communicate()[0].decode("utf8")
141287
public static function strtoupper($str, bool $strict=false) {
		ref\mb::strtoupper($str, $strict);
		return $str;
	}
190291
protected function getOutputByType($type)
    {
        switch ($type) {
            case 'stderr':
                $actual = $this->process->getErrorOutput();
                break;

            case 'all':
                $actual = $this->process->getOutput() . $this->process->getErrorOutput();
                break;

            case 'stdout':
            default:
                $actual = $this->process->getOutput();
                break;
        }

        return $actual;
    }
319094
protected function write()
    {
        if (!isset($this->pipes[0])) {
            return;
        }
        $input = $this->input;

        if ($input instanceof \Iterator) {
            if (!$input->valid()) {
                $input = null;
            } elseif (is_resource($input = $input->current())) {
                stream_set_blocking($input, 0);
            } elseif (!isset($this->inputBuffer[0])) {
                if (!is_string($input)) {
                    if (!is_scalar($input)) {
                        throw new InvalidArgumentException(sprintf('%s yielded a value of type "%s", but only scalars and stream resources are supported', get_class($this->input), gettype($input)));
                    }
                    $input = (string) $input;
                }
                $this->inputBuffer = $input;
                $this->input->next();
                $input = null;
            } else {
                $input = null;
            }
        }

        $r = $e = array();
        $w = array($this->pipes[0]);

        // let's have a look if something changed in streams
        if (false === $n = @stream_select($r, $w, $e, 0, 0)) {
            return;
        }

        foreach ($w as $stdin) {
            if (isset($this->inputBuffer[0])) {
                $written = fwrite($stdin, $this->inputBuffer);
                $this->inputBuffer = substr($this->inputBuffer, $written);
                if (isset($this->inputBuffer[0])) {
                    return array($this->pipes[0]);
                }
            }

            if ($input) {
                for (;;) {
                    $data = fread($input, self::CHUNK_SIZE);
                    if (!isset($data[0])) {
                        break;
                    }
                    $written = fwrite($stdin, $data);
                    $data = substr($data, $written);
                    if (isset($data[0])) {
                        $this->inputBuffer = $data;

                        return array($this->pipes[0]);
                    }
                }
                if (feof($input)) {
                    if ($this->input instanceof \Iterator) {
                        $this->input->next();
                    } else {
                        $this->input = null;
                    }
                }
            }
        }

        // no input to read on resource, buffer is empty
        if (!isset($this->inputBuffer[0]) && !($this->input instanceof \Iterator ? $this->input->valid() : $this->input)) {
            $this->input = null;
            fclose($this->pipes[0]);
            unset($this->pipes[0]);
        } elseif (!$w) {
            return array($this->pipes[0]);
        }
    }
967755
public function render(ResultsRenderer $renderer)
    {
        $results = array_filter($this->result->getResults(), function (ResultInterface $result) {
            return $result instanceof FailureInterface;
        });

        $output = '';
        if (count($results)) {
            $output .= $renderer->center("Some requests to your solution produced incorrect output!\n");
        }

        foreach ($results as $key => $request) {
            $output .= $renderer->lineBreak();
            $output .= "\n";
            $output .= $renderer->style(sprintf('Request %d', $key + 1), ['bold', 'underline', 'blue']);
            $output .= ' ' . $renderer->style(' FAILED ', ['bg_red', 'bold']) . "\n\n";
            $output .= "Request Details:\n\n";
            $output .= $this->requestRenderer->renderRequest($request->getRequest()) . "\n";

            $output .= $renderer->renderResult($request) . "\n";
        }

        return $output;
    }
1262947
public static function stderr($text, $raw = false)
    {
        if ($raw) {
            return fwrite(STDERR, $text);
        } elseif (extension_loaded('posix') && posix_isatty(STDERR)) {
            return fwrite(STDERR, static::colorize($text));
        } else {
            return fwrite(STDERR, static::decolorize($text));
        }
    }
419696
protected function exec()
    {
        $descriptors = [
           0 => ["pipe", "r"],  // stdin is a pipe that the child will read from
           1 => ["pipe", "w"],  // stdout is a pipe that the child will write to
           2 => ["pipe", "w"] // stderr is a file to write to
        ];
        
        $process = proc_open($this->getCommand(), $descriptors, $pipes, dirname($this->getJarPath()), []);

        if (is_resource($process)) {
            fclose($pipes[0]); // close stdin pipe
            $this->output = stream_get_contents($pipes[1]);
            $this->errors = stream_get_contents($pipes[2]);
            fclose($pipes[2]);
            fclose($pipes[1]);                       
            if(proc_close($process) === -1) {
                throw new RuntimeException($this->errors);
            }
        }            
    }
60242
public function output($output) {
		return fwrite($this->output, Text::insert($output, $this->styles()));
	}
1054085
def writer(self, outputs, stdout, stderr=sys.stderr):
        
        for output in outputs:
            try:
                output = flatten(output)
                if self.data_interchange_format == "json":
                    # Only dump one json string, and skip another one, maybe key or value.
                    output = filter(lambda x: x, output)
                else:
                    # JSON is already serialized, so we put `self.serialize` in a else statement.
                    output = map(self.serialize, output)
                print("\t".join(output), file=stdout)
            except BaseException:
                print(output, file=stderr)
                raise