Documentation

ChunkStream extends FilteredStream
in package

Transform a regular stream into a chunked one.

Tags
author

Joel Wurtz joel.wurtz@gmail.com

Table of Contents

Constants

BUFFER_SIZE  = 8192

Properties

$buffer  : string
Internal buffer.
$readFilter  : resource
$readFilterCallback  : callable
$stream  : StreamInterface
$writeFilter  : resource
$writeFilterCallback  : callable

Methods

__construct()  : mixed
__toString()  : string
Reads all data from the stream into a string, from the beginning to end.
close()  : void
detach()  : mixed
eof()  : bool
Returns true if the stream is at the end of the stream.
getContents()  : string
Returns the remaining contents in a string
getMetadata()  : mixed
getReadFilter()  : string
Returns the read filter name.
getSize()  : int|null
Always returns null because we can't tell the size of a stream when we filter.
getWriteFilter()  : string
Returns the write filter name.
isReadable()  : bool
isSeekable()  : bool
Filtered streams are not seekable.
isWritable()  : bool
read()  : string
Read data from the stream.
rewind()  : void
Filtered streams are not seekable and can thus not be rewound.
seek()  : void
Filtered streams are not seekable.
tell()  : int
write()  : int
fill()  : void
Buffer is filled by reading underlying stream.
readFilter()  : string
Returns the write filter name.
writeFilter()  : string
Returns the write filter name.

Constants

Properties

$readFilter

since version 1.5, will be removed in 2.0

protected resource $readFilter

$writeFilter

since version 1.5, will be removed in 2.0

protected resource $writeFilter

$writeFilterCallback

since version 1.5, will be removed in 2.0

protected callable $writeFilterCallback

Methods

__construct()

public __construct(StreamInterface $stream[, mixed|null $readFilterOptions = null ][, mixed|null $writeFilterOptions = null ]) : mixed
Parameters
$stream : StreamInterface
$readFilterOptions : mixed|null = null
$writeFilterOptions : mixed|null = null

deprecated since 1.5, will be removed in 2.0

__toString()

Reads all data from the stream into a string, from the beginning to end.

public __toString() : string

This method MUST attempt to seek to the beginning of the stream before reading data and read the stream until the end is reached.

Warning: This could attempt to load a large amount of data into memory.

This method MUST NOT raise an exception in order to conform with PHP's string casting operations.

Return values
string

eof()

Returns true if the stream is at the end of the stream.

public eof() : bool
Return values
bool

getContents()

Returns the remaining contents in a string

public getContents() : string
Return values
string

getMetadata()

public getMetadata([string|null $key = null ]) : mixed
Parameters
$key : string|null = null

getReadFilter()

Returns the read filter name.

public getReadFilter() : string

since version 1.5, will be removed in 2.0

Return values
string

getSize()

Always returns null because we can't tell the size of a stream when we filter.

public getSize() : int|null
Return values
int|null

Returns the size in bytes if known, or null if unknown.

getWriteFilter()

Returns the write filter name.

public getWriteFilter() : string

since version 1.5, will be removed in 2.0

Return values
string

isSeekable()

Filtered streams are not seekable.

public isSeekable() : bool

We would need to buffer and process everything to allow seeking.

Return values
bool

read()

Read data from the stream.

public read(int $length) : string
Parameters
$length : int

Read up to $length bytes from the object and return them. Fewer than $length bytes may be returned if underlying stream call returns fewer bytes.

Return values
string

Returns the data read from the stream, or an empty string if no bytes are available.

rewind()

Filtered streams are not seekable and can thus not be rewound.

public rewind() : void

seek()

Filtered streams are not seekable.

public seek(int $offset[, int $whence = SEEK_SET ]) : void
Parameters
$offset : int

Stream offset

$whence : int = SEEK_SET

Specifies how the cursor position will be calculated based on the seek offset. Valid values are identical to the built-in PHP $whence values for fseek(). SEEK_SET: Set position equal to offset bytes SEEK_CUR: Set position to current location plus offset SEEK_END: Set position to end-of-stream plus offset.

write()

public write(string $string) : int
Parameters
$string : string
Return values
int

fill()

Buffer is filled by reading underlying stream.

protected fill() : void

Callback is reading once more even if the stream is ended. This allow to get last data in the PHP buffer otherwise this bug is present : https://bugs.php.net/bug.php?id=48725

readFilter()

Returns the write filter name.

protected readFilter() : string
Return values
string

writeFilter()

Returns the write filter name.

protected writeFilter() : string
Return values
string

        
On this page

Search results