Skip to content

Commit ef20977

Browse files
Merge tests
1 parent cd097f9 commit ef20977

5 files changed

Lines changed: 50 additions & 89 deletions

File tree

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,27 +2753,6 @@ public function testBug11619Strict(): void
27532753
$this->analyse([__DIR__ . '/data/bug-11619-strict.php'], []);
27542754
}
27552755

2756-
#[RequiresPhp('>= 8.1')]
2757-
public function testBug11619Error(): void
2758-
{
2759-
$this->analyse([__DIR__ . '/data/bug-11619-error.php'], [
2760-
[
2761-
'Parameter #1 $string1 of function strnatcasecmp expects string, Bug11619Error\Foo given.',
2762-
32,
2763-
],
2764-
[
2765-
'Parameter #2 $string2 of function strnatcasecmp expects string, Bug11619Error\Foo given.',
2766-
32,
2767-
],
2768-
]);
2769-
}
2770-
2771-
#[RequiresPhp('>= 8.1')]
2772-
public function testBug11619Typed(): void
2773-
{
2774-
$this->analyse([__DIR__ . '/data/bug-11619-typed.php'], []);
2775-
}
2776-
27772756
public function testBug13247(): void
27782757
{
27792758
$this->analyse([__DIR__ . '/data/bug-13247.php'], []);

tests/PHPStan/Rules/Functions/data/bug-11619-error.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

tests/PHPStan/Rules/Functions/data/bug-11619-strict.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,29 @@ function test(): void
2727

2828
uasort($options, 'strnatcasecmp');
2929
usort($options, 'strnatcasecmp');
30+
31+
uasort($options, fn($a, $b) => strnatcasecmp($a, $b));
32+
uasort($options, fn(string $a, string $b) => strnatcasecmp($a, $b));
33+
}
34+
35+
/**
36+
* @param array<\Stringable> $a
37+
* @param callable(\Stringable, \Stringable): int $f
38+
*/
39+
function customUsort(array &$a, callable $f): void
40+
{
41+
for ($i = 1; $i < count($a); $i++)
42+
for ($j = $i; $j > 0 && $f($a[$j-1], $a[$j]) > 0; $j--)
43+
[$a[$j-1], $a[$j]] = [$a[$j], $a[$j-1]];
44+
}
45+
46+
function test2(): void
47+
{
48+
$options = [
49+
Foo::fromString('c'),
50+
Foo::fromString('b'),
51+
Foo::fromString('a'),
52+
];
53+
54+
customUsort($options, 'strnatcasecmp');
3055
}

tests/PHPStan/Rules/Functions/data/bug-11619-typed.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

tests/PHPStan/Rules/Functions/data/bug-11619.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,29 @@ function test(): void
2727

2828
uasort($options, 'strnatcasecmp');
2929
usort($options, 'strnatcasecmp');
30+
31+
uasort($options, fn($a, $b) => strnatcasecmp($a, $b));
32+
uasort($options, fn(string $a, string $b) => strnatcasecmp($a, $b));
33+
}
34+
35+
/**
36+
* @param array<\Stringable> $a
37+
* @param callable(\Stringable, \Stringable): int $f
38+
*/
39+
function customUsort(array &$a, callable $f): void
40+
{
41+
for ($i = 1; $i < count($a); $i++)
42+
for ($j = $i; $j > 0 && $f($a[$j-1], $a[$j]) > 0; $j--)
43+
[$a[$j-1], $a[$j]] = [$a[$j], $a[$j-1]];
44+
}
45+
46+
function test2(): void
47+
{
48+
$options = [
49+
Foo::fromString('c'),
50+
Foo::fromString('b'),
51+
Foo::fromString('a'),
52+
];
53+
54+
customUsort($options, 'strnatcasecmp');
3055
}

0 commit comments

Comments
 (0)