diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index 80b4e8ee120..e86dd797009 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -561,6 +561,14 @@ public function testArrayFunctionCallbackIsValidated(): void 'Parameter #2 $callback of function array_reduce expects callable(string, int|string): string, Closure(string, string): string given.', 5, ], + [ + 'Parameter #2 $callback of function array_reduce expects callable(string|null, int): string|null, Closure(string, int): string given.', + 11 + ], + [ + 'Parameter #2 $callback of function array_reduce expects callable(string|null, int): string|null, Closure(string, int): string given.', + 18 + ] ]); $this->analyse([__DIR__ . '/data/array_map.php'], [ diff --git a/tests/PHPStan/Rules/Functions/data/array_reduce.php b/tests/PHPStan/Rules/Functions/data/array_reduce.php index da95486054f..2857029bd31 100644 --- a/tests/PHPStan/Rules/Functions/data/array_reduce.php +++ b/tests/PHPStan/Rules/Functions/data/array_reduce.php @@ -5,3 +5,15 @@ fn(string $foo, string $current): string => $foo . $current, '' ); + +array_reduce( + [1,2,3], + fn(string $foo, int $current): string => $foo . $current, + null +); + + +array_reduce( + [1,2,3], + fn(string $foo, int $current): string => $foo . $current, +);