Read stream content to output array

@param resource $stream Stream resource
@param array $output
548896
protected function readStream(&$stream, &$output) {
    $content = stream_get_contents($stream);
    if (strlen(rtrim($content))) {
      foreach (preg_split('/\r?\n/', $content) as $line) {
        $output[] = $line;
      }
    }
  }
600785
private function copyToOutputAndCleanup($output, $zipFileUrl)
    {
        $zipFilePointer = fopen($zipFileUrl, 'r');
        if (!stream_copy_to_stream($zipFilePointer, $output)
            || !fclose($zipFilePointer)
            || !fclose($output)
            || !unlink($zipFileUrl)
        ) {
            throw new \RuntimeException("Failed to copy stream and clean up!");
        }
    }
1355937
public function readBinaryStream($stream)
    {
        if (($str = stream_get_contents($stream)) === false || empty($str)) {
            throw new PListException("Error reading stream!");
        }

        $this->parseBinary($str);
    }
1304407
public function parse($resource, $output)
    {
        printf('file %s' . PHP_EOL, $resource);

        $pathinfo = pathinfo($resource);
        $extension = $pathinfo['extension'];

        $this->environment->setSourceFile($resource);

        $parser = $this->configuration->getParserForFileExtension($extension);

        if (!$parser instanceof ParserInterface) {
            throw new \Exception('No parser found. Have you initialized any plugins?');
        }

        if ($parser instanceof HasEnvironmentInterface) {
            $parser->setEnvironment($this->environment);
        }

        $content = $parser->parse($resource);
        $output  = $parser->getOutputFilename($output);
        file_put_contents($output, $content);
    }
728219
public function addReadStream($stream, $listener)
    {
        $key = (int) $stream;

        $this->streamsRead[$key] = $stream;
        $this->streamsDuplex[$key] = $stream;

        GlobalState::set('eventloop.streams.read.current', count($this->streamsRead));
        GlobalState::set('eventloop.streams.total.current', count($this->streamsDuplex));
        GlobalState::incr('eventloop.streams.read.total');
        if (!isset($this->streamsWrite[$key])) {
            GlobalState::incr('eventloop.streams.total.total');
        }

        $this->loop->addReadStream($stream, function ($stream) use ($listener) {
            GlobalState::incr('eventloop.streams.read.ticks');
            GlobalState::incr('eventloop.streams.total.ticks');

            $listener($stream, $this);
        });
    }
1017625
protected function printMessage(OutputInterface $output, array $response)
    {
        $this->printBoolean($output, $response['message'], $response['message'], true === $response['success']);
    }
640751
public static void writeToOutputStream(String s, OutputStream output) throws IOException {
		writeToOutputStream(s, output, null);
	}
355294
public function sendOutput(String $output, String $colour='white', String $backgroundColor='black')
	{
		fwrite(STDOUT, $this->getText($output, $colour, $backgroundColor));
	}
274750
private static function initializeOutputStreams()
    {
        if (self::$out === null) {
            if (!defined('STDOUT')) {
                self::$out = new OutputStream(fopen('php://stdout', 'w'));
            } else {
                self::$out = new OutputStream(STDOUT);
            }
        }
        if (self::$err === null) {
            if (!defined('STDERR')) {
                self::$err = new OutputStream(fopen('php://stderr', 'w'));
            } else {
                self::$err = new OutputStream(STDERR);
            }
        }
    }
659000
public function initFromStream($stream)
    {
        if (!$stream instanceof StreamInterface) {
            $stream = new Stream($stream);
        }

        try {
            $offset = $stream->tell();
        } catch (\RuntimeException $e) {
            $offset = 0;
        }

        $shouldAndCanSeek = $offset !== 0 && $stream->isSeekable();

        if ($shouldAndCanSeek) {
            $stream->rewind();
        }

        try {
            $data = $stream->getContents();
        } catch (\RuntimeException $e) {
            $data = null;
        }

        if ($shouldAndCanSeek) {
            $stream->seek($offset);
        }

        if ($data) {
            return $this->initFromBinary($data);
        }

        throw new \Intervention\Image\Exception\NotReadableException(
            "Unable to init from given stream"
        );
    }
1060943
private void copyToStream(String txt, OutputStream stream) throws IOException {
        if (txt != null) {
            stream.write(txt.getBytes());
        }
    }
400151
public function write($output)
    {
        //lets parse the file
        if ($this->_hasBeenModified($this->_file) || !file_exists($output)) {
            //get the data
            file_put_contents($output, $this->getData());
            //update the timestamp
            $this->_cache_data['timestamp'] = time();
            file_put_contents($this->_cache_file, serialize($this->_cache_data));
        }
    }
245527
protected function outputFileCreation(array &$output)
    {
        if (file_exists($this->filename)) {
            $output[] = ['status' => 'ok', 'operation' => 'overwriting', 'file' => $this->filename];
        } else {
            $output[] = ['status' => 'ok', 'operation' => 'creating', 'file' => $this->filename];
        }

        return $this;
    }
511687
def output(stream):
    """"""
    while True:
        content = stream.read(1024)
        if len(content) == 0: break
        sys.stdout.write(content)
562842
public function writeStream(Stream $stream, Stream $value, $length = null)
    {
        if ($length === null) {
            $length = $value->getSize();
        }

        $stream->writeStream($value, $length);
    }
681855
protected function _populateOutput(array &$output, $key, $value) {
        if (strpos($key, '.') === false) {
            $output[$key] = $value;
            return;
        }
        $array = Garp_Util_String::toArray($key, '.', $value);
        $output += $array;
    }
1154671
@Deprecated // replace with StreamUtil.copyContentIntoOutputStream()
    private static void copyStream(InputStream input, OutputStream output) throws IOException {
        byte[] buffer = new byte[BUFFER_SIZE];
        int len;
        while ((len = input.read(buffer)) != -1) {
            output.write(buffer, 0, len);
        }
    }