diff --git a/src/Guzzle/Stream/Stream.php b/src/Guzzle/Stream/Stream.php index bb2279c1..5fe933b8 100644 --- a/src/Guzzle/Stream/Stream.php +++ b/src/Guzzle/Stream/Stream.php @@ -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 * diff --git a/src/Guzzle/Stream/StreamInterface.php b/src/Guzzle/Stream/StreamInterface.php index 7df9acff..59df534e 100644 --- a/src/Guzzle/Stream/StreamInterface.php +++ b/src/Guzzle/Stream/StreamInterface.php @@ -14,6 +14,11 @@ interface StreamInterface */ public function __toString(); + /** + * Close the underlying stream + */ + public function close(); + /** * Get stream metadata *