Skip to content

Commit 3f31056

Browse files
committed
Regression test
1 parent e9b40b7 commit 3f31056

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3172,4 +3172,23 @@ public function testRequireImplements(): void
31723172
]);
31733173
}
31743174

3175+
public function testBug6371(): void
3176+
{
3177+
$this->checkThisOnly = false;
3178+
$this->checkNullables = true;
3179+
$this->checkUnionTypes = true;
3180+
$this->checkExplicitMixed = true;
3181+
3182+
$this->analyse([__DIR__ . '/data/bug-6371.php'], [
3183+
[
3184+
'Parameter #1 $t of method Bug6371\HelloWorld<int,string>::compare() expects int, true given.',
3185+
24,
3186+
],
3187+
[
3188+
'Parameter #2 $k of method Bug6371\HelloWorld<int,string>::compare() expects string, false given.',
3189+
24,
3190+
],
3191+
]);
3192+
}
3193+
31753194
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Bug6371;
4+
5+
/**
6+
* @template T
7+
* @template K
8+
*
9+
* @method bool compare(T $t, K $k) Compares two objects magically somehow
10+
*/
11+
class HelloWorld
12+
{
13+
public function __call(string $name, array $args) {
14+
return true;
15+
}
16+
}
17+
18+
/**
19+
* @param HelloWorld<int, string> $hw
20+
* @return void
21+
*/
22+
function foo (HelloWorld $hw): void {
23+
$hw->compare(1, 'foo');
24+
$hw->compare(true, false);
25+
};

0 commit comments

Comments
 (0)