HH\Lib\IO\BufferedReader::readLineAsync

Meta Engineer?

The containing class is available as IO\BufferedReader in the www repository.

Read until the platform end-of-line sequence is seen, or EOF is reached

public function readLineAsync(): Awaitable<?string>;

On current platforms, this is always \n; it may have other values on other platforms in the future, e.g. \r\n.

The newline sequence is read (so won't be returned by other calls), but is not included in the return value.

  • Returns null if the end of file is reached with no data.
  • Returns a string otherwise

Some illustrative edge cases:

  • '' is considered a 0-line input
  • 'foo' is considered a 1-line input
  • "foo\nbar" is considered a 2-line input
  • "foo\nbar\n" is also considered a 2-line input

Returns