Read the next chunk of the string.

@param integer $bytesRequested The size of the chunk that is to be read.
@return string A corresponding piece of the string.
487475
public function read($bytesRequested)
    {
      $len = strlen($this->_sourceString);
      if($this->_bytesRead == $len) {
          return FALSE;
      } else if($bytesRequested > $len - $this->_bytesRead) {
          $bytesRequested = $len - $this->_bytesRead;
      }

      $buffer = substr($this->_sourceString, $this->_bytesRead, $bytesRequested);
      $this->_bytesRead += $bytesRequested;

      return $buffer;
    }
460294
public function readBytes(int $bytes): string
	{
		if ($this->connected() === false)
		{
			throw new \Exception('Not connected');
		}

		$response = fread($this->connection, $bytes);

		if ($response === false)
		{
			throw new \Exception('Nothing to read');
		}

		return $response;
	}
717713
public function read($length)
    {
        if ($length < 1) {
            return '';
        }

        $buffer = fread($this->stream, $length);

        if ($buffer === false) {
            throw new RuntimeException('Failed to read ' . $length . ' bytes');
        }

        return $buffer;
    }
968919
public function read($len) {
        // Do a non-blocking read to clear any buffering, even though
        // the code doesn't use the results
        if (is_resource($this->socket_)) {
            @fread($this->socket_, max($len, 8192));
        }

        // Return data from the hard-coded response buffer
        $part = substr($this->respBuffer_, 0, $len);
        $this->respBuffer_ = substr($this->respBuffer_, $len);
        return $part;
    }
263493
public function read($offset, $length = 1)
    {
        $ret = '';
        $segno = floor($offset / $this->segsize);
        $sOffset = $offset % $this->segsize;
        while (true) {
            if (!isset($this->segments[$segno])) {
                if (!$this->open($segno)) {
                    goto ret;
                }
            }

            $ret .= shmop_read($this->segments[$segno], $sOffset, min($length - mb_orig_strlen($ret), $this->segsize));

            if (mb_orig_strlen($ret) >= $length) {
                goto ret;
            }

            ++$segno;

            $sOffset = 0;
        }
        ret:

        return $ret === '' ? false : $ret;
    }
354776
function read($inByte = null)
    {
        if ($this->getSegmentLimit() == -1)
            return $this->_t__wrap_stream->read($inByte);


        $inByte = ($inByte === null)
            ? (
                ($this->getBuffer() === null) ? $this->getSize() : $this->getBuffer()

            ) : $inByte;

        $remain = $this->getSegmentLimit() - $this->getCurrOffset();
        if ($remain > 0)
            return $this->_t__wrap_stream->read(min($remain, $inByte));

        return '';
    }
139376
protected function read($chunk)
	{
		if ( ! is_string($chunk) && $chunk !== false) {
			throw new \InvalidArgumentException(
				__METHOD__."() expects parameter one, chunk, to be a string or false"
			);
		}
		
		$this->characters = [];
		
		// if $chunk is not false and not empty...
		// keep in mind, the single-byte strlen() function is ok here, I just want
		//     to be sure the string isn't empty; otherwise, the characters array
		//     will have an empty string as an element (e.g., [''])
		// also, don't use PHP's native empty() method here either; empty() will
		//     consider "0" an empty string, but it's a valid value
		//
		if (is_string($chunk) && strlen($chunk) > 0) {
			// get the chunk's length
			$len = mb_strlen($chunk, $this->chunker->getEncoding());
			// loop through the chunk's characters
			for ($i = 0; $i < $len; ++$i) {
				// append the character to the characters array...
				// I (Jack) tried using mb_split('//', $chunk) here; however, it 
				//     didn't split the string into characters as expected
				//
				$this->characters[] = mb_substr(
					$chunk, $i, 1, $this->chunker->getEncoding()
				);
			}	
		}
		
		return;
	}
246015
public function readBytes($length)
    {
        $read = $this->read($length);
        if (false !== $read) {
            $ret = array_map('ord', str_split($read, 1));

            return $ret;
        }

        return false;
    }
984496
public function read($count)
    {
        $data = substr($this->content, $this->bytes_read, $count);
        $this->bytes_read  += $count;
        $this->lastAccessed = time();
        return $data;
    }
202814
public function read($length)
    {
        $buffer = '';
        $total = count($this->streams) - 1;
        $remaining = $length;
        $progressToNext = false;

        while ($remaining > 0) {

            // Progress to the next stream if needed.
            if ($progressToNext || $this->streams[$this->current]->eof()) {
                $progressToNext = false;
                if ($this->current === $total) {
                    break;
                }
                $this->current++;
            }

            $result = $this->streams[$this->current]->read($remaining);

            // Using a loose comparison here to match on '', false, and null
            if ($result == null) {
                $progressToNext = true;
                continue;
            }

            $buffer .= $result;
            $remaining = $length - strlen($buffer);
        }

        $this->pos += strlen($buffer);

        return $buffer;
    }
1336965
protected function readLine($handle, $chunkSize)
    {
        $line = $chunkSize ? fgets($handle, $chunkSize) : fgets($handle);

        return rtrim($line, "\n\r");
    }
1280451
protected function readbytes($length)
    {
        if ($this->comptype === Archive::COMPRESS_GZIP) {
            return @gzread($this->fh, $length);
        } elseif ($this->comptype === Archive::COMPRESS_BZIP) {
            return @bzread($this->fh, $length);
        } else {
            return @fread($this->fh, $length);
        }
    }
742763
public function readLine($maxLength = null)
    {
        $buffer = '';
        $size = 0;
        while (!$this->isConsumed()) {
            $byte = $this->read(1);
            $buffer .= $byte;
            // Break when a new line is found or the max length - 1 is reached
            if ($byte == PHP_EOL || ++$size == $maxLength - 1) {
                break;
            }
        }

        return $buffer;
    }
1237941
private function getChunkedString($string)
    {
        $firstLine = '';
        if ($this->tell() !== 0) {
            $next = $this->lineLength - ($this->position % ($this->lineLength + $this->lineEndingLength));
            if (strlen($string) > $next) {
                $firstLine = substr($string, 0, $next) . $this->lineEnding;
                $string = substr($string, $next);
            }
        }
        // chunk_split always ends with the passed line ending
        $chunked = $firstLine . chunk_split($string, $this->lineLength, $this->lineEnding);
        return substr($chunked, 0, strlen($chunked) - $this->lineEndingLength);
    }
1203290
public function read($n)
    {
        if (0 === $n) {
            return '';
        }

        $remaining = ($n - $this->length) + $this->position;

        while ($remaining > 0) {
            //$this->io->wait();
            if ($this->io->shouldEnableCrypto()) {
                $new = $this->io->read($remaining);
            } else {
                $new = $this->io->readChunk($remaining);
            }
            $this->bytes .= $new;
            $remaining -= strlen($new);
        }

        $this->length = strlen($this->bytes);
        $data = substr($this->bytes, $this->position, $n);
        $this->position += $n;

        return $data;
    }
1213418
public function read($length)
    {
        // let Guzzle decide what to do.
        if ($length <= 0 || $this->eof()) {
            return $this->stream->read($length);
        }
        $this->readRawCharsIntoBuffer($length);
        $numChars = min([$this->bufferLength, $length]);
        $chars = $this->converter->getSubstr($this->buffer, $this->streamCharset, 0, $numChars);
        
        $this->position += $numChars;
        $this->buffer = $this->converter->getSubstr($this->buffer, $this->streamCharset, $numChars);
        $this->bufferLength = $this->bufferLength - $numChars;

        return $this->converter->convert($chars, $this->streamCharset, $this->stringCharset);
    }
412996
public function consumeReadBuffer(int $bytes) : string
    {
        if ($this->getBufferLength()<$bytes) {
            throw new \RuntimeException("BufferedSocket::getAndConsumeReadBuffer requested more bytes than are currently available. Requested=".$bytes.", available=".$this->getBufferLength().".");
        }
        $data = \substr($this->getReadBuffer(), 0, $bytes);
        $this->reduceReadBuffer($bytes);
        return $data;
    }