MediaWiki master
MediaWiki\Rest\StringStream Class Reference

A stream class which uses a string as the underlying storage. More...

Inherits Stringable, and MediaWiki\Rest\CopyableStreamInterface.

Collaboration diagram for MediaWiki\Rest\StringStream:

Public Member Functions

 __construct (private string $contents='',)
 Construct a StringStream with the given contents.
 __toString ()
 close ()
 copyToStream ( $stream)
 Copy this stream to a specified stream resource.For some streams, this can be implemented without a tight loop in PHP code.Equivalent to reading from the object until EOF and writing the resulting data to $stream. The position will be advanced to the end.Note that $stream is not a StreamInterface object.
Parameters
resource$streamDestination

 detach ()
 eof ()
 getContents ()
 getMetadata (?string $key=null)
 getSize ()
 isReadable ()
 isSeekable ()
 isWritable ()
 read (int $length)
 rewind ()
 seek (int $offset, int $whence=SEEK_SET)
 tell ()
 write (string $string)

Detailed Description

A stream class which uses a string as the underlying storage.

Surprisingly, Guzzle does not appear to have one of these. BufferStream does not do what we want.

The normal use of this class should be to first write to the stream, then rewind, then read back the whole buffer with getContents().

Seeking is supported, however seeking past the end of the string does not fill with null bytes as in a real file, it throws an exception instead.

Definition at line 19 of file StringStream.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Rest\StringStream::__construct ( private string $contents = '')

Construct a StringStream with the given contents.

The offset will start at 0, ready for reading. If appending to the given string is desired, you should first seek to the end.

Definition at line 30 of file StringStream.php.

Member Function Documentation

◆ __toString()

MediaWiki\Rest\StringStream::__toString ( )

Definition at line 40 of file StringStream.php.

References return.

◆ close()

MediaWiki\Rest\StringStream::close ( )

Definition at line 44 of file StringStream.php.

◆ copyToStream()

MediaWiki\Rest\StringStream::copyToStream ( $stream)

Copy this stream to a specified stream resource.For some streams, this can be implemented without a tight loop in PHP code.Equivalent to reading from the object until EOF and writing the resulting data to $stream. The position will be advanced to the end.Note that $stream is not a StreamInterface object.

Parameters
resource$streamDestination

Implements MediaWiki\Rest\CopyableStreamInterface.

Definition at line 36 of file StringStream.php.

References getContents().

◆ detach()

MediaWiki\Rest\StringStream::detach ( )

Definition at line 48 of file StringStream.php.

References detach().

Referenced by detach().

◆ eof()

MediaWiki\Rest\StringStream::eof ( )

Definition at line 63 of file StringStream.php.

References return.

◆ getContents()

MediaWiki\Rest\StringStream::getContents ( )

Definition at line 139 of file StringStream.php.

References if.

Referenced by copyToStream().

◆ getMetadata()

MediaWiki\Rest\StringStream::getMetadata ( ?string $key = null)

Definition at line 152 of file StringStream.php.

◆ getSize()

MediaWiki\Rest\StringStream::getSize ( )

Definition at line 53 of file StringStream.php.

References return.

◆ isReadable()

MediaWiki\Rest\StringStream::isReadable ( )

Definition at line 121 of file StringStream.php.

References return.

◆ isSeekable()

MediaWiki\Rest\StringStream::isSeekable ( )

Definition at line 68 of file StringStream.php.

References return.

◆ isWritable()

MediaWiki\Rest\StringStream::isWritable ( )

Definition at line 104 of file StringStream.php.

References return.

◆ read()

MediaWiki\Rest\StringStream::read ( int $length)

Definition at line 126 of file StringStream.php.

References if.

◆ rewind()

MediaWiki\Rest\StringStream::rewind ( )

Definition at line 99 of file StringStream.php.

◆ seek()

MediaWiki\Rest\StringStream::seek ( int $offset,
int $whence = SEEK_SET )

Definition at line 73 of file StringStream.php.

◆ tell()

MediaWiki\Rest\StringStream::tell ( )

Definition at line 58 of file StringStream.php.

References return.

◆ write()

MediaWiki\Rest\StringStream::write ( string $string)

Definition at line 109 of file StringStream.php.

References if.


The documentation for this class was generated from the following file: