Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return type of str_split() #9504

Merged
merged 1 commit into from Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dictionaries/CallMap.php
Expand Up @@ -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'=>'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'],
Expand Down
2 changes: 1 addition & 1 deletion dictionaries/CallMap_82_delta.php
Expand Up @@ -51,7 +51,7 @@
],
'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'],
],
],

Expand Down
1 change: 0 additions & 1 deletion src/Psalm/Internal/Type/TypeTokenizer.php
Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion stubs/CoreGenericFunctions.phpstub
Expand Up @@ -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
*/
Expand Down
9 changes: 9 additions & 0 deletions stubs/Php82.phpstub
Expand Up @@ -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) {}
}