public function readImpl()

in src/io/BufferedReader.php [38:63]


  public function readImpl(?int $max_bytes = null): string {
    _OS\arg_assert(
      $max_bytes is null || $max_bytes > 0,
      "Max bytes must be null, or greater than 0",
    );

    if ($this->eof) {
      return '';
    }
    if ($this->buffer === '') {
      $this->buffer = $this->getHandle()->readImpl();
      if ($this->buffer === '') {
        $this->eof = true;
        return '';
      }
    }

    if ($max_bytes is null || $max_bytes >= Str\length($this->buffer)) {
      $buf = $this->buffer;
      $this->buffer = '';
      return $buf;
    }
    $buf = $this->buffer;
    $this->buffer = Str\slice($buf, $max_bytes);
    return Str\slice($buf, 0, $max_bytes);
  }