IterableStream
final class IterableStream implements StreamInterface (View source)
Represents a one-pass response body that reads lazy producer chunks without assembling the full content in memory
Methods
Initializes a one-pass producer that lazily yields string chunks while the stream is read
Creates a body whose producer is not invoked until its first read
Reads the remaining content for PSR-7 string conversion, which may use memory proportional to the body size
Stops the producer and discards all unread chunks
Detaches the one-pass producer and returns null because this body has no resource handle
Returns null because the producer total size is not known in advance
Returns the number of bytes read from this one-pass stream
Reports whether the producer has no remaining chunks or the stream was closed
Reports false because a generator producer cannot return to an earlier position
Rejects repositioning within the one-pass stream
Rejects rewinding the one-pass producer
Reports false because response bodies created from producers do not accept writes
Rejects writes to the read-only response body
Reports whether the stream remains open for reading
Reads at most the requested byte count while retaining only the current chunk and its unread remainder
Reads all remaining chunks, a PSR-7 operation that may use memory proportional to the body size
Returns metadata for the one-pass read-only producer
Details
__construct
__construct(Closure $producer)
Initializes a one-pass producer that lazily yields string chunks while the stream is read
from
static IterableStream
from(callable $producer)
Creates a body whose producer is not invoked until its first read
__toString
string
__toString()
Reads the remaining content for PSR-7 string conversion, which may use memory proportional to the body size
close
void
close()
Stops the producer and discards all unread chunks
detach
null
detach()
Detaches the one-pass producer and returns null because this body has no resource handle
getSize
int|null
getSize()
Returns null because the producer total size is not known in advance
tell
int
tell()
Returns the number of bytes read from this one-pass stream
eof
bool
eof()
Reports whether the producer has no remaining chunks or the stream was closed
isSeekable
bool
isSeekable()
Reports false because a generator producer cannot return to an earlier position
seek
void
seek(int $offset, int $whence = SEEK_SET)
Rejects repositioning within the one-pass stream
rewind
void
rewind()
Rejects rewinding the one-pass producer
isWritable
bool
isWritable()
Reports false because response bodies created from producers do not accept writes
write
int
write(string $string)
Rejects writes to the read-only response body
isReadable
bool
isReadable()
Reports whether the stream remains open for reading
read
string
read(int $length)
Reads at most the requested byte count while retaining only the current chunk and its unread remainder
getContents
string
getContents()
Reads all remaining chunks, a PSR-7 operation that may use memory proportional to the body size
getMetadata
mixed
getMetadata(string|null $key = null)
Returns metadata for the one-pass read-only producer