From c23743e5d29213c648cb7f2bb9537031b48f3e2d Mon Sep 17 00:00:00 2001 From: Corey Taylor Date: Sun, 12 Mar 2023 19:02:34 -0500 Subject: [PATCH] Fix return type of str_split() --- dictionaries/CallMap.php | 2 +- dictionaries/CallMap_82_delta.php | 2 +- stubs/CoreGenericFunctions.phpstub | 3 ++- stubs/Php82.phpstub | 9 +++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dictionaries/CallMap.php b/dictionaries/CallMap.php index 622ff2582b4..0ea801dc795 100644 --- a/dictionaries/CallMap.php +++ b/dictionaries/CallMap.php @@ -12898,7 +12898,7 @@ 'str_replace' => ['string|string[]', 'search'=>'string|array', 'replace'=>'string|array', 'subject'=>'string|array', '&w_count='=>'int'], 'str_rot13' => ['string', 'string'=>'string'], 'str_shuffle' => ['string', 'string'=>'string'], -'str_split' => ['list', 'string'=>'string', 'length='=>'positive-int'], +'str_split' => ['list', 'string'=>'string', 'length='=>'positive-int'], 'str_starts_with' => ['bool', 'haystack'=>'string', 'needle'=>'string'], 'str_word_count' => ['array|int', 'string'=>'string', 'format='=>'int', 'characters='=>'?string'], 'strcasecmp' => ['int', 'string1'=>'string', 'string2'=>'string'], diff --git a/dictionaries/CallMap_82_delta.php b/dictionaries/CallMap_82_delta.php index 3e88fad54f6..47ded4fbb19 100644 --- a/dictionaries/CallMap_82_delta.php +++ b/dictionaries/CallMap_82_delta.php @@ -51,7 +51,7 @@ ], 'str_split' => [ 'old' => ['non-empty-list', 'string'=>'string', 'length='=>'positive-int'], - 'new' => ['list', 'string'=>'string', 'length='=>'positive-int'], + 'new' => ['list', 'string'=>'string', 'length='=>'positive-int'], ], ], diff --git a/stubs/CoreGenericFunctions.phpstub b/stubs/CoreGenericFunctions.phpstub index 4ad32c517e8..11765e5bea2 100644 --- a/stubs/CoreGenericFunctions.phpstub +++ b/stubs/CoreGenericFunctions.phpstub @@ -1050,7 +1050,8 @@ function str_shuffle(string $string): string {} /** * @psalm-pure - * @return ($length is positive-int ? list : false) + * @param positive-int $length + * @return non-empty-list * * @psalm-flow ($string) -> return */ diff --git a/stubs/Php82.phpstub b/stubs/Php82.phpstub index 40d60e3e55e..8696bd089b7 100644 --- a/stubs/Php82.phpstub +++ b/stubs/Php82.phpstub @@ -45,4 +45,13 @@ namespace { { public function __construct() {} } + + /** + * @psalm-pure + * @param positive-int $length + * @return list + * + * @psalm-flow ($string) -> return + */ + function str_split(string $string, int $length = 1) {} }