From 142ee57836c9b69299f3b2b701db56a4a7673eee Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Sun, 5 Dec 2021 03:57:36 +0200 Subject: [PATCH] Refine `*strlen()` return type to exclude negative integers Fixes vimeo/psalm#7062 --- dictionaries/CallMap.php | 8 ++++---- dictionaries/CallMap_80_delta.php | 4 ++-- dictionaries/CallMap_historical.php | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dictionaries/CallMap.php b/dictionaries/CallMap.php index cc318ae4be7..25f970de56f 100644 --- a/dictionaries/CallMap.php +++ b/dictionaries/CallMap.php @@ -4102,7 +4102,7 @@ 'grapheme_extract' => ['string|false', 'haystack'=>'string', 'size'=>'int', 'type='=>'int', 'offset='=>'int', '&w_next='=>'int'], 'grapheme_stripos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int'], 'grapheme_stristr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'beforeNeedle='=>'bool'], -'grapheme_strlen' => ['int|false|null', 'string'=>'string'], +'grapheme_strlen' => ['0|positive-int|false|null', 'string'=>'string'], 'grapheme_strpos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int'], 'grapheme_strripos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int'], 'grapheme_strrpos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int'], @@ -5281,7 +5281,7 @@ 'iconv_mime_decode_headers' => ['array|false', 'headers'=>'string', 'mode='=>'int', 'encoding='=>'string'], 'iconv_mime_encode' => ['string|false', 'field_name'=>'string', 'field_value'=>'string', 'options='=>'array'], 'iconv_set_encoding' => ['bool', 'type'=>'string', 'encoding'=>'string'], -'iconv_strlen' => ['int|false', 'string'=>'string', 'encoding='=>'string'], +'iconv_strlen' => ['0|positive-int|false', 'string'=>'string', 'encoding='=>'string'], 'iconv_strpos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int', 'encoding='=>'string'], 'iconv_strrpos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'encoding='=>'string'], 'iconv_substr' => ['string|false', 'string'=>'string', 'offset'=>'int', 'length='=>'int', 'encoding='=>'string'], @@ -7313,7 +7313,7 @@ 'mb_strimwidth' => ['string', 'string'=>'string', 'start'=>'int', 'width'=>'int', 'trim_marker='=>'string', 'encoding='=>'string|null'], 'mb_stripos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int', 'encoding='=>'string|null'], 'mb_stristr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool', 'encoding='=>'string|null'], -'mb_strlen' => ['int', 'string'=>'string', 'encoding='=>'string|null'], +'mb_strlen' => ['0|positive-int', 'string'=>'string', 'encoding='=>'string|null'], 'mb_strpos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int', 'encoding='=>'string|null'], 'mb_strrchr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool', 'encoding='=>'string|null'], 'mb_strrichr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool', 'encoding='=>'string|null'], @@ -13865,7 +13865,7 @@ 'stripos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int'], 'stripslashes' => ['string', 'string'=>'string'], 'stristr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool'], -'strlen' => ['int', 'string'=>'string'], +'strlen' => ['0|positive-int', 'string'=>'string'], 'strnatcasecmp' => ['int', 'string1'=>'string', 'string2'=>'string'], 'strnatcmp' => ['int', 'string1'=>'string', 'string2'=>'string'], 'strncasecmp' => ['int', 'string1'=>'string', 'string2'=>'string', 'length'=>'int'], diff --git a/dictionaries/CallMap_80_delta.php b/dictionaries/CallMap_80_delta.php index 2420127df69..583bff4a0d2 100644 --- a/dictionaries/CallMap_80_delta.php +++ b/dictionaries/CallMap_80_delta.php @@ -870,8 +870,8 @@ 'new' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool', 'encoding='=>'string|null'], ], 'mb_strlen' => [ - 'old' => ['int', 'string'=>'string', 'encoding='=>'string'], - 'new' => ['int', 'string'=>'string', 'encoding='=>'string|null'], + 'old' => ['0|positive-int', 'string'=>'string', 'encoding='=>'string'], + 'new' => ['0|positive-int', 'string'=>'string', 'encoding='=>'string|null'], ], 'mb_strpos' => [ 'old' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int', 'encoding='=>'string'], diff --git a/dictionaries/CallMap_historical.php b/dictionaries/CallMap_historical.php index daf37fd2aff..5e2786084f8 100644 --- a/dictionaries/CallMap_historical.php +++ b/dictionaries/CallMap_historical.php @@ -11211,7 +11211,7 @@ 'grapheme_extract' => ['string|false', 'haystack'=>'string', 'size'=>'int', 'type='=>'int', 'offset='=>'int', '&w_next='=>'int'], 'grapheme_stripos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int'], 'grapheme_stristr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'beforeNeedle='=>'bool'], - 'grapheme_strlen' => ['int|false|null', 'string'=>'string'], + 'grapheme_strlen' => ['0|positive-int|false|null', 'string'=>'string'], 'grapheme_strpos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int'], 'grapheme_strripos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int'], 'grapheme_strrpos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int'], @@ -11956,7 +11956,7 @@ 'iconv_mime_decode_headers' => ['array|false', 'headers'=>'string', 'mode='=>'int', 'encoding='=>'string'], 'iconv_mime_encode' => ['string|false', 'field_name'=>'string', 'field_value'=>'string', 'options='=>'array'], 'iconv_set_encoding' => ['bool', 'type'=>'string', 'encoding'=>'string'], - 'iconv_strlen' => ['int|false', 'string'=>'string', 'encoding='=>'string'], + 'iconv_strlen' => ['0|positive-int|false', 'string'=>'string', 'encoding='=>'string'], 'iconv_strpos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int', 'encoding='=>'string'], 'iconv_strrpos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'encoding='=>'string'], 'iconv_substr' => ['string|false', 'string'=>'string', 'offset'=>'int', 'length='=>'int', 'encoding='=>'string'], @@ -12922,7 +12922,7 @@ 'mb_strimwidth' => ['string', 'string'=>'string', 'start'=>'int', 'width'=>'int', 'trim_marker='=>'string', 'encoding='=>'string'], 'mb_stripos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int', 'encoding='=>'string'], 'mb_stristr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool', 'encoding='=>'string'], - 'mb_strlen' => ['int', 'string'=>'string', 'encoding='=>'string'], + 'mb_strlen' => ['0|positive-int', 'string'=>'string', 'encoding='=>'string'], 'mb_strpos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int', 'encoding='=>'string'], 'mb_strrchr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool', 'encoding='=>'string'], 'mb_strrichr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool', 'encoding='=>'string'], @@ -15275,7 +15275,7 @@ 'stripos' => ['int|false', 'haystack'=>'string', 'needle'=>'string|int', 'offset='=>'int'], 'stripslashes' => ['string', 'string'=>'string'], 'stristr' => ['string|false', 'haystack'=>'string', 'needle'=>'string|int', 'before_needle='=>'bool'], - 'strlen' => ['int', 'string'=>'string'], + 'strlen' => ['0|positive-int', 'string'=>'string'], 'strnatcasecmp' => ['int', 'string1'=>'string', 'string2'=>'string'], 'strnatcmp' => ['int', 'string1'=>'string', 'string2'=>'string'], 'strncasecmp' => ['int', 'string1'=>'string', 'string2'=>'string', 'length'=>'int'],