Read the next $bytes bytes from the stream

@param  integer $bytes Number of bytes to read
@return string
352473
public function read($bytes)
    {
        $read = 0;
        $parts = array();

        while ($read < $bytes) {
            $data = fread($this->socket, $bytes - $read);

            if ($data === false) {
                // server must have dropped the connection
                if (feof($this->socket)) {
                    $this->close();
                }

                return false;
            }

            $read += strlen($data);
            $parts[] = $data;
        }

        return implode($parts);
    }
663707
private static function sizeFormat($bytes)
    {
        $kb = 1024;
        $mb = $kb * 1024;
        $gb = $mb * 1024;
        $tb = $gb * 1024;

        if (($bytes >= 0) && ($bytes < $kb)) {
            return $bytes . ' B';
        } elseif (($bytes >= $kb) && ($bytes < $mb)) {
            return ceil($bytes / $kb) . ' KB';
        } elseif (($bytes >= $mb) && ($bytes < $gb)) {
            return ceil($bytes / $mb) . ' MB';
        } elseif (($bytes >= $gb) && ($bytes < $tb)) {
            return ceil($bytes / $gb) . ' GB';
        } elseif ($bytes >= $tb) {
            return ceil($bytes / $tb) . ' TB';
        } else {
            return $bytes . ' B';
        }
    }
1282704
public static function fromBytes(string $bytes): Uuid
    {
        if (strlen($bytes) !== 16) {
            $message = sprintf('%s expects $bytes to be a 16-bytes string', __METHOD__);
            throw new DomainException($message);
        }

        $steps = [];
        foreach (range(0, 15) as $i) {
            $steps[] = sprintf('%02x', ord($bytes[$i]));
            if (in_array($i, [3, 5, 7, 9])) {
                $steps[] = '-';
            }
        }

        return static::parse(implode('', $steps));
    }
708724
protected function _random($bytes) {
		if (is_readable('/dev/urandom')) {
			$stream = fopen('/dev/urandom', 'rb');
			$result = fread($stream, $bytes);

			fclose($stream);
			return $result;
		}
		if (function_exists('mcrypt_create_iv')) {
			return mcrypt_create_iv($bytes, MCRYPT_DEV_RANDOM);
		}
		throw new Exception("No source for generating a cryptographically secure seed found.");
	}
903535
public function read($bytes=0)
    {
        // If the connection wrote into the resource the handle will be placed
        // at the end and nothing will be returned
        if ($this->didWrite) {
            $this->stream = null;
        }

        if (!$bytes) {
            return $this->stream()->toString();
        }

        $stream = $this->stream();
        $stream->setChunkSize($bytes);

        if (!$stream->isOpen()) {
            $stream->rewind();
        } else {
            $stream->next();
        }

        return $stream->current();
    }
904836
public function read($length)
    {
        if ($this->deadline) {
            stream_set_timeout($this->socket, max($this->deadline - time(), 1));
        }

        // Note: For correct behaviour, $length should be the same at the
        // PHP stream chunk size. For all PHP < 5.4 this is 8192. Other values
        // will cause PHP's internal stream buffer to be used and break
        // stream_select() semantics. See https://bugs.php.net/bug.php?id=52602
        $data = fread($this->socket, $length);

        $this->checkTimeout();
        return $data;
    }
579911
private function limitBytes($bytes)
    {
        if ($bytes === null) {
            return $this->content;
        } elseif (intval($bytes) < (self::BYTE_LIMIT * 0.046875)) {
            // less than 24 kilobytes (512 kilobytes * 0.046875)
            throw new \InvalidArgumentException('Byte limit is set dangerously low! Default value=' . self::BYTE_LIMIT);
        }
        return $this->content = mb_strcut($this->content, 0, intval($bytes));
    }
945984
public static function fromBytes(array $bytes)
    {
        $result = null;
        if (count($bytes) === 16) {
            $address = '';
            for ($i = 0; $i < 16; ++$i) {
                if ($i !== 0 && $i % 2 === 0) {
                    $address .= ':';
                }
                $byte = $bytes[$i];
                if (is_int($byte) && $byte >= 0 && $byte <= 255) {
                    $address .= sprintf('%02x', $byte);
                } else {
                    $address = null;
                    break;
                }
            }
            if ($address !== null) {
                $result = new static($address);
            }
        }

        return $result;
    }
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;
    }
942964
public function read($pos, $bytes)
    {
        if ($pos + $bytes > $this->_len) {
            throw new ReaderException('Not enough bytes!');
        }

        return substr($this->_str, $pos, $bytes);
    }
676326
public function stream_read($bytes)
    {
        if (!$this->currentlyOpenedFile->isOpenedForReading()) {
            return null;
        }
        $data = $this->currentlyOpenedFile->read($bytes);
        //file access time changes so stat cache needs to be cleared
        clearstatcache();

        return $data;
    }
792689
public static function formatSizeUnits($bytes)
    {
        if ($bytes >= 1073741824) {
            $bytes = number_format($bytes / 1073741824, 2) . ' GB';
        } elseif ($bytes >= 1048576) {
            $bytes = number_format($bytes / 1048576, 2) . ' MB';
        } elseif ($bytes >= 1024) {
            $bytes = number_format($bytes / 1024, 2) . ' KB';
        } elseif ($bytes > 1) {
            $bytes = $bytes . ' bytes';
        } elseif ($bytes === 1) {
            $bytes = $bytes . ' byte';
        } else {
            $bytes = '0 bytes';
        }

        return $bytes;
    }
413414
protected function _fread($length=1)
    {
        if ($length == 0) {
            return '';
        }

        if ($length < 1024) {
            return fread($this->_fileHandle, $length);
        }

        $data = '';
        while ( $length > 0 && ($nextBlock = fread($this->_fileHandle, $length)) != false ) {
            $data .= $nextBlock;
            $length -= strlen($nextBlock);
        }
        return $data;
    }
283244
public function shift($bytes)
    {
        $bufferLen = strlen($this->buffer);

        if ($bytes === $bufferLen) {
            $return       = $this->buffer;
            $this->buffer = '';
        } else {
            $return       = substr($this->buffer, 0, $bytes);
            $this->buffer = substr($this->buffer, $bytes);
        }

        return $return;
    }
216932
public function formatFileSize ($bytes)
    {
        $sz = 'BKMGTP';
        $factor = (int) floor((strlen($bytes) - 1) / 3);
        return number_format($bytes / pow(1024, $factor), 2, ",", ".") . @$sz[$factor];
    }
119774
public function read(int $length = 8192): string
    {
        $bytes           = substr($this->buffer, $this->position, $length);
        $this->position += strlen($bytes);
        return $bytes;
    }
39305
public function read($bytes = 2082)
    {
        return feof($this->stream) ? false : fread($this->stream, $bytes);
    }