From e7005245b8255c41c52fbaf8f086a6f41411c254 Mon Sep 17 00:00:00 2001 From: hirokinoue <70567194+hirokinoue@users.noreply.github.com> Date: Sat, 14 May 2022 23:36:51 +0900 Subject: [PATCH 1/3] add test case for implode() --- tests/ArrayFunctionCallTest.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/ArrayFunctionCallTest.php b/tests/ArrayFunctionCallTest.php index 8ab3396a6de..d6bfc9b41df 100644 --- a/tests/ArrayFunctionCallTest.php +++ b/tests/ArrayFunctionCallTest.php @@ -1055,6 +1055,31 @@ function mapdef(string $_a, int $_b = 0): string { '$b===' => 'non-empty-literal-string', ] ], + 'implodeArrayOfNonEmptyStringAndEmptyString' => [ + ' 'non-empty-literal-string', + '$b===' => 'non-empty-string', + ] + ], + 'implodeEmptyArrayAndString' => [ + ' 'string', + '$b===' => 'string', + ] + ], 'key' => [ ' 1, "two" => 3]; From 91640e7e9098688f0f0c3895b89f8e741b181dc6 Mon Sep 17 00:00:00 2001 From: hirokinoue <70567194+hirokinoue@users.noreply.github.com> Date: Sat, 14 May 2022 23:44:43 +0900 Subject: [PATCH 2/3] improve @return annotation of implode() --- stubs/CoreGenericFunctions.phpstub | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stubs/CoreGenericFunctions.phpstub b/stubs/CoreGenericFunctions.phpstub index 6a6a97711d4..60db20e1b5e 100644 --- a/stubs/CoreGenericFunctions.phpstub +++ b/stubs/CoreGenericFunctions.phpstub @@ -582,7 +582,12 @@ function rtrim(string $string, string $characters = " \t\n\r\0\x0B") : string {} * : non-empty-string * ) * : string) - * : string + * : ($array is non-empty-array + * ? ($array is array + * ? ($array is array ? non-empty-literal-string : non-empty-string) + * : string + * ) + * : string) * ) * * @psalm-flow ($separator) -> return From 4fc34d998b5e0af6a4bbc3fcda2d9e1c20d95833 Mon Sep 17 00:00:00 2001 From: hirokinoue <70567194+hirokinoue@users.noreply.github.com> Date: Sat, 14 May 2022 23:47:46 +0900 Subject: [PATCH 3/3] improve @return annotation of join() --- stubs/CoreGenericFunctions.phpstub | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stubs/CoreGenericFunctions.phpstub b/stubs/CoreGenericFunctions.phpstub index 60db20e1b5e..800383c0dfb 100644 --- a/stubs/CoreGenericFunctions.phpstub +++ b/stubs/CoreGenericFunctions.phpstub @@ -609,7 +609,12 @@ function implode($separator, array $array = []) : string {} * : non-empty-string * ) * : string) - * : string + * : ($array is non-empty-array + * ? ($array is array + * ? ($array is array ? non-empty-literal-string : non-empty-string) + * : string + * ) + * : string) * ) * * @psalm-flow ($separator) -> return