Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
GuzzleHttp\Psr7\FnStream Class Reference
Inheritance diagram for GuzzleHttp\Psr7\FnStream:
Psr\Http\Message\StreamInterface

Public Member Functions

 __destruct ()
 The close method is called on the underlying stream only if possible.
 
foreach( $methods as $name=> $fn) __get (string $name)
 Lazily determine which methods are not implemented.
 
 __toString ()
 Reads all data from the stream into a string, from the beginning to end.
 
 __wakeup ()
 An unserialize would allow the __destruct to run when the unserialized value goes out of scope.
 
 close ()
 Closes the stream and any underlying resources.
 
 detach ()
 Separates any underlying resources from the stream.
 
 eof ()
 Returns true if the stream is at the end of the stream.
 
 getContents ()
 Returns the remaining contents in a string.
 
 getMetadata ($key=null)
 
 getSize ()
 Get the size of the stream if known.
 
 isReadable ()
 Returns whether or not the stream is readable.
 
 isSeekable ()
 Returns whether or not the stream is seekable.
 
 isWritable ()
 Returns whether or not the stream is writable.
 
 read ($length)
 Read data from the stream.
 
 rewind ()
 Seek to the beginning of the stream.
 
 seek ($offset, $whence=SEEK_SET)
 Seek to a position in the stream.
 
 tell ()
 Returns the current position of the file read/write pointer.
 
 write ($string)
 Write data to the stream.
 

Static Public Member Functions

static decorate (StreamInterface $stream, array $methods)
 Adds custom functionality to an underlying stream by intercepting specific method calls.
 

Member Function Documentation

◆ __get()

foreach($methods as $name=> $fn) GuzzleHttp\Psr7\FnStream::__get ( string $name)

Lazily determine which methods are not implemented.

Exceptions
BadMethodCallException

◆ __toString()

GuzzleHttp\Psr7\FnStream::__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
http://php.net/manual/en/language.oop5.magic.php#object.tostring
Return values
string

Implements Psr\Http\Message\StreamInterface.

◆ __wakeup()

GuzzleHttp\Psr7\FnStream::__wakeup ( )

An unserialize would allow the __destruct to run when the unserialized value goes out of scope.

Exceptions
LogicException

◆ close()

GuzzleHttp\Psr7\FnStream::close ( )

Closes the stream and any underlying resources.

Return values
void

Implements Psr\Http\Message\StreamInterface.

◆ decorate()

static GuzzleHttp\Psr7\FnStream::decorate ( StreamInterface $stream,
array $methods )
static

Adds custom functionality to an underlying stream by intercepting specific method calls.

Parameters
StreamInterface$streamStream to decorate
array<string,callable>$methods Hash of method name to a closure
Return values
FnStream

◆ detach()

GuzzleHttp\Psr7\FnStream::detach ( )

Separates any underlying resources from the stream.

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

Return values
resource|nullUnderlying PHP stream, if any

Implements Psr\Http\Message\StreamInterface.

◆ eof()

GuzzleHttp\Psr7\FnStream::eof ( )

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

Return values
bool

Implements Psr\Http\Message\StreamInterface.

◆ getContents()

GuzzleHttp\Psr7\FnStream::getContents ( )

Returns the remaining contents in a string.

Return values
string
Exceptions
RuntimeExceptionif unable to read or an error occurs while reading.

Implements Psr\Http\Message\StreamInterface.

◆ getMetadata()

GuzzleHttp\Psr7\FnStream::getMetadata ( $key = null)
Return values
mixed

Implements Psr\Http\Message\StreamInterface.

◆ getSize()

GuzzleHttp\Psr7\FnStream::getSize ( )

Get the size of the stream if known.

Return values
int|nullReturns the size in bytes if known, or null if unknown.

Implements Psr\Http\Message\StreamInterface.

◆ isReadable()

GuzzleHttp\Psr7\FnStream::isReadable ( )

Returns whether or not the stream is readable.

Return values
bool

Implements Psr\Http\Message\StreamInterface.

◆ isSeekable()

GuzzleHttp\Psr7\FnStream::isSeekable ( )

Returns whether or not the stream is seekable.

Return values
bool

Implements Psr\Http\Message\StreamInterface.

◆ isWritable()

GuzzleHttp\Psr7\FnStream::isWritable ( )

Returns whether or not the stream is writable.

Return values
bool

Implements Psr\Http\Message\StreamInterface.

◆ read()

GuzzleHttp\Psr7\FnStream::read ( $length)

Read data from the stream.

Parameters
int$lengthRead 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
stringReturns the data read from the stream, or an empty string if no bytes are available.
Exceptions
RuntimeExceptionif an error occurs.

Implements Psr\Http\Message\StreamInterface.

◆ rewind()

GuzzleHttp\Psr7\FnStream::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() @externalurl http://www.php.net/manual/en/function.fseek.php
Exceptions
RuntimeExceptionon failure.

Implements Psr\Http\Message\StreamInterface.

◆ seek()

GuzzleHttp\Psr7\FnStream::seek ( $offset,
$whence = SEEK_SET )

Seek to a position in the stream.

@externalurl http://www.php.net/manual/en/function.fseek.php

Parameters
int$offsetStream offset
int$whenceSpecifies 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.
Exceptions
RuntimeExceptionon failure.

Implements Psr\Http\Message\StreamInterface.

◆ tell()

GuzzleHttp\Psr7\FnStream::tell ( )

Returns the current position of the file read/write pointer.

Return values
intPosition of the file pointer
Exceptions
RuntimeExceptionon error.

Implements Psr\Http\Message\StreamInterface.

◆ write()

GuzzleHttp\Psr7\FnStream::write ( $string)

Write data to the stream.

Parameters
string$stringThe string that is to be written.
Return values
intReturns the number of bytes written to the stream.
Exceptions
RuntimeExceptionon failure.

Implements Psr\Http\Message\StreamInterface.


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