Skip to content

Commit 98a3b07

Browse files
authored
Add array_udiff to arrayFunctions.stub
1 parent ef8c7c3 commit 98a3b07

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

stubs/arrayFunctions.stub

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,16 @@ function uksort(
4848
array &$one,
4949
callable $two
5050
): bool {}
51+
52+
/**
53+
* @template T of mixed
54+
*
55+
* @param array<T> $one
56+
* @param array<T> $two
57+
* @param callable(T, T): int<-1, 1> $three
58+
*/
59+
function array_udiff(
60+
array $one,
61+
array $two,
62+
callable $three
63+
): int {}

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,32 @@ public function testArrayWalkArrowFunctionCallback(): void
618618
]);
619619
}
620620

621+
public function testArrayUdiffCallback(): void
622+
{
623+
$this->analyse([__DIR__ . '/data/array_udiff.php'], [
624+
[
625+
'Parameter #3 $data_comp_func of function array_udiff expects callable(int, int): int<-1, 1>, Closure(string, string): string given.',
626+
6,
627+
],
628+
[
629+
'Parameter #3 $data_comp_func of function array_udiff expects callable(int, int): int<-1, 1>, Closure(int, int): non-empty-string given.',
630+
14,
631+
],
632+
[
633+
'Parameter #1 $arr1 of function array_udiff expects array<string>, null given.',
634+
20,
635+
],
636+
[
637+
'Parameter #2 $arr2 of function array_udiff expects array<string>, null given.',
638+
21,
639+
],
640+
[
641+
'Parameter #3 $data_comp_func of function array_udiff expects callable(string, string): int<-1, 1>, Closure(string, int): non-empty-string given.',
642+
22,
643+
],
644+
]);
645+
}
646+
621647
public function testPregReplaceCallback(): void
622648
{
623649
$this->analyse([__DIR__ . '/data/preg_replace_callback.php'], [
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php declare(strict_types = 1);
2+
3+
array_udiff(
4+
[1,2,3],
5+
[4,5,6],
6+
function(string $a, string $b): string {
7+
return $a . $b;
8+
},
9+
);
10+
11+
array_udiff(
12+
[1,2,3],
13+
[4,5,6],
14+
function(int $a, int $b): string {
15+
return $a . $b;
16+
},
17+
);
18+
19+
array_udiff(
20+
null,
21+
null,
22+
function(string $a, int $b): string {
23+
return $a . $b;
24+
},
25+
);
26+
27+
array_udiff(
28+
[25,26],
29+
[26,27],
30+
static function(int $a, int $b): int {
31+
return $a <=> $b;
32+
},
33+
);
34+

0 commit comments

Comments
 (0)