Skip to content

Commit b4bde31

Browse files
committed
Add test cases where a function with the second argument omitted is accepted
1 parent 9798bd4 commit b4bde31

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -903,11 +903,11 @@ public function testArrayFindCallback(): void
903903
],
904904
[
905905
'Parameter #2 $callback of function array_find expects callable(mixed, int|string): bool, Closure(string, array): false given.',
906-
49,
906+
52,
907907
],
908908
[
909909
'Parameter #2 $callback of function array_find expects callable(mixed, int|string): bool, Closure(string, int): array{} given.',
910-
52,
910+
55,
911911
],
912912
]);
913913
}
@@ -929,11 +929,11 @@ public function testArrayFindKeyCallback(): void
929929
],
930930
[
931931
'Parameter #2 $callback of function array_find_key expects callable(mixed, int|string): bool, Closure(string, array): false given.',
932-
49,
932+
52,
933933
],
934934
[
935935
'Parameter #2 $callback of function array_find_key expects callable(mixed, int|string): bool, Closure(string, int): array{} given.',
936-
52,
936+
55,
937937
],
938938
]);
939939
}

tests/PHPStan/Rules/Functions/data/array_find.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ function(int $value, string $key) {
4545
// ok
4646
array_find($array, fn (string $value, int $key) => $key === 0);
4747

48+
// ok
49+
array_find($array, fn (string $value) => $key === 0);
50+
4851
// bad parameters
4952
array_find($array, fn (string $item, array $key) => $key === 0);
5053

tests/PHPStan/Rules/Functions/data/array_find_key.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ function(int $value, string $key) {
4545
// ok
4646
array_find_key($array, fn (string $value, int $key) => $key === 0);
4747

48+
// ok
49+
array_find_key($array, fn (string $value) => $value === 'foo');
50+
4851
// bad parameters
4952
array_find_key($array, fn (string $item, array $key) => $key === 0);
5053

0 commit comments

Comments
 (0)