1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

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
This commit is contained in:
Marcus Bointon 2020-10-15 01:59:07 +02:00 committed by Daniil Gentili
parent d4ccfcf75d
commit fb505df807
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 11 additions and 1 deletions

View File

@ -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) {}

View File

@ -1341,6 +1341,15 @@ class FunctionCallTest extends TestCase
return $matches[0];
}'
],
'pregMatchAllReturnsFalse' => [
'<?php
/**
* @return int|false
*/
function badpattern() {
return @preg_match_all("foo", "foo", $matches);
}'
],
'strposAllowDictionary' => [
'<?php
function sayHello(string $format): void {