vfsStreamWrapper.php

Show: inherited
Table of Contents

Stream wrapper to mock file system requests.

Package
bovigo_vfs  

\vfsStreamWrapper

Package: bovigo\vfs

Stream wrapper to mock file system requests.

Constants

Constant  READ = 'r'

open file for reading

Constant  TRUNCATE = 'w'

truncate file

Constant  APPEND = 'a'

set file pointer to end, append new data

Constant  WRITE = 'x'

set file pointer to start, overwrite existing data

Constant  READONLY = 0

file mode: read only

Constant  WRITEONLY = 1

file mode: write only

Constant  ALL = 2

file mode: read and write

Properties

Propertyprotected\vfsStreamFile  $content= ''

shortcut to file container

Details
Type
\vfsStreamFile
Propertyprotected\vfsStreamDirectory  $dir= ''

shortcut to directory container

Details
Type
\vfsStreamDirectory
Propertyprotected\vfsStreamDirectory  $dirIterator= ''

shortcut to directory container iterator

Details
Type
\vfsStreamDirectory
Propertyprotectedint  $mode= ''

file mode: read only, write only, all

Details
Type
int
Propertyprotectedbool  $registered= 'false'
static

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

Default valuefalseDetails
Type
bool
Propertyprotected\vfsStreamContent  $root= ''
static

root content

Details
Type
\vfsStreamContent

Methods

methodprotectedcalculateMode( string $mode, bool $extended ) : int

calculates the file mode

Parameters
Name Type Description
$mode string

opening mode: r, w, a or x

$extended bool

true if + was set with opening mode

Returns
Type Description
int
methodpublicdir_closedir( ) : bool

closes directory

Returns
Type Description
bool
methodpublicdir_opendir( string $path, int $options ) : bool

opens a directory

Parameters
Name Type Description
$path string
$options int
Returns
Type Description
bool
methodpublicdir_readdir( ) : string

reads directory contents

Returns
Type Description
string
methodpublicdir_rewinddir( ) : bool

reset directory iteration

Returns
Type Description
bool
methodprotecteddoUnlink( string $path ) : bool

removes a path

Parameters
Name Type Description
$path string
Returns
Type Description
bool
methodprotectedgetContent( string $path ) : \vfsStreamContent

returns content for given path

Parameters
Name Type Description
$path string
Returns
Type Description
\vfsStreamContent
methodprotectedgetContentOfType( string $path, int $type ) : \vfsStreamContent

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

Parameters
Name Type Description
$path string
$type int
Returns
Type Description
\vfsStreamContent
methodpublicgetRoot( ) : \vfsStreamContainer
static

returns the root content

Returns
Type Description
\vfsStreamContainer
methodpublicmkdir( string $path, int $mode, int $options ) : bool

creates a new directory

Parameters
Name Type Description
$path string
$mode int
$options int
Returns
Type Description
bool
methodpublicregister( ) : void
static

method to register the stream wrapper

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.

Throws
Exception Description
\vfsStreamException
methodpublicrename( string $path_from, string $path_to ) : bool

rename from one path to another

Parameters
Name Type Description
$path_from string
$path_to string
Returns
Type Description
bool
Details
Author
Benoit Aubuchon  
methodprotectedresolvePath( string $path ) : string

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

Parameters
Name Type Description
$path string
Returns
Type Description
string
methodpublicrmdir( string $path, int $options ) : bool

removes a directory

Parameters
Name Type Description
$path string
$options int
Returns
Type Description
bool
Details
Todo
consider $options with STREAM_MKDIR_RECURSIVE  
methodpublicsetRoot( \vfsStreamContainer $root ) : \vfsStreamContainer
static

sets the root content

Parameters
Name Type Description
$root \vfsStreamContainer
Returns
Type Description
\vfsStreamContainer
methodprotectedsplitPath( string $path ) : array

splits path into its dirname and the basename

Parameters
Name Type Description
$path string
Returns
Type Description
array
methodpublicstream_cast( int $cast_as ) : bool

retrieve the underlaying resource

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

Parameters
Name Type Description
$cast_as int
Returns
Type Description
bool
Details
See
\https://github.com/mikey179/vfsStream/issues/3  
Since
0.9.0  
methodpublicstream_close( ) : void

closes the stream

methodpublicstream_eof( ) : bool

checks whether stream is at end of file

Returns
Type Description
bool
methodpublicstream_flush( ) : bool

flushes unstored data into storage

Returns
Type Description
bool
methodpublicstream_lock( int $operation ) : bool

set lock status for stream

Parameters
Name Type Description
$operation int
Returns
Type Description
bool
Details
See
\https://github.com/mikey179/vfsStream/issues/6  
Since
0.10.0  
methodpublicstream_open( string $path, string $mode, string $options, string $opened_path ) : bool

open the stream

Parameters
Name Type Description
$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
Type Description
bool
methodpublicstream_read( int $count ) : string

read the stream up to $count bytes

Parameters
Name Type Description
$count int

amount of bytes to read

Returns
Type Description
string
methodpublicstream_seek( int $offset, int $whence ) : bool

seeks to the given offset

Parameters
Name Type Description
$offset int
$whence int
Returns
Type Description
bool
methodpublicstream_set_option( int $option, int $arg1, int $arg2 ) : bool

sets options on the stream

Parameters
Name Type Description
$option int

key of option to set

$arg1 int
$arg2 int
Returns
Type Description
bool
Details
See
\https://github.com/mikey179/vfsStream/issues/15  
See
\http://www.php.net/manual/streamwrapper.stream-set-option.php  
Since
0.10.0  
methodpublicstream_stat( ) : array

returns status of stream

Returns
Type Description
array
methodpublicstream_tell( ) : int

returns the current position of the stream

Returns
Type Description
int
methodpublicstream_write( string $data ) : int

writes data into the stream

Parameters
Name Type Description
$data string
Returns
Type Description
int amount of bytes written
methodpublicunlink( string $path ) : bool

remove the data under the given path

Parameters
Name Type Description
$path string
Returns
Type Description
bool
methodpublicurl_stat( string $path, \? $flags ) : array

returns status of url

Parameters
Name Type Description
$path string

path of url to return status for

$flags \?

flags set by the stream API

Returns
Type Description
array
Documentation was generated by DocBlox 0.18.1.