1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix return type of str_split()

This commit is contained in:
Corey Taylor 2023-03-12 19:02:34 -05:00
parent 902a019f0a
commit 39bb7b45a7
5 changed files with 13 additions and 4 deletions

View File

@ -12898,7 +12898,7 @@ return [
'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'=>'string', 'length='=>'positive-int'],
'str_split' => ['list<non-empty-string>', 'string'=>'string', 'length='=>'positive-int'],
'str_starts_with' => ['bool', 'haystack'=>'string', 'needle'=>'string'],
'str_word_count' => ['array<int, string>|int', 'string'=>'string', 'format='=>'int', 'characters='=>'?string'],
'strcasecmp' => ['int', 'string1'=>'string', 'string2'=>'string'],

View File

@ -51,7 +51,7 @@ return [
],
'str_split' => [
'old' => ['non-empty-list<string>', 'string'=>'string', 'length='=>'positive-int'],
'new' => ['list<string>', 'string'=>'string', 'length='=>'positive-int'],
'new' => ['list<non-empty-string>', 'string'=>'string', 'length='=>'positive-int'],
],
],

View File

@ -108,7 +108,6 @@ class TypeTokenizer
* contains the string token and the second element contains its offset,
*
* @return list<array{0: string, 1: int}>
* @psalm-suppress PossiblyUndefinedIntArrayOffset
*/
public static function tokenize(string $string_type, bool $ignore_space = true): array
{

View File

@ -1050,7 +1050,8 @@ function str_shuffle(string $string): string {}
/**
* @psalm-pure
* @return ($length is positive-int ? list<string> : false)
* @param positive-int $length
* @return non-empty-list<string>
*
* @psalm-flow ($string) -> return
*/

View File

@ -45,4 +45,13 @@ namespace {
{
public function __construct() {}
}
/**
* @psalm-pure
* @param positive-int $length
* @return list<non-empty-string>
*
* @psalm-flow ($string) -> return
*/
function str_split(string $string, int $length = 1) {}
}