Skip to content

Commit

Permalink
Merge pull request #9504 from othercorey/fix-strsplit
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Mar 15, 2023
2 parents 293b728 + 39bb7b4 commit 8d71479
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
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) {}
}

0 comments on commit 8d71479

Please sign in to comment.