PHP Class TQ\Vcs\StreamWrapper\AbstractStreamWrapper

显示文件 Open project: teqneers/php-stream-wrapper-for-git Class Usage Examples

Public Properties

Property Type Description
$context resource The stream context if set

Protected Properties

Property Type Description
$bufferFactory TQ\Vcs\StreamWrapper\FileBuffer\FactoryInterface The buffer factory
$contextOptions array The parsed stream context options
$contextParameters array The parsed stream context parameters
$dirBuffer TQ\Vcs\Buffer\ArrayBuffer The directory buffer if used on a directory
$fileBuffer TQ\Vcs\Buffer\FileBufferInterface The file buffer if used on a file
$path TQ\Vcs\StreamWrapper\PathInformationInterface The opened path
$pathFactory PathFactoryInterface The path factory
$protocol string The registered protocol

Public Methods

Method Description
dir_closedir ( ) : boolean streamWrapper::dir_closedir — Close directory handle
dir_opendir ( string $path, integer $options ) : boolean streamWrapper::dir_opendir — Open directory handle
dir_readdir ( ) : string | false streamWrapper::dir_readdir — Read entry from directory handle
dir_rewinddir ( ) : boolean streamWrapper::dir_rewinddir — Rewind directory handle
getRepositoryRegistry ( ) : RepositoryRegistry Returns the repository registry
mkdir ( string $path, integer $mode, integer $options ) : boolean streamWrapper::mkdir — Create a directory
rename ( string $path_from, string $path_to ) : boolean streamWrapper::rename — Renames a file or directory
rmdir ( string $path, integer $options ) : boolean streamWrapper::rmdir — Removes a directory
stream_close ( ) streamWrapper::stream_close — Close an resource
stream_eof ( ) : boolean streamWrapper::stream_eof — Tests for end-of-file on a file pointer
stream_flush ( ) : boolean streamWrapper::stream_flush — Flushes the output
stream_open ( string $path, string $mode, integer $options, string &$opened_path ) : boolean streamWrapper::stream_open — Opens file or URL
stream_read ( integer $count ) : string streamWrapper::stream_read — Read from stream
stream_seek ( integer $offset, integer $whence = SEEK_SET ) : boolean streamWrapper::stream_seek — Seeks to specific location in a stream
stream_stat ( ) : array streamWrapper::stream_stat — Retrieve information about a file resource
stream_tell ( ) : integer streamWrapper::stream_tell — Retrieve the current position of a stream
stream_write ( string $data ) : integer streamWrapper::stream_write — Write to stream
unlink ( string $path ) : boolean streamWrapper::unlink — Delete a file
unregister ( ) Unregisters the stream wrapper
url_stat ( string $path, integer $flags ) : array streamWrapper::url_stat — Retrieve information about a file

Protected Methods

Method Description
doRegister ( string $protocol, PathFactoryInterface $pathFactory, TQ\Vcs\StreamWrapper\FileBuffer\FactoryInterface $bufferFactory ) Registers the stream wrapper with the given protocol
getBufferFactory ( ) : TQ\Vcs\StreamWrapper\FileBuffer\FactoryInterface Creates the buffer factory
getContextOption ( string $option, mixed $default = null ) : mixed Returns a context option - $default if option is not found
getContextOptions ( boolean $all = false ) : array Parses the passed stream context and returns the context options relevant for this stream wrapper
getContextParameter ( string $parameter, mixed $default = null ) : mixed Returns a context parameter - $default if parameter is not found
getContextParameters ( ) : array Parses the passed stream context and returns the context parameters
getPath ( string $streamUrl ) : TQ\Vcs\StreamWrapper\PathInformationInterface Returns the path information for a given stream URL
maskHasFlag ( integer $mask, integer $flag ) : boolean Checks if a bitmask has a specific flag set

Method Details

dir_closedir() public method

streamWrapper::dir_closedir — Close directory handle
public dir_closedir ( ) : boolean
return boolean Returns TRUE on success or FALSE on failure.

dir_opendir() public method

streamWrapper::dir_opendir — Open directory handle
public dir_opendir ( string $path, integer $options ) : boolean
$path string Specifies the URL that was passed to {@see \opendir()}.
$options integer Whether or not to enforce safe_mode (0x04).
return boolean Returns TRUE on success or FALSE on failure.

dir_readdir() public method

streamWrapper::dir_readdir — Read entry from directory handle
public dir_readdir ( ) : string | false
return string | false Should return string representing the next filename, or FALSE if there is no next file.

dir_rewinddir() public method

streamWrapper::dir_rewinddir — Rewind directory handle
public dir_rewinddir ( ) : boolean
return boolean Returns TRUE on success or FALSE on failure.

doRegister() protected static method

Registers the stream wrapper with the given protocol
protected static doRegister ( string $protocol, PathFactoryInterface $pathFactory, TQ\Vcs\StreamWrapper\FileBuffer\FactoryInterface $bufferFactory )
$protocol string The protocol (such as "vcs")
$pathFactory PathFactoryInterface The path factory
$bufferFactory TQ\Vcs\StreamWrapper\FileBuffer\FactoryInterface The buffer factory

getBufferFactory() protected method

Creates the buffer factory
protected getBufferFactory ( ) : TQ\Vcs\StreamWrapper\FileBuffer\FactoryInterface
return TQ\Vcs\StreamWrapper\FileBuffer\FactoryInterface

getContextOption() protected method

Returns a context option - $default if option is not found
protected getContextOption ( string $option, mixed $default = null ) : mixed
$option string The option to retrieve
$default mixed The default value if $option is not found
return mixed

getContextOptions() protected method

Parses the passed stream context and returns the context options relevant for this stream wrapper
protected getContextOptions ( boolean $all = false ) : array
$all boolean Return all options instead of just the relevant options
return array The context options

getContextParameter() protected method

Returns a context parameter - $default if parameter is not found
protected getContextParameter ( string $parameter, mixed $default = null ) : mixed
$parameter string The parameter to retrieve
$default mixed The default value if $parameter is not found
return mixed

getContextParameters() protected method

Parses the passed stream context and returns the context parameters
protected getContextParameters ( ) : array
return array The context parameters

getPath() protected method

Returns the path information for a given stream URL
protected getPath ( string $streamUrl ) : TQ\Vcs\StreamWrapper\PathInformationInterface
$streamUrl string The URL given to the stream function
return TQ\Vcs\StreamWrapper\PathInformationInterface The path information representing the stream URL

getRepositoryRegistry() public static method

Returns the repository registry
public static getRepositoryRegistry ( ) : RepositoryRegistry
return RepositoryRegistry

maskHasFlag() protected static method

Checks if a bitmask has a specific flag set
protected static maskHasFlag ( integer $mask, integer $flag ) : boolean
$mask integer The bitmask
$flag integer The flag to check
return boolean

mkdir() public method

streamWrapper::mkdir — Create a directory
public mkdir ( string $path, integer $mode, integer $options ) : boolean
$path string Directory which should be created.
$mode integer The value passed to {@see \mkdir()}.
$options integer A bitwise mask of values, such as STREAM_MKDIR_RECURSIVE.
return boolean Returns TRUE on success or FALSE on failure.

rename() public method

streamWrapper::rename — Renames a file or directory
public rename ( string $path_from, string $path_to ) : boolean
$path_from string The URL to the current file.
$path_to string The URL which the $path_from should be renamed to.
return boolean Returns TRUE on success or FALSE on failure.

rmdir() public method

streamWrapper::rmdir — Removes a directory
public rmdir ( string $path, integer $options ) : boolean
$path string The directory URL which should be removed.
$options integer A bitwise mask of values, such as STREAM_MKDIR_RECURSIVE.
return boolean Returns TRUE on success or FALSE on failure.

stream_close() public method

streamWrapper::stream_close — Close an resource
public stream_close ( )

stream_eof() public method

streamWrapper::stream_eof — Tests for end-of-file on a file pointer
public stream_eof ( ) : boolean
return boolean Should return 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.

stream_flush() public method

streamWrapper::stream_flush — Flushes the output
public stream_flush ( ) : boolean
return boolean Should return 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.

stream_open() public method

streamWrapper::stream_open — Opens file or URL
public stream_open ( string $path, string $mode, integer $options, string &$opened_path ) : boolean
$path string Specifies the URL that was passed to the original function.
$mode string The mode used to open the file, as detailed for fopen().
$options integer Holds additional flags set by the streams API. It can hold one or more of the following values OR'd together. STREAM_USE_PATH If path is relative, search for the resource using the include_path. STREAM_REPORT_ERRORS If this flag is set, you are responsible for raising errors using trigger_error() during opening of the stream. If this flag is not set, you should not raise any errors.
$opened_path string If the path is opened successfully, and 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 boolean Returns TRUE on success or FALSE on failure.

stream_read() public method

streamWrapper::stream_read — Read from stream
public stream_read ( integer $count ) : string
$count integer How many bytes of data from the current position should be returned.
return string If there are less than count bytes available, return as many as are available. If no more data is available, return either FALSE or an empty string.

stream_seek() public method

streamWrapper::stream_seek — Seeks to specific location in a stream
public stream_seek ( integer $offset, integer $whence = SEEK_SET ) : boolean
$offset integer The stream offset to seek to.
$whence integer Possible values: SEEK_SET - Set position equal to offset bytes. SEEK_CUR - Set position to current location plus offset. SEEK_END - Set position to end-of-file plus offset.
return boolean Return TRUE if the position was updated, FALSE otherwise.

stream_stat() public method

streamWrapper::stream_stat — Retrieve information about a file resource
public stream_stat ( ) : array
return array stat() and fstat() result format Numeric Associative (since PHP 4.0.6) Description 0 dev device number 1 ino inode number * 2 mode inode protection mode 3 nlink number of links 4 uid userid of owner * 5 gid groupid of owner * 6 rdev device type, if inode device 7 size size in bytes 8 atime time of last access (Unix timestamp) 9 mtime time of last modification (Unix timestamp) 10 ctime time of last inode change (Unix timestamp) 11 blksize blocksize of filesystem IO ** 12 blocks number of 512-byte blocks allocated ** * On Windows this will always be 0. ** Only valid on systems supporting the st_blksize type - other systems (e.g. Windows) return -1.

stream_tell() public method

streamWrapper::stream_tell — Retrieve the current position of a stream
public stream_tell ( ) : integer
return integer Should return the current position of the stream.

stream_write() public method

streamWrapper::stream_write — Write to stream
public stream_write ( string $data ) : integer
$data string Should be stored into the underlying stream.
return integer Should return the number of bytes that were successfully stored, or 0 if none could be stored.

unregister() public static method

Unregisters the stream wrapper
public static unregister ( )

url_stat() public method

mode bit mask: S_IFMT 0170000 bit mask for the file type bit fields S_IFSOCK 0140000 socket S_IFLNK 0120000 symbolic link S_IFREG 0100000 regular file S_IFBLK 0060000 block device S_IFDIR 0040000 directory S_IFCHR 0020000 character device S_IFIFO 0010000 FIFO S_ISUID 0004000 set UID bit S_ISGID 0002000 set-group-ID bit (see below) S_ISVTX 0001000 sticky bit (see below) S_IRWXU 00700 mask for file owner permissions S_IRUSR 00400 owner has read permission S_IWUSR 00200 owner has write permission S_IXUSR 00100 owner has execute permission S_IRWXG 00070 mask for group permissions S_IRGRP 00040 group has read permission S_IWGRP 00020 group has write permission S_IXGRP 00010 group has execute permission S_IRWXO 00007 mask for permissions for others (not in group) S_IROTH 00004 others have read permission S_IWOTH 00002 others have write permission S_IXOTH 00001 others have execute permission
public url_stat ( string $path, integer $flags ) : array
$path string The 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.
$flags integer Holds additional flags set by the streams API. It can hold one or more of the following values OR'd together. STREAM_URL_STAT_LINK 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(). STREAM_URL_STAT_QUIET If this flag is set, your wrapper should not raise any errors. If this flag is not set, you are responsible for reporting errors using the trigger_error() function during stating of the path.
return array Should return as many elements as stat() does. Unknown or unavailable values should be set to a rational value (usually 0).

Property Details

$bufferFactory protected_oe static_oe property

The buffer factory
protected static FactoryInterface,TQ\Vcs\StreamWrapper\FileBuffer $bufferFactory
return TQ\Vcs\StreamWrapper\FileBuffer\FactoryInterface

$context public_oe property

The stream context if set
public resource $context
return resource

$contextOptions protected_oe property

The parsed stream context options
protected array $contextOptions
return array

$contextParameters protected_oe property

The parsed stream context parameters
protected array $contextParameters
return array

$dirBuffer protected_oe property

The directory buffer if used on a directory
protected ArrayBuffer,TQ\Vcs\Buffer $dirBuffer
return TQ\Vcs\Buffer\ArrayBuffer

$fileBuffer protected_oe property

The file buffer if used on a file
protected FileBufferInterface,TQ\Vcs\Buffer $fileBuffer
return TQ\Vcs\Buffer\FileBufferInterface

$path protected_oe property

The opened path
protected PathInformationInterface,TQ\Vcs\StreamWrapper $path
return TQ\Vcs\StreamWrapper\PathInformationInterface

$pathFactory protected_oe static_oe property

The path factory
protected static PathFactoryInterface $pathFactory
return PathFactoryInterface

$protocol protected_oe static_oe property

The registered protocol
protected static string $protocol
return string