forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexplode.php
More file actions
29 lines (21 loc) · 725 Bytes
/
explode.php
File metadata and controls
29 lines (21 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php // lint >= 8.0
namespace ExplodeFunction;
use function PHPStan\Testing\assertType;
function (string $delimiter, $mixed) {
/** @var string $str */
$str = doFoo();
$sureArray = explode(' ', $str);
$sureFalse = explode('', $str);
$arrayOrFalse = explode($delimiter, $str);
$emptyOrComma = '';
if (doFoo()) {
$emptyOrComma = ',';
}
$anotherArrayOrFalse = explode($emptyOrComma, $str);
$benevolentArrayOrFalse = explode($mixed, $str);
assertType('non-empty-list<string>', $sureArray);
assertType('*NEVER*', $sureFalse);
assertType('non-empty-list<string>', $arrayOrFalse);
assertType('non-empty-list<string>', $anotherArrayOrFalse);
assertType('non-empty-list<string>', $benevolentArrayOrFalse);
};