From 428beb21fbc4786991907712213c96fb0770e344 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 30 May 2020 22:59:18 +0200 Subject: [PATCH] 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 --- .../Internal/Stubs/CoreGenericFunctions.phpstub | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Psalm/Internal/Stubs/CoreGenericFunctions.phpstub b/src/Psalm/Internal/Stubs/CoreGenericFunctions.phpstub index 947be2927d1..a3fee3fefaf 100644 --- a/src/Psalm/Internal/Stubs/CoreGenericFunctions.phpstub +++ b/src/Psalm/Internal/Stubs/CoreGenericFunctions.phpstub @@ -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 $search + * @param string|array $replace + * @param string|array $subject * @param int $count - * @return string|string[] + * @return ($subject is array ? array : 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 $replace + * @param string|array $subject * @param int $count - * @return string|string[] + * @return ($subject is array ? array : string) * * @psalm-flow ($replace, $subject) -> return */