@@ -69,7 +69,7 @@ public static function fromContents(string $contents): self
6969 *
7070 * @return void
7171 */
72- public function close ()
72+ public function close (): void
7373 {
7474 if (!$ this ->resource ) {
7575 return ;
@@ -119,7 +119,7 @@ public function replace($stream, $mode = 'r')
119119 *
120120 * @return int|null Returns the size in bytes if known, or null if unknown.
121121 */
122- public function getSize ()
122+ public function getSize (): ? int
123123 {
124124 if (!$ this ->isValidResource ($ this ->resource )) {
125125 return null ;
@@ -136,7 +136,7 @@ public function getSize()
136136 * @return int Position of the file pointer
137137 * @throws \RuntimeException on error.
138138 */
139- public function tell ()
139+ public function tell (): int
140140 {
141141 $ this ->ensureResourceOpen ();
142142
@@ -153,7 +153,7 @@ public function tell()
153153 *
154154 * @return bool
155155 */
156- public function eof ()
156+ public function eof (): bool
157157 {
158158 if (!$ this ->isValidResource ($ this ->resource )) {
159159 return true ;
@@ -167,7 +167,7 @@ public function eof()
167167 *
168168 * @return bool
169169 */
170- public function isSeekable ()
170+ public function isSeekable (): bool
171171 {
172172 if (!$ this ->isValidResource ($ this ->resource )) {
173173 return false ;
@@ -188,10 +188,9 @@ public function isSeekable()
188188 * PHP $whence values for `fseek()`. SEEK_SET: Set position equal to
189189 * offset bytes SEEK_CUR: Set position to current location plus offset
190190 * SEEK_END: Set position to end-of-stream plus offset.
191- * @return bool
192191 * @throws \RuntimeException on failure.
193192 */
194- public function seek ($ offset , $ whence = SEEK_SET )
193+ public function seek ($ offset , $ whence = SEEK_SET ): void
195194 {
196195 $ this ->ensureResourceOpen ();
197196
@@ -205,7 +204,7 @@ public function seek($offset, $whence = SEEK_SET)
205204 throw new \RuntimeException ('Error seeking within stream ' , 1453892231 );
206205 }
207206
208- return true ;
207+ return ;
209208 }
210209
211210 /**
@@ -218,17 +217,17 @@ public function seek($offset, $whence = SEEK_SET)
218217 * @link http://www.php.net/manual/en/function.fseek.php
219218 * @throws \RuntimeException on failure.
220219 */
221- public function rewind ()
220+ public function rewind (): void
222221 {
223- return $ this ->seek (0 );
222+ $ this ->seek (0 );
224223 }
225224
226225 /**
227226 * Returns whether or not the stream is writable.
228227 *
229228 * @return bool
230229 */
231- public function isWritable ()
230+ public function isWritable (): bool
232231 {
233232 if (!$ this ->isValidResource ($ this ->resource )) {
234233 return false ;
@@ -253,7 +252,7 @@ public function isWritable()
253252 * @return int Returns the number of bytes written to the stream.
254253 * @throws \RuntimeException on failure.
255254 */
256- public function write ($ string )
255+ public function write ($ string ): int
257256 {
258257 if (!$ this ->isWritable ()) {
259258 throw new \RuntimeException ('Stream is not writable ' , 1453892241 );
@@ -273,7 +272,7 @@ public function write($string)
273272 *
274273 * @return bool
275274 */
276- public function isReadable ()
275+ public function isReadable (): bool
277276 {
278277 if (!$ this ->isValidResource ($ this ->resource )) {
279278 return false ;
@@ -295,7 +294,7 @@ public function isReadable()
295294 * if no bytes are available.
296295 * @throws \RuntimeException if an error occurs.
297296 */
298- public function read ($ length )
297+ public function read ($ length ): string
299298 {
300299 $ this ->ensureResourceReadable ();
301300
@@ -315,7 +314,7 @@ public function read($length)
315314 * @throws \RuntimeException if unable to read or an error occurs while
316315 * reading.
317316 */
318- public function getContents ()
317+ public function getContents (): string
319318 {
320319 $ this ->ensureResourceReadable ();
321320
@@ -334,12 +333,12 @@ public function getContents()
334333 * stream_get_meta_data() function.
335334 *
336335 * @link http://php.net/manual/en/function.stream-get-meta-data.php
337- * @param string $key Specific metadata to retrieve.
336+ * @param string|null $key Specific metadata to retrieve.
338337 * @return array|mixed|null Returns an associative array if no key is
339338 * provided. Returns a specific key value if a key is provided and the
340339 * value is found, or null if the key is not found.
341340 */
342- public function getMetadata ($ key = null )
341+ public function getMetadata (? string $ key = null )
343342 {
344343 if ($ key === null ) {
345344 return stream_get_meta_data ($ this ->resource );
@@ -395,7 +394,7 @@ protected function isValidResource($resource)
395394 * @see http://php.net/manual/en/language.oop5.magic.php#object.tostring
396395 * @return string
397396 */
398- public function __toString ()
397+ public function __toString (): string
399398 {
400399 if (!$ this ->isReadable ()) {
401400 return '' ;
0 commit comments