From ab3a1d5706a5cc0c7f00b5d5ab47d493ffe68790 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 2 Dec 2021 11:30:10 +0100 Subject: Fix typing problems in OC_Image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/legacy/OC_Image.php | 12 ++++++++++-- lib/public/IImage.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php index e6a815a3cf7..1b1d98325ba 100644 --- a/lib/private/legacy/OC_Image.php +++ b/lib/private/legacy/OC_Image.php @@ -124,7 +124,11 @@ class OC_Image implements \OCP\IImage { * @return int */ public function width() { - return $this->valid() ? imagesx($this->resource) : -1; + if ($this->valid() && (($width = imagesx($this->resource)) !== false)) { + return $width; + } else { + return -1; + } } /** @@ -133,7 +137,11 @@ class OC_Image implements \OCP\IImage { * @return int */ public function height() { - return $this->valid() ? imagesy($this->resource) : -1; + if ($this->valid() && (($height = imagesy($this->resource)) !== false)) { + return $height; + } else { + return -1; + } } /** diff --git a/lib/public/IImage.php b/lib/public/IImage.php index 9d2b31e0e28..659cd24720d 100644 --- a/lib/public/IImage.php +++ b/lib/public/IImage.php @@ -98,7 +98,7 @@ interface IImage { public function save($filePath = null, $mimeType = null); /** - * @return resource|\GdImage Returns the image resource in any. + * @return false|resource|\GdImage Returns the image resource if any * @since 8.1.0 */ public function resource(); -- cgit v1.2.3