Skip to content

Commit 6bbca56

Browse files
committed
(mb_)?str_split() always returns non-empty-array
1 parent 119facc commit 6bbca56

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

resources/functionMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11696,7 +11696,7 @@
1169611696
'str_replace' => ['string|array', 'search'=>'string|array', 'replace'=>'string|array', 'subject'=>'string|array', '&w_replace_count='=>'int'],
1169711697
'str_rot13' => ['string', 'str'=>'string'],
1169811698
'str_shuffle' => ['string', 'str'=>'string'],
11699-
'str_split' => ['array<int,string>|false', 'str'=>'string', 'split_length='=>'int'],
11699+
'str_split' => ['non-empty-array<int,string>|false', 'str'=>'string', 'split_length='=>'int'],
1170011700
'str_word_count' => ['array<int,string>|int|false', 'string'=>'string', 'format='=>'int', 'charlist='=>'string'],
1170111701
'strcasecmp' => ['int', 'str1'=>'string', 'str2'=>'string'],
1170211702
'strchr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool'],

resources/functionMap_php74delta.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
'FFI::typeof' => ['FFI\CType', '&ptr'=>'FFI\CData'],
4040
'FFI::type' => ['FFI\CType', 'type'=>'string'],
4141
'get_mangled_object_vars' => ['array', 'obj'=>'object'],
42-
'mb_str_split' => ['array<int,string>|false', 'str'=>'string', 'split_length='=>'int', 'encoding='=>'string'],
42+
'mb_str_split' => ['non-empty-array<int,string>|false', 'str'=>'string', 'split_length='=>'int', 'encoding='=>'string'],
4343
'password_algos' => ['array<int, string>'],
4444
'password_hash' => ['string|false', 'password'=>'string', 'algo'=>'string|null', 'options='=>'array'],
4545
'password_needs_rehash' => ['bool', 'hash'=>'string', 'algo'=>'string|null', 'options='=>'array'],

resources/functionMap_php80delta.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
'imagerotate' => ['false|object', 'src_im'=>'resource', 'angle'=>'float', 'bgdcolor'=>'int', 'ignoretransparent='=>'int'],
7171
'imagescale' => ['false|object', 'im'=>'resource', 'new_width'=>'int', 'new_height='=>'int', 'method='=>'int'],
7272
'mb_decode_numericentity' => ['string|false', 'string'=>'string', 'convmap'=>'array', 'encoding='=>'string'],
73-
'mb_str_split' => ['array<int,string>', 'str'=>'string', 'split_length='=>'positive-int', 'encoding='=>'string'],
73+
'mb_str_split' => ['non-empty-array<int,string>', 'str'=>'string', 'split_length='=>'positive-int', 'encoding='=>'string'],
7474
'mktime' => ['int|false', 'hour'=>'int', 'minute='=>'int', 'second='=>'int', 'month='=>'int', 'day='=>'int', 'year='=>'int'],
7575
'odbc_exec' => ['resource|false', 'connection_id'=>'resource', 'query'=>'string'],
7676
'parse_str' => ['void', 'encoded_string'=>'string', '&w_result'=>'array'],
@@ -84,7 +84,7 @@
8484
'socket_select' => ['int|false', '&rw_read'=>'Socket[]|null', '&rw_write'=>'Socket[]|null', '&rw_except'=>'Socket[]|null', 'seconds'=>'int|null', 'microseconds='=>'int'],
8585
'sodium_crypto_aead_chacha20poly1305_ietf_decrypt' => ['string|false', 'confidential_message'=>'string', 'public_message'=>'string', 'nonce'=>'string', 'key'=>'string'],
8686
'str_contains' => ['bool', 'haystack'=>'string', 'needle'=>'string'],
87-
'str_split' => ['array<int,string>', 'str'=>'string', 'split_length='=>'positive-int'],
87+
'str_split' => ['non-empty-array<int,string>', 'str'=>'string', 'split_length='=>'positive-int'],
8888
'str_ends_with' => ['bool', 'haystack'=>'string', 'needle'=>'string'],
8989
'str_starts_with' => ['bool', 'haystack'=>'string', 'needle'=>'string'],
9090
'strchr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool'],

tests/PHPStan/Analyser/LegacyNodeScopeResolverTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5880,7 +5880,7 @@ public function dataFunctions(): array
58805880
'$gettimeofdayBenevolent',
58815881
],
58825882
[
5883-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
5883+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
58845884
'$strSplitConstantStringWithoutDefinedParameters',
58855885
],
58865886
[
@@ -5904,15 +5904,15 @@ public function dataFunctions(): array
59045904
'$strSplitConstantStringWithFailureSplitLength',
59055905
],
59065906
[
5907-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
5907+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
59085908
'$strSplitConstantStringWithInvalidSplitLengthType',
59095909
],
59105910
[
59115911
'array<int, string>&nonEmpty',
59125912
'$strSplitConstantStringWithVariableStringAndConstantSplitLength',
59135913
],
59145914
[
5915-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
5915+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
59165916
'$strSplitConstantStringWithVariableStringAndVariableSplitLength',
59175917
],
59185918
// parse_url
@@ -9674,7 +9674,7 @@ public function dataPhp74Functions(): array
96749674
{
96759675
return [
96769676
[
9677-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
9677+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
96789678
'$mbStrSplitConstantStringWithoutDefinedParameters',
96799679
],
96809680
[
@@ -9698,15 +9698,15 @@ public function dataPhp74Functions(): array
96989698
'$mbStrSplitConstantStringWithFailureSplitLength',
96999699
],
97009700
[
9701-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
9701+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
97029702
'$mbStrSplitConstantStringWithInvalidSplitLengthType',
97039703
],
97049704
[
97059705
'array<int, string>&nonEmpty',
97069706
'$mbStrSplitConstantStringWithVariableStringAndConstantSplitLength',
97079707
],
97089708
[
9709-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
9709+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
97109710
'$mbStrSplitConstantStringWithVariableStringAndVariableSplitLength',
97119711
],
97129712
[
@@ -9718,7 +9718,7 @@ public function dataPhp74Functions(): array
97189718
'$mbStrSplitConstantStringWithOneSplitLengthAndInvalidEncoding',
97199719
],
97209720
[
9721-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
9721+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
97229722
'$mbStrSplitConstantStringWithOneSplitLengthAndVariableEncoding',
97239723
],
97249724
[
@@ -9730,7 +9730,7 @@ public function dataPhp74Functions(): array
97309730
'$mbStrSplitConstantStringWithGreaterSplitLengthThanStringLengthAndInvalidEncoding',
97319731
],
97329732
[
9733-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
9733+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
97349734
'$mbStrSplitConstantStringWithGreaterSplitLengthThanStringLengthAndVariableEncoding',
97359735
],
97369736
[
@@ -9746,15 +9746,15 @@ public function dataPhp74Functions(): array
97469746
'$mbStrSplitConstantStringWithFailureSplitLengthAndVariableEncoding',
97479747
],
97489748
[
9749-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
9749+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
97509750
'$mbStrSplitConstantStringWithInvalidSplitLengthTypeAndValidEncoding',
97519751
],
97529752
[
97539753
'false',
97549754
'$mbStrSplitConstantStringWithInvalidSplitLengthTypeAndInvalidEncoding',
97559755
],
97569756
[
9757-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
9757+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
97589758
'$mbStrSplitConstantStringWithInvalidSplitLengthTypeAndVariableEncoding',
97599759
],
97609760
[
@@ -9766,19 +9766,19 @@ public function dataPhp74Functions(): array
97669766
'$mbStrSplitConstantStringWithVariableStringAndConstantSplitLengthAndInvalidEncoding',
97679767
],
97689768
[
9769-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
9769+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
97709770
'$mbStrSplitConstantStringWithVariableStringAndConstantSplitLengthAndVariableEncoding',
97719771
],
97729772
[
9773-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
9773+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
97749774
'$mbStrSplitConstantStringWithVariableStringAndVariableSplitLengthAndValidEncoding',
97759775
],
97769776
[
97779777
'false',
97789778
'$mbStrSplitConstantStringWithVariableStringAndVariableSplitLengthAndInvalidEncoding',
97799779
],
97809780
[
9781-
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
9781+
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
97829782
'$mbStrSplitConstantStringWithVariableStringAndVariableSplitLengthAndVariableEncoding',
97839783
],
97849784
];

0 commit comments

Comments
 (0)