Skip to content

Commit

Permalink
Improve stubs for str_replace and preg_replace (#3495)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
orklah and muglug committed May 30, 2020
1 parent 51bf7f3 commit 428beb2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Psalm/Internal/Stubs/CoreGenericFunctions.phpstub
Expand Up @@ -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
*/
Expand All @@ -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
*/
Expand Down

0 comments on commit 428beb2

Please sign in to comment.