vfsStreamWrapper
in package
Stream wrapper to mock file system requests.
Table of Contents
- ALL = 2
- file mode: read and write
- APPEND = 'a'
- set file pointer to end, append new data
- READ = 'r'
- open file for reading
- READONLY = 0
- file mode: read only
- TRUNCATE = 'w'
- truncate file
- WRITE = 'x'
- set file pointer to start, overwrite existing data
- WRITE_NEW = 'c'
- set file pointer to start, overwrite existing data; or create file if does not exist
- WRITEONLY = 1
- file mode: write only
- $content : mixed
- shortcut to file container
- $dir : mixed
- shortcut to directory container
- $dirIterator : mixed
- shortcut to directory container iterator
- $mode : mixed
- file mode: read only, write only, all
- $registered : mixed
- switch whether class has already been registered as stream wrapper or not
- $root : mixed
- root content
- $quota : mixed
- disk space quota
- dir_closedir() : bool
- closes directory
- dir_opendir() : bool
- opens a directory
- dir_readdir() : string
- reads directory contents
- dir_rewinddir() : bool
- reset directory iteration
- getRoot() : vfsStreamContainer
- returns the root content
- mkdir() : bool
- creates a new directory
- register() : mixed
- method to register the stream wrapper
- rename() : bool
- rename from one path to another
- rmdir() : bool
- removes a directory
- setQuota() : mixed
- sets quota for disk space
- setRoot() : vfsStreamContainer
- sets the root content
- stream_cast() : bool
- retrieve the underlaying resource
- stream_close() : mixed
- closes the stream
- stream_eof() : bool
- checks whether stream is at end of file
- stream_flush() : bool
- flushes unstored data into storage
- stream_lock() : bool
- set lock status for stream
- stream_metadata() : bool
- sets metadata like owner, user or permissions
- stream_open() : bool
- open the stream
- stream_read() : string
- read the stream up to $count bytes
- stream_seek() : bool
- seeks to the given offset
- stream_set_option() : bool
- sets options on the stream
- stream_stat() : array<string|int, mixed>
- returns status of stream
- stream_tell() : int
- returns the current position of the stream
- stream_truncate() : bool
- truncates a file to a given length
- stream_write() : int
- writes data into the stream
- unlink() : bool
- remove the data under the given path
- unregister() : mixed
- Unregisters a previously registered URL wrapper for the vfs scheme.
- url_stat() : array<string|int, mixed>
- returns status of url
- calculateMode() : int
- calculates the file mode
- doUnlink() : bool
- removes a path
- getContent() : vfsStreamContent
- returns content for given path
- getContentOfType() : vfsStreamContent
- returns content for given path but only when it is of given type
- resolvePath() : string
- helper method to resolve a path from /foo/bar/. to /foo/bar
- splitPath() : array<string|int, string>
- splits path into its dirname and the basename
- createFile() : bool
- creates a file at given path
- doPermChange() : bool
- executes given permission change when necessary rights allow such a change
- isInRoot() : bool
- helper method to detect whether given path is in root path
Constants
ALL
file mode: read and write
public
mixed
ALL
= 2
APPEND
set file pointer to end, append new data
public
mixed
APPEND
= 'a'
READ
open file for reading
public
mixed
READ
= 'r'
READONLY
file mode: read only
public
mixed
READONLY
= 0
TRUNCATE
truncate file
public
mixed
TRUNCATE
= 'w'
WRITE
set file pointer to start, overwrite existing data
public
mixed
WRITE
= 'x'
WRITE_NEW
set file pointer to start, overwrite existing data; or create file if does not exist
public
mixed
WRITE_NEW
= 'c'
WRITEONLY
file mode: write only
public
mixed
WRITEONLY
= 1
Properties
$content
shortcut to file container
protected
mixed
$content
Tags
$dir
shortcut to directory container
protected
mixed
$dir
Tags
$dirIterator
shortcut to directory container iterator
protected
mixed
$dirIterator
Tags
$mode
file mode: read only, write only, all
protected
mixed
$mode
Tags
$registered
switch whether class has already been registered as stream wrapper or not
protected
static mixed
$registered
= false
Tags
$root
root content
protected
static mixed
$root
Tags
$quota
disk space quota
private
static mixed
$quota
Tags
Methods
dir_closedir()
closes directory
public
dir_closedir() : bool
Return values
bool —dir_opendir()
opens a directory
public
dir_opendir(string $path, int $options) : bool
Parameters
- $path : string
- $options : int
Return values
bool —dir_readdir()
reads directory contents
public
dir_readdir() : string
Return values
string —dir_rewinddir()
reset directory iteration
public
dir_rewinddir() : bool
Return values
bool —getRoot()
returns the root content
public
static getRoot() : vfsStreamContainer
Return values
vfsStreamContainer —mkdir()
creates a new directory
public
mkdir(string $path, int $mode, int $options) : bool
Parameters
- $path : string
- $mode : int
- $options : int
Return values
bool —register()
method to register the stream wrapper
public
static register() : mixed
Please be aware that a call to this method will reset the root element to null. If the stream is already registered the method returns silently. If there is already another stream wrapper registered for the scheme used by vfsStream a vfsStreamException will be thrown.
Tags
Return values
mixed —rename()
rename from one path to another
public
rename(string $path_from, string $path_to) : bool
Parameters
- $path_from : string
- $path_to : string
Tags
Return values
bool —rmdir()
removes a directory
public
rmdir(string $path, int $options) : bool
Parameters
- $path : string
- $options : int
Tags
Return values
bool —setQuota()
sets quota for disk space
public
static setQuota(Quota $quota) : mixed
Parameters
- $quota : Quota
Tags
Return values
mixed —setRoot()
sets the root content
public
static setRoot(vfsStreamContainer $root) : vfsStreamContainer
Parameters
- $root : vfsStreamContainer
Return values
vfsStreamContainer —stream_cast()
retrieve the underlaying resource
public
stream_cast(int $cast_as) : bool
Please note that this method always returns false as there is no underlaying resource to return.
Parameters
- $cast_as : int
Tags
Return values
bool —stream_close()
closes the stream
public
stream_close() : mixed
Tags
Return values
mixed —stream_eof()
checks whether stream is at end of file
public
stream_eof() : bool
Return values
bool —stream_flush()
flushes unstored data into storage
public
stream_flush() : bool
Return values
bool —stream_lock()
set lock status for stream
public
stream_lock(int $operation) : bool
Parameters
- $operation : int
Tags
Return values
bool —stream_metadata()
sets metadata like owner, user or permissions
public
stream_metadata(string $path, int $option, mixed $var) : bool
Parameters
- $path : string
- $option : int
- $var : mixed
Tags
Return values
bool —stream_open()
open the stream
public
stream_open(string $path, string $mode, string $options, string $opened_path) : bool
Parameters
- $path : string
-
the path to open
- $mode : string
-
mode for opening
- $options : string
-
options for opening
- $opened_path : string
-
full path that was actually opened
Return values
bool —stream_read()
read the stream up to $count bytes
public
stream_read(int $count) : string
Parameters
- $count : int
-
amount of bytes to read
Return values
string —stream_seek()
seeks to the given offset
public
stream_seek(int $offset, int $whence) : bool
Parameters
- $offset : int
- $whence : int
Return values
bool —stream_set_option()
sets options on the stream
public
stream_set_option(int $option, int $arg1, int $arg2) : bool
Parameters
- $option : int
-
key of option to set
- $arg1 : int
- $arg2 : int
Tags
Return values
bool —stream_stat()
returns status of stream
public
stream_stat() : array<string|int, mixed>
Return values
array<string|int, mixed> —stream_tell()
returns the current position of the stream
public
stream_tell() : int
Return values
int —stream_truncate()
truncates a file to a given length
public
stream_truncate(int $size) : bool
Parameters
- $size : int
-
length to truncate file to
Tags
Return values
bool —stream_write()
writes data into the stream
public
stream_write(string $data) : int
Parameters
- $data : string
Return values
int —amount of bytes written
unlink()
remove the data under the given path
public
unlink(string $path) : bool
Parameters
- $path : string
Return values
bool —unregister()
Unregisters a previously registered URL wrapper for the vfs scheme.
public
static unregister() : mixed
If this stream wrapper wasn't registered, the method returns silently.
If unregistering fails, or if the URL wrapper for vfs:// was not registered with this class, a vfsStreamException will be thrown.
Tags
Return values
mixed —url_stat()
returns status of url
public
url_stat(string $path, int $flags) : array<string|int, mixed>
Parameters
- $path : string
-
path of url to return status for
- $flags : int
-
flags set by the stream API
Return values
array<string|int, mixed> —calculateMode()
calculates the file mode
protected
calculateMode(string $mode, bool $extended) : int
Parameters
- $mode : string
-
opening mode: r, w, a or x
- $extended : bool
-
true if + was set with opening mode
Return values
int —doUnlink()
removes a path
protected
doUnlink(string $path) : bool
Parameters
- $path : string
Return values
bool —getContent()
returns content for given path
protected
getContent(string $path) : vfsStreamContent
Parameters
- $path : string
Return values
vfsStreamContent —getContentOfType()
returns content for given path but only when it is of given type
protected
getContentOfType(string $path, int $type) : vfsStreamContent
Parameters
- $path : string
- $type : int
Return values
vfsStreamContent —resolvePath()
helper method to resolve a path from /foo/bar/. to /foo/bar
protected
resolvePath(string $path) : string
Parameters
- $path : string
Return values
string —splitPath()
splits path into its dirname and the basename
protected
splitPath(string $path) : array<string|int, string>
Parameters
- $path : string
Return values
array<string|int, string> —createFile()
creates a file at given path
private
createFile(string $path[, string $mode = null ][, string $options = null ]) : bool
Parameters
- $path : string
-
the path to open
- $mode : string = null
-
mode for opening
- $options : string = null
-
options for opening
Return values
bool —doPermChange()
executes given permission change when necessary rights allow such a change
private
doPermChange(string $path, vfsStreamAbstractContent $content, Closure $change) : bool
Parameters
- $path : string
- $content : vfsStreamAbstractContent
- $change : Closure
Return values
bool —isInRoot()
helper method to detect whether given path is in root path
private
isInRoot(string $path) : bool
Parameters
- $path : string