PHP Class VCR\Util\StreamProcessor

Author: Ignas Rudaitis ([email protected])
Author: Adrian Philipp ([email protected])
ファイルを表示 Open project: php-vcr/php-vcr Class Usage Examples

Public Properties

Property Type Description
$context The current context, or NULL if no context was passed to the caller function.

Protected Properties

Property Type Description
$codeTransformers VCR\CodeTransform\AbstractCodeTransform[] Transformers which have been appended to this stream processor.
$configuration VCR\Configuration
$isIntercepting boolean
$resource Resource for the currently opened file.

Public Methods

Method Description
__construct ( Configuration $configuration = null )
appendCodeTransformer ( VCR\CodeTransform\AbstractCodeTransform $codeTransformer ) : void Adds code transformer to the stream processor.
detachCodeTransformer ( VCR\CodeTransform\AbstractCodeTransform $codeTransformer ) : void Removes a code transformer from the stream processor.
dir_closedir ( ) : boolean Close directory handle.
dir_opendir ( string $path ) : boolean Open directory handle.
dir_readdir ( ) : mixed Read entry from directory handle.
dir_rewinddir ( ) : boolean Rewind directory handle.
intercept ( ) : void Registers current class as the PHP file stream wrapper.
mkdir ( string $path, integer $mode, integer $options ) : boolean Create a directory.
rename ( string $path_from, string $path_to ) : boolean Renames a file or directory.
restore ( ) : void Restores the original file stream wrapper status.
rmdir ( string $path ) : boolean Removes a directory
stream_cast ( integer $cast_as ) : resource Retrieve the underlaying resource.
stream_close ( ) : boolean Close an resource.
stream_eof ( ) : boolean Tests for end-of-file on a file pointer.
stream_flush ( ) : boolean Flushes the output.
stream_lock ( integer $operation ) : boolean Advisory file locking.
stream_metadata ( string $path, integer $option, mixed $value ) : boolean Change stream options.
stream_open ( string $path, string $mode, integer $options, string &$openedPath ) : boolean Opens a stream and attaches registered filters.
stream_read ( integer $count ) : string Read from stream.
stream_seek ( integer $offset, integer $whence = SEEK_SET ) : boolean Seeks to specific location in a stream.
stream_set_option ( integer $option, integer $arg1, integer $arg2 ) : boolean Change stream options.
stream_stat ( ) : array Retrieve information about a file resource.
stream_tell ( ) : integer Retrieve the current position of a stream.
stream_truncate ( integer $new_size ) : boolean Truncate stream.
stream_write ( string $data ) : integer Write to stream.
unlink ( string $path ) : boolean Delete a file.
url_stat ( string $path, integer $flags ) : integer Retrieve information about a file.

Protected Methods

Method Description
appendFiltersToStream ( resource $stream ) Appends the current set of php_user_filter to the provided stream.
isBlacklisted ( string $uri ) : boolean Determines that the provided url is member of a url blacklist.
isPhpFile ( string $uri ) : boolean Determines that the provided uri leads to a PHP file.
isWhitelisted ( string $uri ) : boolean Determines that the provided url is member of a url whitelist.
shouldProcess ( string $uri ) : boolean

Private Methods

Method Description
normalizePath ( string $path ) : string Normalizes the path, to always use the slash as directory separator.

Method Details

__construct() public method

public __construct ( Configuration $configuration = null )
$configuration VCR\Configuration

appendCodeTransformer() public method

Adds code transformer to the stream processor.
public appendCodeTransformer ( VCR\CodeTransform\AbstractCodeTransform $codeTransformer ) : void
$codeTransformer VCR\CodeTransform\AbstractCodeTransform
return void

appendFiltersToStream() protected method

Appends the current set of php_user_filter to the provided stream.
protected appendFiltersToStream ( resource $stream )
$stream resource

detachCodeTransformer() public method

Removes a code transformer from the stream processor.
public detachCodeTransformer ( VCR\CodeTransform\AbstractCodeTransform $codeTransformer ) : void
$codeTransformer VCR\CodeTransform\AbstractCodeTransform
return void

dir_closedir() public method

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

dir_opendir() public method

Open directory handle.
public dir_opendir ( string $path ) : boolean
$path string The file path or URL to stat.
return boolean Returns TRUE on success or FALSE on failure.

dir_readdir() public method

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

dir_rewinddir() public method

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

intercept() public method

Registers current class as the PHP file stream wrapper.
public intercept ( ) : void
return void

isBlacklisted() protected method

Determines that the provided url is member of a url blacklist.
protected isBlacklisted ( string $uri ) : boolean
$uri string
return boolean True if the provided url is blacklisted, false otherwise.

isPhpFile() protected method

Determines that the provided uri leads to a PHP file.
protected isPhpFile ( string $uri ) : boolean
$uri string
return boolean

isWhitelisted() protected method

Determines that the provided url is member of a url whitelist.
protected isWhitelisted ( string $uri ) : boolean
$uri string
return boolean True if the specified url is whitelisted, false otherwise.

mkdir() public method

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 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

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.

restore() public method

Restores the original file stream wrapper status.
public restore ( ) : void
return void

rmdir() public method

Removes a directory
public rmdir ( string $path ) : boolean
$path string The directory URL which should be removed.
return boolean Returns TRUE on success or FALSE on failure.

shouldProcess() protected method

protected shouldProcess ( string $uri ) : boolean
$uri string
return boolean

stream_cast() public method

Retrieve the underlaying resource.
public stream_cast ( integer $cast_as ) : resource
$cast_as integer Can be STREAM_CAST_FOR_SELECT when stream_select() is calling stream_cast() or STREAM_CAST_AS_STREAM when stream_cast() is called for other uses.
return resource Should return the underlying stream resource used by the wrapper, or FALSE.

stream_close() public method

Close an resource.
public stream_close ( ) : boolean
return boolean

stream_eof() public method

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

Flushes the output.
public stream_flush ( ) : boolean
return boolean

stream_lock() public method

Advisory file locking.
public stream_lock ( integer $operation ) : boolean
$operation integer One of the operation constantes.
return boolean Returns TRUE on success or FALSE on failure.

stream_metadata() public method

Change stream options.
public stream_metadata ( string $path, integer $option, mixed $value ) : boolean
$path string The file path or URL to set metadata.
$option integer One of the stream options.
$value mixed Value depending on the option.
return boolean Returns TRUE on success or FALSE on failure.

stream_open() public method

Opens a stream and attaches registered filters.
public stream_open ( string $path, string $mode, integer $options, string &$openedPath ) : 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.
$openedPath 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

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

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_set_option() public method

Change stream options.
public stream_set_option ( integer $option, integer $arg1, integer $arg2 ) : boolean
$option integer One of STREAM_OPTION_BLOCKING, STREAM_OPTION_READ_TIMEOUT, STREAM_OPTION_WRITE_BUFFER.
$arg1 integer Depending on option.
$arg2 integer Depending on option.
return boolean Returns TRUE on success or FALSE on failure. If option is not implemented, FALSE should be returned.

stream_stat() public method

Retrieve information about a file resource.
public stream_stat ( ) : array
return array See stat().

stream_tell() public method

This method is called in response to fseek() to determine the current position.
public stream_tell ( ) : integer
return integer Should return the current position of the stream.

stream_truncate() public method

Truncate stream.
public stream_truncate ( integer $new_size ) : boolean
$new_size integer The new size.
return boolean Returns TRUE on success or FALSE on failure.

stream_write() public method

Write to stream.
public stream_write ( string $data ) : integer
$data string Should be stored into the underlying stream.
return integer

url_stat() public method

Retrieve information about a file.
public url_stat ( string $path, integer $flags ) : integer
$path string The file path or URL to stat.
$flags integer Holds additional flags set by the streams API.
return integer Should return as many elements as stat() does.

Property Details

$codeTransformers protected_oe static_oe property

Transformers which have been appended to this stream processor.
protected static AbstractCodeTransform[],VCR\CodeTransform $codeTransformers
return VCR\CodeTransform\AbstractCodeTransform[]

$configuration protected_oe static_oe property

protected static Configuration,VCR $configuration
return VCR\Configuration

$context public_oe property

The current context, or NULL if no context was passed to the caller function.
public $context

$isIntercepting protected_oe property

protected bool $isIntercepting
return boolean

$resource protected_oe property

Resource for the currently opened file.
protected $resource