final class StreamWrapper

Adapt Guzzle's PSR-7 resource bridge so stream callers retain cancellation failures.

Constants

PROTOCOL

Properties

resource $context

Methods

static mixed
getResource(StreamInterface $stream)

Return a borrowed resource without taking ownership of the underlying stream.

static mixed
detach(StreamInterface $stream)

Transfer ownership of a stream to a PHP resource.

static mixed
createStreamContext(StreamInterface $stream)

Create a stream context for a borrowed PHP stream resource.

static void
register()

Register the stream wrapper protocol once per process.

bool
stream_open(string $path, string $mode, int $options, string|null $openedPath = null)

Open the PSR-7 stream supplied through its resource context.

void
stream_close()

Close an owned stream while leaving borrowed bodies with their owner.

string|false
stream_read(int $count)

Read bytes while preserving cancellation through producer cleanup.

int
stream_write(string $data)

Write bytes to the underlying stream.

bool
stream_flush()

Accept flushing for a PSR-7 stream without a separate flush operation.

int|false
stream_tell()

Return the current stream position.

bool
stream_eof()

Determine whether the underlying stream has ended.

bool
stream_seek(int $offset, int $whence)

Seek within the underlying stream.

mixed
stream_cast(int $castAs)

Expose a native descriptor without detaching the retained stream.

array|false
stream_stat()

Return metadata for a stream with a known size.

array
url_stat(string $path, int $flags)

Return placeholder metadata for the wrapper URL.

Details

at line 42
static mixed getResource(StreamInterface $stream)

Return a borrowed resource without taking ownership of the underlying stream.

Parameters

StreamInterface $stream

Return Value

mixed

Exceptions

InvalidArgumentException

at line 55
static mixed detach(StreamInterface $stream)

Transfer ownership of a stream to a PHP resource.

Unlike getResource(), closing this resource closes the supplied stream. The caller must relinquish the stream after transferring ownership.

Parameters

StreamInterface $stream

Return Value

mixed

at line 75
static mixed createStreamContext(StreamInterface $stream)

Create a stream context for a borrowed PHP stream resource.

Parameters

StreamInterface $stream

Return Value

mixed

at line 114
static void register()

Register the stream wrapper protocol once per process.

Return Value

void

at line 130
bool stream_open(string $path, string $mode, int $options, string|null $openedPath = null)

Open the PSR-7 stream supplied through its resource context.

Parameters

string $path
string $mode
int $options
string|null $openedPath

Return Value

bool

at line 149
void stream_close()

Close an owned stream while leaving borrowed bodies with their owner.

Return Value

void

at line 159
string|false stream_read(int $count)

Read bytes while preserving cancellation through producer cleanup.

Parameters

int $count

Return Value

string|false

at line 175
int stream_write(string $data)

Write bytes to the underlying stream.

Parameters

string $data

Return Value

int

at line 191
bool stream_flush()

Accept flushing for a PSR-7 stream without a separate flush operation.

Return Value

bool

at line 199
int|false stream_tell()

Return the current stream position.

Return Value

int|false

at line 215
bool stream_eof()

Determine whether the underlying stream has ended.

Return Value

bool

at line 231
bool stream_seek(int $offset, int $whence)

Seek within the underlying stream.

Parameters

int $offset
int $whence

Return Value

bool

at line 251
mixed stream_cast(int $castAs)

Expose a native descriptor without detaching the retained stream.

Parameters

int $castAs

Return Value

mixed

at line 281
array|false stream_stat()

Return metadata for a stream with a known size.

Return Value

array|false

at line 341
array url_stat(string $path, int $flags)

Return placeholder metadata for the wrapper URL.

Parameters

string $path
int $flags

Return Value

array