Reads data from the stream.

@return Promise Resolves with the full contents or `null` if the stream has closed / already been consumed.
190158
public function read(): Promise
    {
        if ($this->contents === null) {
            return new Success;
        }

        $promise = new Success($this->contents);
        $this->contents = null;

        return $promise;
    }
468155
public function read()
    {
        if (!$this->isOpen()) {
            $this->open();
        }

        $this->stream = fopen($this->lock_filename, 'r');

        $content = stream_get_contents($this->stream);

        $this->close();

        return $content;
    }
744510
public function stream_eof()
    {
        return $this->_download !== null
            ? ($this->_pointerOffset >= $this->_download->getSize())
            : true;
    }
966852
public function getNext()
    {
        if ($this->peeking) {
            $this->peeking = false;
            $this->used[] = $this->peeked;

            return $this->peeked;
        }

        if (!isset($this->tokens[$this->cursor])) {
            throw new InternalErrorException('Unexpected token stream end.');
        }

        return $this->tokens[$this->cursor++];
    }
656851
public function openAsync()
    {
        return $this->readBeforeStream()
        ->otherwise(function($err) {
            //If failed to load initial portion of tweets, continue anyway
            $this->emit("warning", [$err]);
        })
        ->then(function($initialTweets) {
            $this->emit("clear_tweets", []);
            foreach ($initialTweets as $tweet) {
              $this->emit("tweet", [$tweet]);
            }
            return $this->openStream();
        });
    }
952633
private static function read()
	{
		self::lock();
		if ( is_null( self::$authFileP ) ) throw new Exception( 'No lock has been requested' );
		return stream_get_contents( self::$authFileP , -1 , 0 );
	}
1000683
final public function buffer(): Promise
    {
        if ($this->promise) {
            return $this->promise;
        }

        return $this->promise = call(function () {
            $buffer = '';
            if ($this->lastRead && null === yield $this->lastRead) {
                return $buffer;
            }

            while (null !== $chunk = yield $this->stream->read()) {
                $buffer .= $chunk;
            }
            return $buffer;
        });
    }
1162789
public function read () {
			if( ! $this->write_finished ) { $this->finishWrite(); }
			$this->read_started = true;

			$response = new AWSResponse();
			while( ! feof( $this->socket ) ) {
				$line = fgets( $this->socket );
				if( AWSResponse::EOF == $response->line( $line ) ) {
					break;
				}
			}
			$response->complete();

			return $response;
		}
227292
protected function loadBuffer()
	{
		$this->remainder = 0;
		
		if($this->ended)
		{
			return;
		}
		
		while(!$this->stream->eof() && strlen($this->buffer) < self::BUFFER_SIZE)
		{
			$this->buffer .= $this->stream->read(self::BUFFER_SIZE);
		}
		
		$m = NULL;
		
		if(preg_match("'^\r?\n?([a-fA-F0-9]+).*\r\n'", $this->buffer, $m))
		{
			$this->remainder = hexdec($m[1]);
			$this->buffer = (string)substr($this->buffer, strlen($m[0]));
			
			if($this->remainder === 0)
			{
				$this->buffer = '';
				$this->ended = true;
			}
			else
			{
				while(!$this->stream->eof() && strlen($this->buffer) < $this->remainder)
				{
					$this->buffer .= $this->stream->read($this->remainder);
				}
				
				if(strlen($this->buffer) < $this->remainder)
				{
					$this->buffer = '';
					$this->ended = true;
				}
			}
		}
		else
		{
			$this->buffer = '';
			$this->ended = true;
		}
	}
44468
public function read()
    {
        $this->ensureDeviceOpen();

        $chars = [];

        do {
            $char = fread($this->fd, 1);
            $chars[] = $char;
        } while ($char != $this->getParser()->getSeparator());

        return $this->getParser()->parse($chars);
    }
222305
public function handleRead()
    {
        try
        {
            if (!$this->reading)
            {
                return;
            }

            $length = $this->bufferSize;
            $ret = fread($this->resource, $length);

            if ($ret === false)
            {
                $this->emit('error', [ $this, new ReadException('Error occurred while reading from the stream resource.') ]);
                return;
            }

            if ($ret !== '')
            {
                $this->emit('data', [ $this, $ret ]);

                if (strlen($ret) < $length)
                {
                    $this->reading = false;
                    $this->emit('end', [ $this ]);
                }
            }
        }
        catch (Error $ex)
        {
            $this->emit('error', [ $this, $ex ]);
        }
        catch (Exception $ex)
        {
            $this->emit('error', [ $this, $ex ]);
        }
    }
221919
@Override
    public int read(byte[] output) throws IOException {
        
        //Return -1 here because if we are closed or finished, we're at the end of the stream
        if(isClosed || isFinished()){
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Nothing to read, stream is closed : " + isClosed + ", or finished : " + isFinished());
            return -1;
        }
        
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "read" , "SRTInputStream31.read(byte[])");
        }
        if(output == null){
            if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
                Tr.error(tc, "read.write.bytearray.null");
            throw new NullPointerException(Tr.formatMessage(tc, "read.write.bytearray.null"));
        }
        
        int returnSize = 0;
        
        if(this.request.isAsyncStarted() && (this.getReadListener()!= null)){
            synchronized(this){
                
                //Check if isReady had returned false. If it did then an IllegalArgumentException will be thrown if a listener is set
                isReadyFalseCheck();
                returnSize = super.read(output);
            }
        }else{
            returnSize = super.read(output);
        }
        
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "read" , "SRTInputStream31.read(byte[]) : " + returnSize);
        }
        
        return returnSize;
    }
368800
public function read(): Promise
    {
        return $this->pending = call(function () {
            if ($this->pending) {
                yield $this->pending;
            }

            if ($this->id !== null) {
                $this->data = yield $this->storage->read($this->id);
            }

            $this->status |= self::STATUS_READ;

            return $this;
        });
    }
226700
@NotNull
    @SuppressWarnings("unchecked")
    public Stream<T> stream() {
        if (!isPresent()) return Stream.empty();
        return Stream.of(value);
    }
517909
protected function onRead()
    {
        start:
        if ($this->state === self::STATE_ROOT) {
            while (($l = $this->readLine()) !== null) {
                $e = explode(' ', $l);

                if ($e[0] === 'VALUE') {
                    $this->key = $e[1];
                    $this->valueFlags = $e[2];
                    $this->valueLength = $e[3];
                    $this->result = '';
                    $this->setWatermark($this->valueLength);
                    $this->state = self::STATE_DATA;
                    break;
                } elseif ($e[0] === 'STAT') {
                    if ($this->result === null) {
                        $this->result = [];
                    }

                    $this->result[$e[1]] = $e[2];
                } elseif (($e[0] === 'STORED') || ($e[0] === 'END') || ($e[0] === 'DELETED') || ($e[0] === 'ERROR')
                    || ($e[0] === 'CLIENT_ERROR') || ($e[0] === 'SERVER_ERROR')
                ) {
                    if ($e[0] !== 'END') {
                        $this->result = false;
                        $this->error = isset($e[1]) ? $e[1] : null;
                    }
                    $this->onResponse->executeOne($this);
                    $this->checkFree();
                    $this->result = null;
                }
            }
        }

        if ($this->state === self::STATE_DATA) {
            if (false === ($this->result = $this->readExact($this->valueLength))) {
                return; //we do not have a whole packet
            }
            $this->state = self::STATE_ROOT;
            $this->setWatermark(1);
            goto start;
        }
    }
639871
function () {
    return new Promise((resolve, reject) => {
      var startTime = Date.now();
      var size = fs.statSync(dataFile).size;
      var next = (readInfo, position) => {
        var jobs = [readNextChunk(readInfo)];

        if (position) {
          jobs.push(readAndIndex(position, readInfo.readBuffer));
          debug(position);
        }

        Q.all(jobs).then(results => {
          var nextReadInfo = results[0];
          var nextPosition = results[1] || {};

          readInfo.readBuffer = null;

          if (nextReadInfo.done && position) {
            debug("indexSize size: %s", (indexSize / 1024) + "KB");
            debug("index ready (took %s secs)", (Date.now() - startTime) / 1000);

            meta.size = indexSize;

            debug(meta);

            resolve();
          } else {
            next(nextReadInfo, nextPosition);
          }
        }).catch(err => reject(err));
      };

      debug("creating index");
      next({ size: size, fd: openDataFile() });
    });
  }
1107371
public function read()
    {
        if ($this->data || !file_exists($this->filename)) {
            return $this->data;
        }

        return @unserialize(file_get_contents($this->filename)) ?: [];
    }