@@ -65,21 +65,21 @@ class Stream implements StreamInterface
6565 *
6666 * @var bool
6767 */
68- protected bool $ readable ;
68+ protected ? bool $ readable ;
6969
7070 /**
7171 * Is this stream writable?
7272 *
7373 * @var bool
7474 */
75- protected bool $ writable ;
75+ protected ? bool $ writable ;
7676
7777 /**
7878 * Is this stream seekable?
7979 *
8080 * @var bool
8181 */
82- protected bool $ seekable ;
82+ protected ? bool $ seekable ;
8383
8484 /**
8585 * The size of the stream if known
@@ -93,7 +93,7 @@ class Stream implements StreamInterface
9393 *
9494 * @var bool
9595 */
96- protected bool $ isPipe ;
96+ protected ? bool $ isPipe ;
9797
9898 /**
9999 * Create a new Stream.
@@ -115,13 +115,13 @@ public function __construct($stream)
115115 *
116116 * @link http://php.net/manual/en/function.stream-get-meta-data.php
117117 *
118- * @param string $key Specific metadata to retrieve.
118+ * @param string|null $key Specific metadata to retrieve.
119119 *
120120 * @return array|mixed|null Returns an associative array if no key is
121121 * provided. Returns a specific key value if a key is provided and the
122122 * value is found, or null if the key is not found.
123123 */
124- public function getMetadata ($ key = null ): mixed
124+ public function getMetadata (? string $ key = null ): mixed
125125 {
126126 $ this ->meta = \stream_get_meta_data ($ this ->stream );
127127 if (null === $ key ) {
@@ -176,7 +176,7 @@ public function detach()
176176 {
177177 $ oldResource = $ this ->stream ;
178178 $ this ->stream = null ;
179- $ this ->meta = null ;
179+ $ this ->meta = [] ;
180180 $ this ->readable = null ;
181181 $ this ->writable = null ;
182182 $ this ->seekable = null ;
@@ -356,7 +356,7 @@ public function isSeekable(): bool
356356 *
357357 * @throws RuntimeException on failure.
358358 */
359- public function seek ($ offset , $ whence = \SEEK_SET )
359+ public function seek (int $ offset , $ whence = \SEEK_SET )
360360 {
361361 // Note that fseek returns 0 on success!
362362 if (!$ this ->isSeekable () || fseek ($ this ->stream , $ offset , $ whence ) === -1 ) {
@@ -395,7 +395,7 @@ public function rewind()
395395 *
396396 * @throws RuntimeException if an error occurs.
397397 */
398- public function read ($ length ): string
398+ public function read (int $ length ): string
399399 {
400400 if (!$ this ->isReadable () || ($ data = fread ($ this ->stream , $ length )) === false ) {
401401 throw new RuntimeException ('Could not read from stream ' );
@@ -407,15 +407,15 @@ public function read($length): string
407407 /**
408408 * Write data to the stream.
409409 *
410- * @param string $string The string that is to be written.
410+ * @param string $str The string that is to be written.
411411 *
412412 * @return int Returns the number of bytes written to the stream.
413413 *
414414 * @throws RuntimeException on failure.
415415 */
416- public function write ($ string ): int
416+ public function write (string $ str ): int
417417 {
418- if (!$ this ->isWritable () || ($ written = fwrite ($ this ->stream , $ string )) === false ) {
418+ if (!$ this ->isWritable () || ($ written = fwrite ($ this ->stream , $ str )) === false ) {
419419 throw new RuntimeException ('Could not write to stream ' );
420420 }
421421
0 commit comments