mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-25 10:33:18 +01:00
Adding close() method to stream objects
This commit is contained in:
parent
d9c2824046
commit
38cd929fc8
@ -70,9 +70,7 @@ class Stream implements StreamInterface
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if (is_resource($this->stream)) {
|
||||
fclose($this->stream);
|
||||
}
|
||||
$this->close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,6 +89,18 @@ class Stream implements StreamInterface
|
||||
return $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
if (is_resource($this->stream)) {
|
||||
fclose($this->stream);
|
||||
}
|
||||
$this->cache[self::IS_READABLE] = false;
|
||||
$this->cache[self::IS_WRITABLE] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate a hash of a Stream
|
||||
*
|
||||
|
@ -14,6 +14,11 @@ interface StreamInterface
|
||||
*/
|
||||
public function __toString();
|
||||
|
||||
/**
|
||||
* Close the underlying stream
|
||||
*/
|
||||
public function close();
|
||||
|
||||
/**
|
||||
* Get stream metadata
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user