phasync
StringBuffer / readFromResource

Method

StringBuffer::readFromResource

Starts a coroutine that reads the stream into the buffer, and ends the buffer when the stream ends.

Description#

public StringBuffer::readFromResource(
    $resource
): Fiber

Sets the stream to non-blocking. The coroutine stops reading while more than 1 MiB is unread.

Parameters#

$resource
A stream to read from

Return values#

The coroutine; await it to see a read error Fiber

Errors / Exceptions#

ExceptionWhen
InvalidArgumentExceptionIf $resource is not a stream

See also#