From eb63e0c9182f203c8e6789f9b31892a2f34a169d Mon Sep 17 00:00:00 2001 From: Marcus Bointon Date: Thu, 15 Oct 2020 01:59:07 +0200 Subject: [PATCH] Fix preg_match_all stub (#4325) * preg_match_all can return false * Test for preg_match_all returning false * Fix test * Add @psalm-ignore-falsable-return --- stubs/CoreGenericFunctions.phpstub | 3 ++- tests/FunctionCallTest.php | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/stubs/CoreGenericFunctions.phpstub b/stubs/CoreGenericFunctions.phpstub index b4bcaaff9b3..f37af3c13c1 100644 --- a/stubs/CoreGenericFunctions.phpstub +++ b/stubs/CoreGenericFunctions.phpstub @@ -760,7 +760,8 @@ function preg_replace_callback($search, $replace, $subject, int $limit = -1, &$c * ) * ) * ) $matches - * @return int + * @return int|false + * @psalm-ignore-falsable-return */ function preg_match_all($pattern, $replace, &$matches = [], int $flags = 1, int $offset = 0) {} diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index 95e822e0899..b5c91acc75b 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -1341,6 +1341,15 @@ function foo(string $input): array { return $matches[0]; }' ], + 'pregMatchAllReturnsFalse' => [ + ' [ '