Skip to content

Commit cd097f9

Browse files
committed
more tests
1 parent 82945c6 commit cd097f9

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,6 +2753,27 @@ 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+
27562777
public function testBug13247(): void
27572778
{
27582779
$this->analyse([__DIR__ . '/data/bug-13247.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+
namespace Bug11619Error;
4+
5+
final class Foo implements \Stringable {
6+
7+
private function __construct(public readonly string $value) {
8+
}
9+
10+
public static function fromString(string $string): self {
11+
return new self($string);
12+
}
13+
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
public function __toString(): string {
18+
return $this->value;
19+
}
20+
21+
}
22+
23+
$options = [
24+
Foo::fromString('c'),
25+
Foo::fromString('b'),
26+
Foo::fromString('a'),
27+
Foo::fromString('ccc'),
28+
Foo::fromString('bcc'),
29+
];
30+
31+
32+
uasort($options, fn($a, $b) => strnatcasecmp($a, $b));
33+
34+
var_export($options);
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+
namespace Bug11619Typed;
4+
5+
final class Foo implements \Stringable {
6+
7+
private function __construct(public readonly string $value) {
8+
}
9+
10+
public static function fromString(string $string): self {
11+
return new self($string);
12+
}
13+
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
public function __toString(): string {
18+
return $this->value;
19+
}
20+
21+
}
22+
23+
$options = [
24+
Foo::fromString('c'),
25+
Foo::fromString('b'),
26+
Foo::fromString('a'),
27+
Foo::fromString('ccc'),
28+
Foo::fromString('bcc'),
29+
];
30+
31+
32+
uasort($options, fn(string $a, string $b) => strnatcasecmp($a, $b));
33+
34+
var_export($options);

0 commit comments

Comments
 (0)