@param Stream $stream

@return string
501098
private function parseTypeAlias(Stream $stream)
    {
        $alias = $this->parseTypeIdentifier($stream);

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

            $alias = sprintf('%s[]', $alias);
        }

        return $alias;
    }
651158
public function parseCondition(Stream $stream)
    {
        $expr = $this->parseExpr($stream);

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

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

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

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

        $expr = new EqualsNode($expr, $this->parseExpr($stream));

        if ($not === true) {
            $expr = new UnaryPrefixOperatorNode('!', new GroupNode($expr));
        }

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

            $expr = new BinaryInfixOperatorNode('&&', $expr, $this->parseCondition($stream));
        }

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

            $expr = new BinaryInfixOperatorNode('||', $expr, $this->parseCondition($stream));
        }

        return $expr;
    }
1152579
protected function isStreamReadable($stream)
    {
        if (empty($stream)) {
            return false;
        }
        if ($stream instanceof StreamInterface) {
            return $stream->isReadable();
        }

        // Ensure resource is stream type
        if (!is_resource($stream)) {
            return false;
        }
        if (get_resource_type($stream) !== 'stream') {
            return false;
        }

        // Ensure stream is readable
        $meta = stream_get_meta_data($stream);
        return isset($meta['mode']) && (strstr($meta['mode'], 'r') || strstr($meta['mode'], '+'));
    }
301373
public function parse($stream, $filename = null)
    {
        $this->stream = $stream;
        $this->filename = $filename;
        $this->variables = array();

        return $this->parseMain();
    }
381679
private function parseHashList(Stream $stream)
    {
        $hash = [];

        do {
            $key = $stream->expects(Token::TYPE_IDENTIFIER)->getValue();

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

            $hash[$key] = $this->parseValue($stream);
        } while ($stream->current()->equals(Token::TYPE_SYMBOL, ',') && $stream->expects(Token::TYPE_SYMBOL, ','));

        return $hash;
    }
66068
private function getMimeType($data, $stream = false) {
		$finfo = finfo_open(FILEINFO_MIME_TYPE);
		$mimetype = $stream ? finfo_buffer($finfo, $data) : finfo_file($finfo, $data);
		finfo_close($finfo);

		return $mimetype;
	}
140165
public function stream_write($data) {
    assert(isset($this->client));
    return $this->client->write($data);
  }
155537
public function compile(Stream $stream)
    {
        // Parse the request
        $request    = CodeGeneratorRequest::fromStream($stream, $this->config);
        $response   = new CodeGeneratorResponse();
        $context    = $this->createContext($request);
        $entities   = $context->getEntities();
        $options    = $context->getOptions();
        $generator  = new Generator($context);

        // whether or not it will renegerate classes with new extensions
        $regenerate   = false;
        $hasExtension = $context->hasProtobufExtension();

        // Run each entity
        foreach ($entities as $key => $entity) {
            $generateImported = $options->getGenerateImported();
            $isFileToGenerate = $entity->isFileToGenerate();

            // Only compile those given to generate, not the imported ones
            if ( ! $generateImported && ! $isFileToGenerate) {
                $this->logger->debug(sprintf('Skipping generation of imported class "%s"', $entity->getClass()));

                continue;
            }

            $this->logger->info(sprintf('Generating class "%s"', $entity->getClass()));

            $generator->visit($entity);

            $file    = new File();
            $path    = $entity->getPath();
            $content = $entity->getContent();

            $file->setName($path);
            $file->setContent($content);

            $response->addFile($file);

            if ($hasExtension && $this->loadEntityClass($entity)) {
                $regenerate = true;
            }
        }

        if ($regenerate) {

            $this->logger->info('Regenerating classes with new extensions');

            $stream->seek(0);

            // Renegerate classes with new extensions
            return $this->compile($stream);
        }

        $this->logger->info('Generation completed.');

        // Finally serialize the response object
        return $response->toStream($this->config);
    }
1158033
public static function fromStream(StreamInterface $stream): Xml
    {
        $xml = new DOMDocument();
        $xml->loadXML($stream->getContents());

        return new static($xml);
    }
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"
        );
    }
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;
    }
377366
public static function getExtBySignature($stream)
    {
        $prefix = strval(bin2hex(mb_strcut($stream, 0, 10)));

        foreach (self::$signatures as $signature => $extension) {
            if (0 === strpos($prefix, strval($signature))) {
                return $extension;
            }
        }

        return '';
    }
891088
private function getStreamHash($stream, $hash = 'md5')
    {
        $hc = hash_init($hash);
        hash_update_stream($hc, $stream);
        return hash_final($hc);
    }
188860
private function parseTypeDefinition(Stream $stream)
    {
        $definition = [];

        while ($stream->peek()->equals(Token::TYPE_SYMBOL, ':')) {
            $field = $this->parseIdentifier($stream);

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

            $type = $this->parseTypeAlias($stream);

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

            $definition['mapping'][$field] = $type;
        }

        while ($stream->peek()->equals(Token::TYPE_SYMBOL, '=')) {
            $name = $stream->expects(Token::TYPE_IDENTIFIER)->getValue();

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

            $value = $this->parseValue($stream);

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

            $definition['options'][$name] = $value;
        }

        return $definition;
    }
974465
public function parse($stream)
    {
        $tokeniser = new StreamTokeniser($this->csvFormat, $stream);
        $parser = new Parser();
        return $this->parseIterator(
            $parser->parse($tokeniser->getTokens())
        );
    }
1341400
public function lexAll(\Jstewmc\Stream\Stream $stream) 
	{
		$tokens = [];
		
		// while tokens exist
		while (false !== ($token = $this->lexOne($stream))) {
			// append le token
			$tokens[] = $token;
		}
		
		return $tokens;
	}
639794
public function getContent($stream = null)
    {
        fseek($this->_fh, $this->_contentPos[0]);
        if ($stream !== null) {
            return stream_copy_to_stream($this->_fh, $stream, $this->_contentPos[1] - $this->_contentPos[0]);
        }
        $length = $this->_contentPos[1] - $this->_contentPos[0];
        return $length < 1 ? '' : fread($this->_fh, $length);
    }