Doesn't close the underlying stream when 'close' is called on it. Instead, calling close simply removes any reference to the underlying stream. Note that GuzzleHttp\Psr7\Stream calls close in __destruct, so a reference to the Stream needs to be kept. For example:
$f = fopen('php://temp', 'r+');
$test = new NonClosingStream(Psr7\Utils::streamFor('test'));
// work
$test->close();
rewind($f); // error, $f is a closed resource
Instead, this would work:
$stream = Psr7\Utils::streamFor(fopen('php://temp', 'r+'));
$test = new NonClosingStream($stream);
// work
$test->close();
$stream->rewind(); // works
- author Zaahid Bateson
CloneableInstantiable
- Implements
Psr\Http\Message\StreamInterface Stringable - Traits
Methods |
public __call(string $method, array $args) Allow decorators to implement custom methods
|
public __construct(Psr\Http\Message\StreamInterface $stream)
|
public __get(string $name) Magic method used to create a new stream if streams are not added in the constructor of a decorator (e.g., LazyOpenStream).
|
public __toString() : string |
public close() : void
|
public detach() Overridden to detach the underlying stream without closing it.
|
public eof() : bool |
public getContents() : string |
public getMetadata( $key = NULL)
|
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 |
Methods |
protected createStream() : Psr\Http\Message\StreamInterface Implement in subclasses to dynamically create streams when requested.
|
Properties |
private ?Psr\Http\Message\StreamInterface $stream
|