‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Http\Stream Class Reference
Inheritance diagram for TYPO3\CMS\Core\Http\Stream:

Public Member Functions

 __construct ($stream, string $mode='r')
string __toString ()
 close ()
resource null detach ()
int null getSize ()
int tell ()
 eof ()
 isSeekable ()
 seek (int $offset, int $whence=SEEK_SET)
 rewind ()
 isWritable ()
int write (string $string)
 isReadable ()
string read (int $length)
 getContents ()
array mixed null getMetadata (?string $key=null)
 attach ($resource, string $mode='r')

Protected Attributes

resource null $resource
string resource $stream

Detailed Description

Default implementation for the StreamInterface of the PSR-7 standard Acts mainly as a decorator class for streams/resources.

Highly inspired by https://github.com/phly/http/

Note that this is not public API yet.

Definition at line 30 of file Stream.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Http\Stream::__construct (   $stream,
string  $mode = 'r' 

Constructor setting up the PHP resource

string | resource$stream
string$mode‪Mode with which to open stream

Definition at line 48 of file Stream.php.

References TYPO3\CMS\Core\Http\Stream\$stream.

Member Function Documentation

◆ __toString()

string TYPO3\CMS\Core\Http\Stream::__toString ( )

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

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.

See also

Definition at line 74 of file Stream.php.

References TYPO3\CMS\Core\Http\Stream\getContents(), TYPO3\CMS\Core\Http\Stream\isReadable(), and TYPO3\CMS\Core\Http\Stream\rewind().

◆ attach()

TYPO3\CMS\Core\Http\Stream::attach (   $resource,
string  $mode = 'r' 

Attach a new stream/resource to the instance.

string | resource$resource

Definition at line 336 of file Stream.php.

References TYPO3\CMS\Core\Http\Stream\$resource.

◆ close()

TYPO3\CMS\Core\Http\Stream::close ( )

Closes the stream and any underlying resources.

Definition at line 90 of file Stream.php.

References TYPO3\CMS\Core\Http\Stream\$resource, and TYPO3\CMS\Core\Http\Stream\detach().

◆ detach()

resource null TYPO3\CMS\Core\Http\Stream::detach ( )

Separates any underlying resources from the stream.

After the stream has been detached, the stream is in an unusable state.

‪resource|null Underlying PHP stream, if any

Definition at line 109 of file Stream.php.

References TYPO3\CMS\Core\Http\Stream\$resource.

Referenced by TYPO3\CMS\Core\Http\Stream\close().

◆ eof()

TYPO3\CMS\Core\Http\Stream::eof ( )

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

Definition at line 151 of file Stream.php.

◆ getContents()

TYPO3\CMS\Core\Http\Stream::getContents ( )

Returns the remaining contents in a string


Definition at line 287 of file Stream.php.

References TYPO3\CMS\Core\Http\Stream\isReadable().

Referenced by TYPO3\CMS\Core\Http\Stream\__toString().

◆ getMetadata()

array mixed null TYPO3\CMS\Core\Http\Stream::getMetadata ( ?string  $key = null)

◆ getSize()

int null TYPO3\CMS\Core\Http\Stream::getSize ( )

Get the size of the stream if known.

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

Definition at line 121 of file Stream.php.

◆ isReadable()

TYPO3\CMS\Core\Http\Stream::isReadable ( )

◆ isSeekable()

TYPO3\CMS\Core\Http\Stream::isSeekable ( )

Returns whether the stream is seekable.

Definition at line 162 of file Stream.php.

References TYPO3\CMS\Core\Http\Stream\getMetadata().

Referenced by TYPO3\CMS\Core\Http\Stream\seek().

◆ isWritable()

TYPO3\CMS\Core\Http\Stream::isWritable ( )

Returns whether the stream is writable.

Definition at line 217 of file Stream.php.

References TYPO3\CMS\Core\Http\Stream\getMetadata().

◆ read()

string TYPO3\CMS\Core\Http\Stream::read ( int  $length)

Read data from the stream.

int$length‪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.
‪string Returns the data read from the stream, or an empty string if no bytes are available.

Definition at line 267 of file Stream.php.

References TYPO3\CMS\Core\Http\Stream\isReadable().

◆ rewind()

TYPO3\CMS\Core\Http\Stream::rewind ( )

Seek to the beginning of the stream.

If the stream is not seekable, this method will raise an exception; otherwise, it will perform a seek(0).

See also
seek() on failure.

Definition at line 209 of file Stream.php.

References TYPO3\CMS\Core\Http\Stream\seek().

Referenced by TYPO3\CMS\Core\Http\Stream\__toString().

◆ seek()

◆ tell()

int TYPO3\CMS\Core\Http\Stream::tell ( )

Returns the current position of the file read/write pointer

‪int Position of the file pointer

Definition at line 136 of file Stream.php.

◆ write()

int TYPO3\CMS\Core\Http\Stream::write ( string  $string)

Write data to the stream.

string$string‪The string that is to be written.
‪int Returns the number of bytes written to the stream.

Definition at line 233 of file Stream.php.

Member Data Documentation

◆ $resource

resource null TYPO3\CMS\Core\Http\Stream::$resource

The actual PHP resource

Definition at line 35 of file Stream.php.

Referenced by TYPO3\CMS\Core\Http\Stream\attach(), TYPO3\CMS\Core\Http\Stream\close(), and TYPO3\CMS\Core\Http\Stream\detach().

◆ $stream

string resource TYPO3\CMS\Core\Http\Stream::$stream

Definition at line 39 of file Stream.php.

Referenced by TYPO3\CMS\Core\Http\Stream\__construct().