Skip to content

Commit

Permalink
Add a failing test case for not passing in 3rd param
Browse files Browse the repository at this point in the history
  • Loading branch information
BackEndTea committed Jun 12, 2021
1 parent 3b132ff commit 061b13e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Expand Up @@ -560,6 +560,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'], [
Expand Down
12 changes: 12 additions & 0 deletions tests/PHPStan/Rules/Functions/data/array_reduce.php
Expand Up @@ -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,
);

0 comments on commit 061b13e

Please sign in to comment.