@@ -67,7 +67,7 @@ public function __toString(): string
6767 {
6868 try {
6969 $ this ->seek (0 );
70- } catch (\ RuntimeException $ e ) {}
70+ } catch (RuntimeException $ e ) {}
7171 return (string ) stream_get_contents ($ this ->stream );
7272 }
7373
@@ -81,7 +81,7 @@ public function __toString(): string
8181 * PHP $whence values for `fseek()`. SEEK_SET: Set position equal to
8282 * offset bytes SEEK_CUR: Set position to current location plus offset
8383 * SEEK_END: Set position to end-of-stream plus offset.
84- * @throws \ RuntimeException on failure.
84+ * @throws RuntimeException on failure.
8585 */
8686 public function seek ($ offset , $ whence = SEEK_SET ): void
8787 {
@@ -136,7 +136,7 @@ public function getSize(): ?int
136136 * Returns the current position of the file read/write pointer
137137 *
138138 * @return int Position of the file pointer
139- * @throws \ RuntimeException on error.
139+ * @throws RuntimeException on error.
140140 */
141141 public function tell (): int
142142 {
@@ -165,7 +165,7 @@ public function eof(): bool
165165 *
166166 * @see seek()
167167 * @link http://www.php.net/manual/en/function.fseek.php
168- * @throws \ RuntimeException on failure.
168+ * @throws RuntimeException on failure.
169169 */
170170 public function rewind (): void
171171 {
@@ -177,7 +177,7 @@ public function rewind(): void
177177 *
178178 * @param string $string The string that is to be written.
179179 * @return int Returns the number of bytes written to the stream.
180- * @throws \ RuntimeException on failure.
180+ * @throws RuntimeException on failure.
181181 */
182182 public function write ($ string ): int
183183 {
@@ -197,7 +197,11 @@ public function write($string): int
197197 */
198198 public function isWritable (): bool
199199 {
200- return preg_match ('/[waxc+]/ ' , $ this ->getMetadata ('mode ' )) === 1 ;
200+ $ mode = $ this ->getMetadata ('mode ' );
201+ if (!is_string ($ mode )) {
202+ throw new RuntimeException ('Could not get stream mode from metadata! ' );
203+ }
204+ return preg_match ('/[waxc+]/ ' , $ mode ) === 1 ;
201205 }
202206
203207 /**
@@ -229,7 +233,11 @@ public function read($length): string
229233 */
230234 public function isReadable (): bool
231235 {
232- return preg_match ('/[r+]/ ' , $ this ->getMetadata ('mode ' )) === 1 ;
236+ $ mode = $ this ->getMetadata ('mode ' );
237+ if (!is_string ($ mode )) {
238+ throw new RuntimeException ('Could not get stream mode from metadata! ' );
239+ }
240+ return preg_match ('/[r+]/ ' , $ mode ) === 1 ;
233241 }
234242
235243 /**
0 commit comments