Documentation

CombineWrapper
in package

A stream wrapper that will combine multiple strings/streams into a single stream. Stream Wrappers implement method signatures defined in the builtin class streamWrapper but they do not need to inherit from it. Not all methods of streamWrapper need to be implemented. We follow the signatures as defined in the php manual

Tags
author

Michael Slusarz slusarz@horde.org

category

Horde

copyright

2009-2017 Horde LLC

license

http://www.horde.org/licenses/bsd BSD

Table of Contents

Constants

WRAPPER_NAME  = 'horde-stream-wrapper-combine'

Properties

$context  : resource
Context.
$ateof  : bool
Have we reached EOF?
$data  : array<string|int, mixed>
Array that holds the various streams.
$datapos  : int
The current position in the data array.
$length  : int
The combined length of the stream.
$position  : int
The current position in the string.
$id  : int
Unique ID tracker for the streams.

Methods

getStream()  : resource|false
Create a stream from multiple data sources.
stream_eof()  : bool
stream_open()  : bool
stream_read()  : string
stream_seek()  : bool
stream_stat()  : array<string|int, int>
stream_tell()  : int
stream_write()  : int

Constants

WRAPPER_NAME

public mixed WRAPPER_NAME = 'horde-stream-wrapper-combine'

Properties

$data

Array that holds the various streams.

protected array<string|int, mixed> $data = []

$datapos

The current position in the data array.

protected int $datapos = 0

$length

The combined length of the stream.

protected int $length = 0

$position

The current position in the string.

protected int $position = 0

$id

Unique ID tracker for the streams.

private static int $id = 0

Methods

getStream()

Create a stream from multiple data sources.

public static getStream(array<string|int, mixed> $data) : resource|false
Parameters
$data : array<string|int, mixed>

An array of strings and/or streams to combine into a single stream.

Tags
since
2.1.0
Return values
resource|false

A PHP stream.

stream_eof()

public stream_eof() : bool
Tags
see
streamWrapper::stream_eof()
Return values
bool

stream_open()

public stream_open(string $path, string $mode, int $options[, string|null &$opened_path = null ]) : bool
Parameters
$path : string
$mode : string
$options : int
$opened_path : string|null = null
Tags
see
streamWrapper::stream_open()
throws
Exception
Return values
bool

success

stream_read()

public stream_read(int $count) : string
Parameters
$count : int

streamWrapper reference signature says it always returns string However the docs say further: If there are less than count byte If no more data is available, return either false or an empty string.

We follow the stricter interface and return empty string. This may break deriving class when upgrading from H5.

Tags
see
streamWrapper::stream_read()
Return values
string

stream_seek()

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

SEEK_SET, SEEK_CUR, or SEEK_END

Tags
see
streamWrapper::stream_seek()
Return values
bool

stream_stat()

public stream_stat() : array<string|int, int>
Tags
see
streamWrapper::stream_stat()

streamWrapper docs offer array|false return type. As we will always return an array, we go for the stricter interface

Return values
array<string|int, int>

stream_tell()

public stream_tell() : int
Tags
see
streamWrapper::stream_tell()
Return values
int

stream_write()

public stream_write(string $data) : int
Parameters
$data : string

Previous versions returned int|false.

streamWrapper reference signature says it always returns int Should return the number of bytes that were successfully stored, or 0 if none could be stored.

This may break deriving class when upgrading from H5.

Tags
see
streamWrapper::stream_write()
Return values
int

        
On this page

Search results