Skip to content

Commit 2f3d0bb

Browse files
committed
add test for issue 7707
1 parent 1ff2ba3 commit 2f3d0bb

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

Diff for: tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,13 @@ public function testArrayUintersect(): void
18671867
]);
18681868
}
18691869

1870+
public function testBug7707(): void
1871+
{
1872+
$this->checkExplicitMixed = true;
1873+
1874+
$this->analyse([__DIR__ . '/data/bug-7707.php'], []);
1875+
}
1876+
18701877
public function testNoNamedArguments(): void
18711878
{
18721879
if (PHP_VERSION_ID < 80000) {

Diff for: tests/PHPStan/Rules/Functions/data/bug-7707.php

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug7707;
4+
5+
class HelloWorld
6+
{
7+
public function sayHello(): void
8+
{
9+
var_dump(array_diff_uassoc(
10+
['a' => 1, 'b' => 2],
11+
['c' => 1, 'd' => 2],
12+
// keys comparison
13+
static function (string $a, string $b): int {
14+
return $a <=> $b;
15+
}
16+
));
17+
18+
var_dump(array_diff_ukey(
19+
['a' => 1, 'b' => 2],
20+
['c' => 1, 'd' => 2],
21+
// keys comparison
22+
static function (string $a, string $b): int {
23+
return $a <=> $b;
24+
}
25+
));
26+
27+
var_dump(array_intersect_uassoc(
28+
['a' => 1, 'b' => 2],
29+
['c' => 1, 'd' => 2],
30+
// keys comparison
31+
static function (string $a, string $b): int {
32+
return $a <=> $b;
33+
}
34+
));
35+
36+
var_dump(array_intersect_ukey(
37+
['a' => 1, 'b' => 2],
38+
['c' => 1, 'd' => 2],
39+
// keys comparison
40+
static function (string $a, string $b): int {
41+
return $a <=> $b;
42+
}
43+
));
44+
45+
var_dump(array_udiff_assoc(
46+
['a' => 1, 'b' => 2],
47+
['c' => 1, 'd' => 2],
48+
// values comparison
49+
static function (int $a, int $b): int {
50+
return $a <=> $b;
51+
}
52+
));
53+
54+
var_dump(array_udiff_uassoc(
55+
['a' => 1, 'b' => 2],
56+
['c' => 1, 'd' => 2],
57+
// values comparison
58+
static function (int $a, int $b): int {
59+
return $a <=> $b;
60+
},
61+
// keys comparison
62+
static function (string $a, string $b): int {
63+
return $a <=> $b;
64+
}
65+
));
66+
67+
var_dump(array_uintersect_assoc(
68+
['a' => 1, 'b' => 2],
69+
['c' => 1, 'd' => 2],
70+
// values comparison
71+
static function (int $a, int $b): int {
72+
return $a <=> $b;
73+
}
74+
));
75+
76+
var_dump(array_uintersect_uassoc(
77+
['a' => 1, 'b' => 2],
78+
['c' => 1, 'd' => 2],
79+
// values comparison
80+
static function (int $a, int $b): int {
81+
return $a <=> $b;
82+
},
83+
// keys comparison
84+
static function (string $a, string $b): int {
85+
return $a <=> $b;
86+
}
87+
));
88+
89+
var_dump(array_uintersect(
90+
['a' => 1, 'b' => 2],
91+
['c' => 1, 'd' => 2],
92+
// values comparison
93+
static function (int $a, int $b): int {
94+
return $a <=> $b;
95+
}
96+
));
97+
}
98+
}

0 commit comments

Comments
 (0)