Stream wrapper to mock file system requests.

 Methods

closes directory

dir_closedir() : bool

Returns

bool

opens a directory

dir_opendir(string $path, int $options) : bool

Parameters

$path

string

$options

int

Returns

bool

reads directory contents

dir_readdir() : string

Returns

string

reset directory iteration

dir_rewinddir() : bool

Returns

bool

returns the root content

getRoot() : \org\bovigo\vfs\vfsStreamContainer

creates a new directory

mkdir(string $path, int $mode, int $options) : bool

Parameters

$path

string

$mode

int

$options

int

Returns

bool

method to register the stream wrapper

register() 

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.

Exceptions

\org\bovigo\vfs\vfsStreamException

rename from one path to another

rename(string $path_from, string $path_to) : bool

author Benoit Aubuchon

Parameters

$path_from

string

$path_to

string

Returns

bool

removes a directory

rmdir(string $path, int $options) : bool

todo consider $options with STREAM_MKDIR_RECURSIVE

Parameters

$path

string

$options

int

Returns

bool

sets quota for disk space

setQuota(\org\bovigo\vfs\Quota $quota) 

since 1.1.0

Parameters

$quota

\org\bovigo\vfs\Quota

sets the root content

setRoot(\org\bovigo\vfs\vfsStreamContainer $root) : \org\bovigo\vfs\vfsStreamContainer

retrieve the underlaying resource

stream_cast(int $cast_as) : bool

Please note that this method always returns false as there is no underlaying resource to return.

since 0.9.0
see \org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/3

Parameters

$cast_as

int

Returns

bool

closes the stream

stream_close() 

see \org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/40

checks whether stream is at end of file

stream_eof() : bool

Returns

bool

flushes unstored data into storage

stream_flush() : bool

Returns

bool

set lock status for stream

stream_lock(int $operation) : bool

since 0.10.0
see \org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/6
see \org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/31
see \org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/40

Parameters

$operation

int

Returns

bool

open the stream

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

Returns

bool

read the stream up to $count bytes

stream_read(int $count) : string

Parameters

$count

int

amount of bytes to read

Returns

string

seeks to the given offset

stream_seek(int $offset, int $whence) : bool

Parameters

$offset

int

$whence

int

Returns

bool

sets options on the stream

stream_set_option(int $option, int $arg1, int $arg2) : bool

since 0.10.0
see \org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/15
see \org\bovigo\vfs\http://www.php.net/manual/streamwrapper.stream-set-option.php

Parameters

$option

int

key of option to set

$arg1

int

$arg2

int

Returns

bool

returns status of stream

stream_stat() : array

Returns

array

returns the current position of the stream

stream_tell() : int

Returns

int

truncates a file to a given length

stream_truncate(int $size) : bool

since 1.1.0

Parameters

$size

int

length to truncate file to

Returns

bool

writes data into the stream

stream_write(string $data) : int

Parameters

$data

string

Returns

intamount of bytes written

returns status of url

url_stat(string $path, int $flags) : array

Parameters

$path

string

path of url to return status for

$flags

int

flags set by the stream API

Returns

array

calculates the file mode

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

Returns

int

returns content for given path

getContent(string $path) : \org\bovigo\vfs\vfsStreamContent

Parameters

$path

string

Returns

returns content for given path but only when it is of given type

getContentOfType(string $path, int $type) : \org\bovigo\vfs\vfsStreamContent

Parameters

$path

string

$type

int

Returns

helper method to resolve a path from /foo/bar/.

resolvePath(string $path) : string

to /foo/bar

Parameters

$path

string

Returns

string

splits path into its dirname and the basename

splitPath(string $path) : string[]

Parameters

$path

string

Returns

string[]

creates a file at given path

createFile(string $path, string $mode, string $options) : bool

Parameters

$path

string

the path to open

$mode

string

mode for opening

$options

string

options for opening

Returns

bool

executes given permission change when necessary rights allow such a change

doPermChange(string $path, \org\bovigo\vfs\vfsStreamAbstractContent $content, \Closure $change) : bool

Parameters

$path

string

$change

\Closure

Returns

bool

helper method to detect whether given path is in root path

isInRoot(string $path) : bool

Parameters

$path

string

Returns

bool

 Properties

 

shortcut to file container

$content 

type vfsStreamFile
 

shortcut to directory container

$dir 

type vfsStreamDirectory
 

shortcut to directory container iterator

$dirIterator 

type vfsStreamDirectory
 

file mode: read only, write only, all

$mode 

type int
 

switch whether class has already been registered as stream wrapper or not

$registered 

type bool
 

root content

$root 

type vfsStreamContent
 

disk space quota

$quota 

type Quota

 Constants

 

file mode: read and write

ALL 

 

set file pointer to end, append new data

APPEND 

 

open file for reading

READ 

 

file mode: read only

READONLY 

 

truncate file

TRUNCATE 

 

set file pointer to start, overwrite existing data

WRITE 

 

file mode: write only

WRITEONLY 

 

set file pointer to start, overwrite existing data; or create file if does not exist

WRITE_NEW