diff --git a/stubs/CoreGenericFunctions.phpstub b/stubs/CoreGenericFunctions.phpstub index 07198ae7285..90a8ea7b24c 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 bcac0bb8f39..2e831127521 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -1347,6 +1347,13 @@ function sayHello(string $format): void { if (strpos("abcdefghijklmno", $format)) {} }', ], + 'pregSplit' => [ + ' 'InvalidLiteralArgument', ], + 'pregSplitNoEmpty' => [ + ' 'InvalidReturnStatement' + ], ]; } }