From 0e564798d4c8291f9a5e2b1c01c1a0177a8c5fb0 Mon Sep 17 00:00:00 2001 From: Rudolph Gottesheim Date: Thu, 11 Jul 2024 13:22:28 +0200 Subject: [PATCH 1/3] Use more precise return types for getimagesize and getimagesizefromstring - Key 0 (the image width) is always positive - Key 1 (the image height) is always positive - Key 2 is always one of the `IMAGETYPE_*` constants --- dictionaries/CallMap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dictionaries/CallMap.php b/dictionaries/CallMap.php index 03564be9a30..903a3698d2a 100644 --- a/dictionaries/CallMap.php +++ b/dictionaries/CallMap.php @@ -3304,8 +3304,8 @@ 'gethostbyname' => ['string', 'hostname'=>'string'], 'gethostbynamel' => ['list|false', 'hostname'=>'string'], 'gethostname' => ['string|false'], -'getimagesize' => ['array{0:int, 1: int, 2: int, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'filename'=>'string', '&w_image_info='=>'array'], -'getimagesizefromstring' => ['array{0:int, 1: int, 2: int, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'string'=>'string', '&w_image_info='=>'array'], +'getimagesize' => ['array{0: positive-int, 1: positive-int, 2: IMAGETYPE_*, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'filename'=>'string', '&w_image_info='=>'array'], +'getimagesizefromstring' => ['array{0: positive-int, 1: positive-int, 2: IMAGETYPE_*, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'string'=>'string', '&w_image_info='=>'array'], 'getlastmod' => ['int|false'], 'getmxrr' => ['bool', 'hostname'=>'string', '&w_hosts'=>'array', '&w_weights='=>'array'], 'getmygid' => ['int|false'], From 513f3e8a7e54bb5439df39414cd08db5c493d043 Mon Sep 17 00:00:00 2001 From: Rudolph Gottesheim Date: Thu, 11 Jul 2024 13:31:29 +0200 Subject: [PATCH 2/3] Fully qualify a constant type --- dictionaries/CallMap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dictionaries/CallMap.php b/dictionaries/CallMap.php index 903a3698d2a..6b8580b76d0 100644 --- a/dictionaries/CallMap.php +++ b/dictionaries/CallMap.php @@ -3304,8 +3304,8 @@ 'gethostbyname' => ['string', 'hostname'=>'string'], 'gethostbynamel' => ['list|false', 'hostname'=>'string'], 'gethostname' => ['string|false'], -'getimagesize' => ['array{0: positive-int, 1: positive-int, 2: IMAGETYPE_*, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'filename'=>'string', '&w_image_info='=>'array'], -'getimagesizefromstring' => ['array{0: positive-int, 1: positive-int, 2: IMAGETYPE_*, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'string'=>'string', '&w_image_info='=>'array'], +'getimagesize' => ['array{0: positive-int, 1: positive-int, 2: \IMAGETYPE_*, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'filename'=>'string', '&w_image_info='=>'array'], +'getimagesizefromstring' => ['array{0: positive-int, 1: positive-int, 2: \IMAGETYPE_*, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'string'=>'string', '&w_image_info='=>'array'], 'getlastmod' => ['int|false'], 'getmxrr' => ['bool', 'hostname'=>'string', '&w_hosts'=>'array', '&w_weights='=>'array'], 'getmygid' => ['int|false'], From f3c640af96802f4cd7a95a2a477fad087e25bed8 Mon Sep 17 00:00:00 2001 From: Rudolph Gottesheim Date: Thu, 11 Jul 2024 13:42:06 +0200 Subject: [PATCH 3/3] Width and height might be 0 See https://github.com/phpstan/phpstan-src/pull/3207 --- dictionaries/CallMap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dictionaries/CallMap.php b/dictionaries/CallMap.php index 6b8580b76d0..c1151fe6fdf 100644 --- a/dictionaries/CallMap.php +++ b/dictionaries/CallMap.php @@ -3304,8 +3304,8 @@ 'gethostbyname' => ['string', 'hostname'=>'string'], 'gethostbynamel' => ['list|false', 'hostname'=>'string'], 'gethostname' => ['string|false'], -'getimagesize' => ['array{0: positive-int, 1: positive-int, 2: \IMAGETYPE_*, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'filename'=>'string', '&w_image_info='=>'array'], -'getimagesizefromstring' => ['array{0: positive-int, 1: positive-int, 2: \IMAGETYPE_*, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'string'=>'string', '&w_image_info='=>'array'], +'getimagesize' => ['array{0: int<0, max>, 1: int<0, max>, 2: \IMAGETYPE_*, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'filename'=>'string', '&w_image_info='=>'array'], +'getimagesizefromstring' => ['array{0: int<0, max>, 1: int<0, max>, 2: \IMAGETYPE_*, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'string'=>'string', '&w_image_info='=>'array'], 'getlastmod' => ['int|false'], 'getmxrr' => ['bool', 'hostname'=>'string', '&w_hosts'=>'array', '&w_weights='=>'array'], 'getmygid' => ['int|false'],