Copied!

Provides a read only stream that pumps data from a PHP callable.

When invoking the provided callable, the PumpStream will pass the suggested number of bytes to read to the callable. The callable can choose to ignore this value and return fewer or more bytes than requested. Any extra data returned by the callable is buffered internally until drained using the read() function of the PumpStream. The callable MUST return false or null when there is no more data to read.

Userland callables that declare no parameters are tolerated by PHP, but length-aware callables remain the recommended formal shape.

CloneableFinalInstantiable
  • Implements
    Psr\Http\Message\StreamInterface
    Stringable
Methods
public __construct(callable $source, array $options = [])
 
  • param callable(): string|false|null|callable(int): string|false|null $source Source of the stream data. The callable receives the suggested number of bytes to read, may ignore that value, and may return fewer or more bytes. Extra bytes are buffered. The callable MUST return a string when called, or false|null on error or EOF. Userland callables that declare no parameters are tolerated by PHP, but length-aware callables remain the recommended formal shape.
  • param array{size?: int, metadata?: array} $options Stream options:
    • metadata: Hash of metadata to use with stream.
    • size: Size of the stream, if known.
public __toString() : string
public close() : void
public detach()
public eof() : bool
public getContents() : string
public getMetadata( $key = NULL)
 
  • return mixed
public getSize() : ?int
public isReadable() : bool
public isSeekable() : bool
public isWritable() : bool
public read( $length) : string
public rewind() : void
public seek( $offset, $whence = 0GuzzleHttp\Psr7\SEEK_SET) : void
public tell() : int
public write( $string) : int
Properties
private $buffer = NULL
 
  • var \BufferStream
private $metadata = NULL
 
  • var array
private $size = NULL
 
  • var int|null
private $source = NULL
 
  • var callable|null
private $tellPos = 0
 
  • var int
Methods
private pump(int $length) : void
© 2026 Bruce Wells
Search Namespaces \ Classes
Configuration