Methods |
public
static
|
register(string $protocol = 'php'): void
Register the wrapper as a protocol handler
Register the wrapper as a protocol handler
Throws
|
#
|
public
static
|
deregister(): void
Deregister the wrapper and restore the protocol handler it replaced (if
applicable)
Deregister the wrapper and restore the protocol handler it replaced (if
applicable)
Throws
|
#
|
public
static
|
reset(): void
Clear the wrapper's stream cache
Clear the wrapper's stream cache
Throws
|
#
|
public
|
stream_cast(int $cast_as)
Retrieve the underlying resource
Retrieve the underlying resource
This method is called in response to {@see stream_select()}.
Parameters
$cast_as |
Can be {@see \STREAM_CAST_FOR_SELECT} when
{@see stream_select()} is calling stream_cast() or
{@see \STREAM_CAST_AS_STREAM} when stream_cast() is called for other
uses.
|
Returns
The underlying stream resource used by the
wrapper, or false .
Implements
|
#
|
public
|
stream_close(): void
Close a resource
Close a resource
This method is called in response to {@see fclose()}.
All resources that were locked, or allocated, by the wrapper should be
released.
Implements
|
#
|
public
|
stream_eof(): bool
Tests for end-of-file on a file pointer
Tests for end-of-file on a file pointer
This method is called in response to {@see feof()}.
Returns
true if the read/write position is at the end of the
stream and if no more data is available to be read, or false otherwise.
Implements
|
#
|
public
|
stream_flush(): bool
Flushes the output
Flushes the output
This method is called in response to {@see fflush()} and when the stream
is being closed while any unflushed data has been written to it before.
If you have cached data in your stream but not yet stored it into the
underlying storage, you should do so now.
Returns
true if the cached data was successfully stored (or if
there was no data to store), or false if the data could not be stored.
Implements
|
#
|
public
|
stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool
Opens file or URL
Opens file or URL
This method is called immediately after the wrapper is initialized (e.g.
by {@see fopen()} and {@see file_get_contents()}).
Parameters
$path |
Specifies the URL that was passed to the original
function. Only URLs delimited by :// are supported.
|
$mode |
The mode used to open the file, as detailed for
{@see fopen()}.
|
$options |
Holds additional flags set by the streams API. It can
hold one or more of the following values OR'd together.
|
$opened_path |
If the path is opened successfully,
and {@see \STREAM_USE_PATH} is set in options , opened_path
should be set to the full path of the file/resource that was actually
opened.
|
Returns
true on success or false on failure.
Implements
|
#
|
public
|
stream_read(int $count)
Read from stream
Read from stream
This method is called in response to {@see fread()} and {@see fgets()}.
Remember to update the read/write position of the stream (by the number
of bytes that were successfully read).
Parameters
$count |
How many bytes of data from the current position should
be returned.
|
Returns
If there are less than count bytes available,
as many as are available should be returned. If no more data is
available, an empty string should be returned. To signal that reading
failed, false should be returned.
Implements
|
#
|
public
|
stream_seek(int $offset, int $whence = SEEK_SET): bool
Seeks to specific location in a stream
Seeks to specific location in a stream
This method is called in response to {@see fseek()}.
Parameters
$offset |
The stream offset to seek to.
|
$whence |
Possible values:
|
Returns
true if the position was updated, false otherwise.
Implements
|
#
|
public
|
stream_tell(): int
Retrieve the current position of a stream
Retrieve the current position of a stream
This method is called in response to {@see fseek()}.
Implements
|
#
|
public
|
stream_truncate(int $new_size): bool
Truncate stream
Truncate stream
This method is called in response to {@see ftruncate()}.
Returns
true on success or false on failure.
Implements
|
#
|
public
|
stream_write(string $data): int
Write to stream
Write to stream
This method is called in response to {@see fwrite()}.
Remember to update the current position of the stream by number of
bytes that were successfully written.
Parameters
$data |
Should be stored into the underlying stream. If there
is not enough room in the underlying stream, store as much as possible.
|
Returns
The number of bytes that were successfully stored, or 0 if
none could be stored.
Implements
|
#
|