Skip to content

Commit 3347e95

Browse files
committed
Fix typing problems in OC_Image
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 1c17da1 commit 3347e95

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/private/legacy/OC_Image.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ public function mimeType() {
125125
* @return int
126126
*/
127127
public function width() {
128-
return $this->valid() ? imagesx($this->resource) : -1;
128+
if ($this->valid() && (($width = imagesx($this->resource)) !== false)) {
129+
return $width;
130+
} else {
131+
return -1;
132+
}
129133
}
130134

131135
/**
@@ -134,7 +138,11 @@ public function width() {
134138
* @return int
135139
*/
136140
public function height() {
137-
return $this->valid() ? imagesy($this->resource) : -1;
141+
if ($this->valid() && (($height = imagesy($this->resource)) !== false)) {
142+
return $height;
143+
} else {
144+
return -1;
145+
}
138146
}
139147

140148
/**

lib/public/IImage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function show($mimeType = null);
9999
public function save($filePath = null, $mimeType = null);
100100

101101
/**
102-
* @return resource|\GdImage Returns the image resource in any.
102+
* @return false|resource|\GdImage Returns the image resource if any
103103
* @since 8.1.0
104104
*/
105105
public function resource();

0 commit comments

Comments
 (0)