diff vendor/guzzlehttp/psr7/src/Stream.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
line wrap: on
line diff
--- a/vendor/guzzlehttp/psr7/src/Stream.php	Tue Jul 10 15:07:59 2018 +0100
+++ b/vendor/guzzlehttp/psr7/src/Stream.php	Thu Feb 28 13:21:36 2019 +0000
@@ -24,11 +24,11 @@
             'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true,
             'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true,
             'c+b' => true, 'rt' => true, 'w+t' => true, 'r+t' => true,
-            'x+t' => true, 'c+t' => true, 'a+' => true
+            'x+t' => true, 'c+t' => true, 'a+' => true, 'rb+' => true,
         ],
         'write' => [
             'w' => true, 'w+' => true, 'rw' => true, 'r+' => true, 'x+' => true,
-            'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true,
+            'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true, 'rb+' => true,
             'x+b' => true, 'c+b' => true, 'w+t' => true, 'r+t' => true,
             'x+t' => true, 'c+t' => true, 'a' => true, 'a+' => true
         ]
@@ -70,15 +70,6 @@
         $this->uri = $this->getMetadata('uri');
     }
 
-    public function __get($name)
-    {
-        if ($name == 'stream') {
-            throw new \RuntimeException('The stream is detached');
-        }
-
-        throw new \BadMethodCallException('No value for ' . $name);
-    }
-
     /**
      * Closes the stream when the destructed
      */
@@ -99,6 +90,10 @@
 
     public function getContents()
     {
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
+
         $contents = stream_get_contents($this->stream);
 
         if ($contents === false) {
@@ -173,11 +168,19 @@
 
     public function eof()
     {
-        return !$this->stream || feof($this->stream);
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
+
+        return feof($this->stream);
     }
 
     public function tell()
     {
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
+
         $result = ftell($this->stream);
 
         if ($result === false) {
@@ -194,9 +197,13 @@
 
     public function seek($offset, $whence = SEEK_SET)
     {
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
         if (!$this->seekable) {
             throw new \RuntimeException('Stream is not seekable');
-        } elseif (fseek($this->stream, $offset, $whence) === -1) {
+        }
+        if (fseek($this->stream, $offset, $whence) === -1) {
             throw new \RuntimeException('Unable to seek to stream position '
                 . $offset . ' with whence ' . var_export($whence, true));
         }
@@ -204,6 +211,9 @@
 
     public function read($length)
     {
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
         if (!$this->readable) {
             throw new \RuntimeException('Cannot read from non-readable stream');
         }
@@ -225,6 +235,9 @@
 
     public function write($string)
     {
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
         if (!$this->writable) {
             throw new \RuntimeException('Cannot write to a non-writable stream');
         }