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

Improve stubs for str_replace and preg_replace (#3495)

* expand accepted values for str_replace and preg_replace. Make return conditional based on type of $subject

* Remove int|float from str_replace/preg_replace

Co-authored-by: Matthew Brown <github@muglug.com>
This commit is contained in:
orklah 2020-05-30 22:59:18 +02:00 committed by GitHub
parent 51bf7f38de
commit 428beb21fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -560,11 +560,11 @@ function htmlspecialchars_decode(string $string, ?int $quote_style = null) : str
/**
* @psalm-pure
*
* @param string|string[] $search
* @param string|string[] $replace
* @param string|string[] $subject
* @param string|array<string|int|float> $search
* @param string|array<string|int|float> $replace
* @param string|array<string|int|float> $subject
* @param int $count
* @return string|string[]
* @return ($subject is array ? array<string> : string)
*
* @psalm-flow ($replace, $subject) -> return
*/
@ -574,10 +574,10 @@ function str_replace($search, $replace, $subject, &$count = null) {}
* @psalm-pure
*
* @param string|string[] $search
* @param string|string[] $replace
* @param string|string[] $subject
* @param string|array<string|int|float> $replace
* @param string|array<string|int|float> $subject
* @param int $count
* @return string|string[]
* @return ($subject is array ? array<string> : string)
*
* @psalm-flow ($replace, $subject) -> return
*/