diff --git a/stubs/CoreGenericFunctions.phpstub b/stubs/CoreGenericFunctions.phpstub index 07198ae72..90a8ea7b2 100644 --- a/stubs/CoreGenericFunctions.phpstub +++ b/stubs/CoreGenericFunctions.phpstub @@ -602,6 +602,17 @@ function implode($glue, array $pieces = []) : string {} */ function explode(string $delimiter, string $string, int $limit = -1) : array {} +/** + * @psalm-pure + * + * @psalm-flow ($subject) -(array-assignment)-> return + * + * @return ($flags is 1|3|5|7 ? list|false : non-empty-list|false) + * + * @psalm-ignore-falsable-return + */ +function preg_split(string $pattern, string $subject, int $limit = -1, int $flags = 0) {} + /** * @param array $input * diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index 2f7298412..b3080a7cf 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -1355,6 +1355,13 @@ class FunctionCallTest extends TestCase [], '7.4' ], + 'pregSplit' => [ + ' 'ArgumentTypeCoercion', ], + 'pregSplitNoEmpty' => [ + ' 'InvalidReturnStatement' + ], ]; } }