Erebot  latest
A modular IRC bot for PHP 5.3+
Erebot\StreamWrapperBase Class Reference

Abstract class for a minimal PHP stream wrapper. More...

+ Inheritance diagram for Erebot\StreamWrapperBase:

Public Member Functions

 __construct ()
 Constructs a new instance of this stream wrapper. More...
 
 stream_close ()
 Close a resource. More...
 
 stream_eof ()
 Tests for end-of-file on a file pointer. More...
 
 stream_open ($path, $mode, $options, &$openedPath)
 Opens file or URL. More...
 
 stream_read ($count)
 Read from stream. More...
 
 stream_seek ($offset, $whence)
 Seeks to specific location in a stream. More...
 
 stream_stat ()
 Retrieve information about a file resource. More...
 
 stream_tell ()
 Retrieve the current position of a stream. More...
 
 url_stat ($path, $flags)
 Retrieve information about a file. More...
 

Public Attributes

const SEEK_CUR = SEEK_CUR
 Set position to current location plus offset.
 
const SEEK_END = SEEK_END
 Set position to end-of-file plus offset.
 
const SEEK_SET = SEEK_SET
 Set position equal to offset bytes.
 
const STREAM_REPORT_ERRORS = STREAM_REPORT_ERRORS
 Whether the stream wrapper should report errors or not. More...
 
const STREAM_URL_STAT_LINK = STREAM_URL_STAT_LINK
 For links, whether to return information about the link itself or the resource it links to. More...
 
const STREAM_URL_STAT_QUIET = STREAM_URL_STAT_QUIET
 Whether to report errors in Erebot::StreamWrapperBase::url_stat() or not. More...
 
const STREAM_USE_PATH = STREAM_USE_PATH
 If path is relative, search for the resource using the include_path.
 

Detailed Description

Abstract class for a minimal PHP stream wrapper.

Definition at line 28 of file StreamWrapperBase.php.

Constructor & Destructor Documentation

Erebot\StreamWrapperBase::__construct ( )

Constructs a new instance of this stream wrapper.

This method is called when opening the stream wrapper, right before Erebot::StreamWrapperBase::stream_open().

Definition at line 84 of file StreamWrapperBase.php.

Member Function Documentation

Erebot\StreamWrapperBase::stream_close ( )
abstract

Close a resource.

This method is called in response to fclose(). All resources that were locked, or allocated, by the wrapper should be released.

Erebot\StreamWrapperBase::stream_eof ( )
abstract

Tests for end-of-file on a file pointer.

This method is called in response to feof().

Return values
booltrue 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.
Erebot\StreamWrapperBase::stream_open (   $path,
  $mode,
  $options,
$openedPath 
)
abstract

Opens file or URL.

This method is called immediately after the wrapper is initialized (f.e. by fopen() and file_get_contents()).

Parameters
string$pathSpecifies the URL that was passed to the original function.
string$modeThe mode used to open the file, as detailed for fopen().
int$optionsHolds additional flags set by the streams API. It can hold one or more of the flags defined in thisinterface, OR'd together.
string$openedPathIf the path is opened successfully, and Erebot::StreamWrapperBase::STREAM_USE_PATH is set in $options, $opened_path should be set to the full path of the file/resource that was actually opened.
Return values
booltrue on success or false on failure.
Note
The URL can be broken apart with parse_url(). Note that only URLs delimited by "://"" are supported. ":" and ":/" while technically valid URLs, are not.
Attention
Remember to check if the mode is valid for the path requested.
Erebot\StreamWrapperBase::stream_read (   $count)

Read from stream.

This method is called in response to fread() and fgets().

Parameters
int$countHow many bytes of data from the current position should be returned.
Return values
stringIf there are less than count bytes available, returns as many as are available.
falseIf no more data is available, false should be returned.
Attention
Remember to update the read/write position of the stream (by the number of bytes that were successfully read).
Note
As a special case, an empty string may also be returned when no more data is available for reading.
Erebot::StreamWrapperBase::stream_eof() is called directly after calling Erebot::StreamWrapperBase::stream_read() to check if EOF has been reached. If not implemented, EOF is assumed.

Definition at line 176 of file StreamWrapperBase.php.

Erebot\StreamWrapperBase::stream_seek (   $offset,
  $whence 
)

Seeks to specific location in a stream.

This method is called in response to fseek().

Parameters
int$offsetThe stream offset to seek to.
int$whenceHow the seek is to be interpreted. One of:
Return values
booltrue if the position was updated, false otherwise.
Attention
The read/write position of the stream should be updated according to the $offset and $whence.
Note
Upon success, Erebot::StreamWrapperBase::stream_tell() is called directly after calling Erebot::StreamWrapperBase::stream_seek(). If Erebot::StreamWrapperBase::stream_tell() fails, the return value to the caller function will be set to false.

Definition at line 212 of file StreamWrapperBase.php.

Erebot\StreamWrapperBase::stream_stat ( )

Retrieve information about a file resource.

This method is called in response to fstat().

Return values
arraySame as for http://php.net/manual/en/function.stat.php.
Note
When using PHP 5.2.x, fstat() is sometimes called automatically on the stream. For backward compatibility, this method should always be implemented.

Definition at line 231 of file StreamWrapperBase.php.

Erebot\StreamWrapperBase::stream_tell ( )
abstract

Retrieve the current position of a stream.

This method is called in response to ftell().

Return values
intThe current position of the stream.
Erebot\StreamWrapperBase::url_stat (   $path,
  $flags 
)

Retrieve information about a file.

This method is called in response to all stat() related functions.

Parameters
string$pathThe file path or URL to stat. Note that in the case of a URL, it must be a :// delimited URL. Other URL forms are not supported.
int$flagsHolds additional flags set by the streams API. It can hold one or more of the following values OR'd together:
See also
http://php.net/manual/en/streamwrapper.url-stat.php for a complete list of all stat() related functions.

Definition at line 268 of file StreamWrapperBase.php.

Member Data Documentation

const Erebot\StreamWrapperBase::STREAM_REPORT_ERRORS = STREAM_REPORT_ERRORS

Whether the stream wrapper should report errors or not.

If this flag is set, the wrapper is responsible for raising errors using trigger_error() during opening of the stream. If this flag is not set, it should not raise any errors.

Definition at line 41 of file StreamWrapperBase.php.

const Erebot\StreamWrapperBase::STREAM_URL_STAT_LINK = STREAM_URL_STAT_LINK

For links, whether to return information about the link itself or the resource it links to.

For resources with the ability to link to other resource (such as an HTTP Location: forward, or a filesystem symlink). This flag specified that only information about the link itself should be returned, not the resource pointed to by the link. This flag is set in response to calls to lstat(), is_link(), or filetype().

Definition at line 55 of file StreamWrapperBase.php.

const Erebot\StreamWrapperBase::STREAM_URL_STAT_QUIET = STREAM_URL_STAT_QUIET

Whether to report errors in Erebot::StreamWrapperBase::url_stat() or not.

If this flag is set, the wrapper should not raise any errors. If this flag is not set, it is responsible for reporting errors using the trigger_error() function during stating of the path.

Definition at line 66 of file StreamWrapperBase.php.


The documentation for this class was generated from the following file: