From 0c31a1a0db81816f3f1b565623f654d33f13f9fc Mon Sep 17 00:00:00 2001 From: Dmitriy Trt Date: Thu, 23 Sep 2021 14:26:06 +0300 Subject: [PATCH] Fix warnings in getSize() without changing the actual API. --- src/StreamUtil.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/StreamUtil.php b/src/StreamUtil.php index 09907ef..91e0650 100644 --- a/src/StreamUtil.php +++ b/src/StreamUtil.php @@ -84,13 +84,16 @@ public static function getUsableUri($stream) * * @param resource $stream The stream. * - * @return int The size of the stream. + * @return int|null The size of the stream or NULL if it can't be retrieved. */ public static function getSize($stream) { $stat = fstat($stream); + if ($stat === FALSE) { + return NULL; + } - return $stat['size']; + return isset($stat['size']) ? $stat['size'] : NULL; } /**