Skip to content

Commit

Permalink
explode() always returns non-empty-array
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 7, 2021
1 parent 6ef5e91 commit 25260db
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion resources/functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2639,7 +2639,7 @@
'exp' => ['float', 'number'=>'float'],
'expect_expectl' => ['int', 'expect'=>'resource', 'cases'=>'array', 'match='=>'array'],
'expect_popen' => ['resource|false', 'command'=>'string'],
'explode' => ['array<int,string>|false', 'separator'=>'string', 'str'=>'string', 'limit='=>'int'],
'explode' => ['non-empty-array<int,string>|false', 'separator'=>'string', 'str'=>'string', 'limit='=>'int'],
'expm1' => ['float', 'number'=>'float'],
'extension_loaded' => ['bool', 'extension_name'=>'string'],
'extract' => ['int', '&rw_var_array'=>'array', 'extract_type='=>'int', 'prefix='=>'string|null'],
Expand Down
2 changes: 1 addition & 1 deletion resources/functionMap_php80delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'date_time_set' => ['DateTime', 'object'=>'DateTime', 'hour'=>'int', 'minute'=>'int', 'second='=>'int', 'microseconds='=>'int'],
'date_timestamp_set' => ['DateTime', 'object'=>'DateTime', 'unixtimestamp'=>'int'],
'date_timezone_set' => ['DateTime', 'object'=>'DateTime', 'timezone'=>'DateTimeZone'],
'explode' => ['array<int,string>', 'separator'=>'non-empty-string', 'str'=>'string', 'limit='=>'int'],
'explode' => ['non-empty-array<int,string>', 'separator'=>'non-empty-string', 'str'=>'string', 'limit='=>'int'],
'fdiv' => ['float', 'dividend'=>'float', 'divisor'=>'float'],
'get_debug_type' => ['string', 'var'=>'mixed'],
'get_resource_id' => ['int', 'res'=>'resource'],
Expand Down
6 changes: 3 additions & 3 deletions tests/PHPStan/Analyser/LegacyNodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8003,15 +8003,15 @@ public function dataExplode(): array
'$sureFalse',
],
[
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
PHP_VERSION_ID < 80000 ? '(array<int, string>&nonEmpty)|false' : 'array<int, string>&nonEmpty',
'$arrayOrFalse',
],
[
PHP_VERSION_ID < 80000 ? 'array<int, string>|false' : 'array<int, string>',
PHP_VERSION_ID < 80000 ? 'array<int, string>&nonEmpty|false' : 'array<int, string>&nonEmpty',
'$anotherArrayOrFalse',
],
[
PHP_VERSION_ID < 80000 ? '(array<int, string>|false)' : 'array<int, string>',
PHP_VERSION_ID < 80000 ? '((array<int, string>&nonEmpty)|false)' : 'array<int, string>&nonEmpty',
'$benevolentArrayOrFalse',
],
];
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Analyser/data/bug-3961-php8.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public function doFoo(string $v, string $d, $m): void
assertType('array<int, string>', explode('.', $v, -2));
assertType('array<int, string>&nonEmpty', explode('.', $v, 0));
assertType('array<int, string>&nonEmpty', explode('.', $v, 1));
assertType('array<int, string>', explode($d, $v));
assertType('array<int, string>', explode($m, $v));
assertType('array<int, string>&nonEmpty', explode($d, $v));
assertType('array<int, string>&nonEmpty', explode($m, $v));
}

}
4 changes: 2 additions & 2 deletions tests/PHPStan/Analyser/data/bug-4711.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ function x(string $string): void {
return;
}

assertType('array<int, string>', explode($string, ''));
assertType('array<int, string>', explode($string[0], ''));
assertType('array<int, string>&nonEmpty', explode($string, ''));
assertType('array<int, string>&nonEmpty', explode($string[0], ''));
}

}

0 comments on commit 25260db

Please sign in to comment.