@param Stream $stream

@return array
14067
private function parseReturnExpr(Stream $stream)
    {
        $stream->expects(Token::TYPE_SYMBOL, '->');

        $expr = $stream->expects(Token::TYPE_IDENTIFIER)->getValue();

        if ($stream->current()->is(Token::TYPE_IDENTIFIER)) {
            $field = $stream->expects(Token::TYPE_IDENTIFIER)->getValue();
        } elseif ($stream->current()->equals(Token::TYPE_SYMBOL, '*')) {
            $stream->expects(Token::TYPE_SYMBOL, '*');

            $field = null;
        } else {
            return [
                'expr' => $expr,
                'field' => null,
                'type' => null,
            ];
        }

        if ($stream->current()->equals(Token::TYPE_SYMBOL, ':')) {
            $stream->expects(Token::TYPE_SYMBOL, ':');

            $type = $this->parseTypeIdentifier($stream);
        } else {
            $type = null;
        }

        return [
            'expr' => $expr,
            'field' => $field,
            'type' => $type,
        ];
    }
160546
public function hasStream($stream)
    {
        $isInputStream = $stream == $this->getInputStream();
        $isOutputStream = $stream == $this->getOutputStream();
        $isErrStream = $stream == $this->getErrorStream();

        return $isInputStream || $isOutputStream || $isErrStream;
    }
29265
protected function decryptResponse(StreamInterface $response): array
    {
        parse_str($response->getContents(), $responseHeader);

        $decryptedResponseHeader = $this
            ->computopApiService
            ->decryptResponseHeader($responseHeader, $this->config->getBlowfishPass());

        return $decryptedResponseHeader;
    }
840749
public function parse(AbstractStream $stream)
    {
        $value = $this->format($this->read($stream));
        $this->validate($value);
        return $value;
    }
45304
public function read($path)
    {
        if ($response = $this->readStream($path)) {
            return ['contents' => stream_get_contents($response['stream']), 'path' => $response['path']];
        }

        return false;
    }
510626
public function initFromStream($stream)
    {
        $stream = Factory::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 Exception\NotReadableException(
            "Unable to init from given stream"
        );
    }
760739
public function readStream($path)
    {
        try {
            $temporaryUrl = $this->getTemporaryUrl($path, Carbon::now()->addMinutes(5));

            $stream = $this->getHttpClient()
                           ->get($temporaryUrl, ['stream' => true])
                           ->getBody()
                           ->detach();

            return ['stream' => $stream];
        } catch (NoSuchKeyException $e) {
            return false;
        } catch (\GuzzleHttp\Exception\ClientException $e) {
            return false;
        }
    }
889067
public function toStream($stream)
    {
        $bytesWritten = 0;
        foreach ($this->getChunkCursor() as $chunk) {
            $bytesWritten += fwrite($stream, $chunk['data']->getData());
        }
        return $bytesWritten;
    }
1342473
public function getRaw($stream = true)
    {
        if ($stream) {
            $hdr = new Horde_Stream();
            $hdr->add($this->_headers->toString(), true);
            return Horde_Stream_Wrapper_Combine::getStream(
                array($hdr->stream,
                      $this->getBasePart()->toString(
                        array('stream' => true, 'encode' => Horde_Mime_Part::ENCODE_7BIT | Horde_Mime_Part::ENCODE_8BIT | Horde_Mime_Part::ENCODE_BINARY))
                )
            );
        }

        return $this->_headers->toString() . $this->getBasePart()->toString();
    }
741716
private function parseType(Stream $stream)
    {
        if ($stream->current()->equals(Token::TYPE_KEYWORD, 'export')) {
            $stream->expects(Token::TYPE_KEYWORD, 'export');

            $isExported = true;
        } else {
            $isExported = false;
        }

        $stream->expects(Token::TYPE_KEYWORD, 'type');

        $typeName = $this->parseTypeIdentifier($stream);

        if ($isExported) {
            $nodes = [new MapperExportNode($typeName)];
        } else {
            $nodes = [];
        }

        if ($stream->current()->equals(Token::TYPE_KEYWORD, 'extends')) {
            $stream->expects(Token::TYPE_KEYWORD, 'extends');

            $parentTypeName = $this->parseTypeIdentifier($stream);
        } else {
            $parentTypeName = null;
        }

        $stream->expects(Token::TYPE_SYMBOL, '{');

        $definition = $this->parseTypeDefinition($stream);

        $stream->expects(Token::TYPE_SYMBOL, '}');
        $stream->expects(Token::TYPE_SYMBOL, ';');

        if (isset($definition['mapping'])) {
            if ($parentTypeName !== null) {
                array_unshift($nodes, new ExtendCompositeTypeNode($parentTypeName, $typeName, $definition));
            } else {
                array_unshift($nodes, new SetCompositeTypeNode($typeName, $definition));
            }
        } else {
            if ($parentTypeName !== null) {
                array_unshift($nodes, new ExtendTypeNode($parentTypeName, $typeName, $definition));
            } else {
                array_unshift($nodes, new SetTypeNode($typeName, $definition));
            }
        }

        return $nodes;
    }
886588
private function parseImportList(Stream $stream)
    {
        $list = [];

        do {
            $resource = $this->parseIdentifier($stream);

            if ($stream->current()->equals(Token::TYPE_KEYWORD, 'as')) {
                $stream->expects(Token::TYPE_KEYWORD, 'as');

                $alias = $this->parseIdentifier($stream);
            } else {
                $alias = $resource;
            }

            $list[$resource] = $alias;
        } while ($stream->current()->equals(Token::TYPE_SYMBOL, ',') && $stream->expects(Token::TYPE_SYMBOL, ','));

        return $list;
    }
488949
public function readStream($path)
    {
        $location = $this->applyPathPrefix($path);
        $resource = ($this->ossClient->isUseSSL() ? 'https://' : 'http://') . $this->bucket . '.' . $this->endpoint . '/' . $location;
        return [
            'stream' => $resource = fopen($resource, 'r')
        ];
    }
1265386
public function readStream($path) {
        $mapping = $this->mapper->get($path);

        if (!$mapping) {
            return false;
        }

        try {
            $file = $this->client->get($mapping['fid']);

            if (!$file) {
                return false;
            }

            return [
                'stream' => $file
            ];
        } catch (SeaweedFSException $e) {
            return false;
        }
    }
1173375
protected function getStreamAsFile($stream)
    {
        // Get temporary file and name
        $file = tempnam(sys_get_temp_dir(), 'ssflysystem');
        $buffer = fopen($file, 'w');
        if (!$buffer) {
            throw new FlysystemException("Could not create temporary file");
        }

        // Transfer from given stream
        Util::rewindStream($stream);
        stream_copy_to_stream($stream, $buffer);
        if (!fclose($buffer)) {
            throw new FlysystemException("Could not write stream to temporary file");
        }

        return $file;
    }
1093684
public function readSFixed64(Stream $stream)
    {
        $bytes = $stream->read(8);

        list(, $lo0, $lo1, $hi0, $hi1) = unpack('v*', $bytes);

        return ($hi1 << 16 | $hi0) << 32 | ($lo1 << 16 | $lo0);
    }
473478
public static function deserialize(StreamInterface $stream)
    {
        $rsp = $stream->readLine();

        list($type, $result) = [$rsp[0], trim(substr($rsp, 1, strlen($rsp)))];

        switch ($type) {
            case '-': // ERRORS
                throw new CommandException($result);

            case '+': // SIMPLE STRINGS
                return $result;

            case ':': // INTEGERS
                return (int) $result;

            case '$': // BULK STRINGS
                $result = (int) $result;

                if ($result == -1) {
                    return null;
                }

                return trim($stream->readBytes($result + 2));

            case '*': // ARRAYS
                $cnt = (int)$result;
                $out = [];

                for ($i = 0; $i < $cnt; $i++) {
                    $out[] = static::deserialize($stream);
                }

                return $out;

            default:
                throw new \RuntimeException('unhandled protocol response: '.$rsp);
        }
    }
1059855
public function supportsExpr(Stream $stream)
    {
        $token = $stream->current();

        return !$token->is(Token::TYPE_KEYWORD) && ($token->is(Token::TYPE_STRING) || $token->is(Token::TYPE_NUMBER) || $token->is(Token::TYPE_CONSTANT) || $token->is(Token::TYPE_IDENTIFIER) || $token->equals(Token::TYPE_SYMBOL, '{') || $token->equals(Token::TYPE_SYMBOL, '['));
    }