Documentation

WritableStream extends Closable
in

A `WritableStream` allows writing data in chunks. Writers can wait on the returned promises to feel the backpressure.

Table of Contents

Methods

close()  : void
Closes the resource, marking it as unusable.
end()  : void
Marks the stream as no longer writable.
isClosed()  : bool
Returns whether this resource has been closed.
isWritable()  : bool
onClose()  : void
Registers a callback that is invoked when this resource is closed.
write()  : void
Writes data to the stream.

Methods

close()

Closes the resource, marking it as unusable.

public close() : void

Whether pending operations are aborted or not is implementation dependent.

end()

Marks the stream as no longer writable.

public end() : void

Note that this is not the same as forcefully closing the stream. This method waits for all pending writes to complete before closing the stream. Socket streams implementing this interface should only close the writable side of the stream.

Tags
throws
ClosedException

If the stream has already been closed.

throws
StreamException

If writing to the stream fails.

isClosed()

Returns whether this resource has been closed.

public isClosed() : bool
Return values
bool

true if closed, otherwise false.

isWritable()

public isWritable() : bool
Return values
bool

A stream may no longer be writable if it is closed or ended using end().

onClose()

Registers a callback that is invoked when this resource is closed.

public onClose(callable(): void $onClose) : void
Parameters
$onClose : callable(): void

write()

Writes data to the stream.

public write(string $bytes) : void
Parameters
$bytes : string

Bytes to write.

Tags
throws
ClosedException

If the stream has already been closed.

throws
StreamException

If writing to the stream fails.


        
On this page

Search results