From 123e2ac063c249f82830bb5a0e8dd28f7bfceacb Mon Sep 17 00:00:00 2001 From: Markus Fruehauf Date: Tue, 2 Jul 2024 13:08:07 +0000 Subject: [PATCH] getimagesize, getimagesizefromstring zero is a possible value for height and width --- resources/functionMap.php | 4 ++-- tests/PHPStan/Analyser/nsrt/image-size.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/functionMap.php b/resources/functionMap.php index eae5a837bf..4ef3f0d6ac 100644 --- a/resources/functionMap.php +++ b/resources/functionMap.php @@ -3331,8 +3331,8 @@ 'gethostbyname' => ['string', 'hostname'=>'string'], 'gethostbynamel' => ['list|false', 'hostname'=>'string'], 'gethostname' => ['string|false'], -'getimagesize' => ['array{0: positive-int, 1: positive-int, 2: int, 3: string, mime: string, channels?: int, bits?: int}|false', 'imagefile'=>'string', '&w_info='=>'array'], -'getimagesizefromstring' => ['array{0: positive-int, 1: positive-int, 2: int, 3: string, mime: string, channels?: int, bits?: int}|false', 'data'=>'string', '&w_info='=>'array'], +'getimagesize' => ['array{0: 0|positive-int, 1: 0|positive-int, 2: int, 3: string, mime: string, channels?: int, bits?: int}|false', 'imagefile'=>'string', '&w_info='=>'array'], +'getimagesizefromstring' => ['array{0: 0|positive-int, 1: 0|positive-int, 2: int, 3: string, mime: string, channels?: int, bits?: int}|false', 'data'=>'string', '&w_info='=>'array'], 'getlastmod' => ['int|false'], 'getmxrr' => ['bool', 'hostname'=>'string', '&w_mxhosts'=>'array', '&w_weight='=>'array'], 'getmygid' => ['int|false'], diff --git a/tests/PHPStan/Analyser/nsrt/image-size.php b/tests/PHPStan/Analyser/nsrt/image-size.php index 882f82e629..a68a0706b3 100644 --- a/tests/PHPStan/Analyser/nsrt/image-size.php +++ b/tests/PHPStan/Analyser/nsrt/image-size.php @@ -14,8 +14,8 @@ function imageFoo(): void list($width, $height, $type, $attr) = $imagesize; - assertType('int<1, max>', $width); - assertType('int<1, max>', $height); + assertType('int<0, max>', $width); + assertType('int<0, max>', $height); assertType('int', $type); assertType('string', $attr); assertType('string', $imagesize['mime']); @@ -31,8 +31,8 @@ function imagesizeFoo(string $s): void } list($width, $height, $type, $attr) = $imagesize; - assertType('int<1, max>', $width); - assertType('int<1, max>', $height); + assertType('int<0, max>', $width); + assertType('int<0, max>', $height); assertType('int', $type); assertType('string', $attr); assertType('string', $imagesize['mime']);