Skip to content

Commit 0af0399

Browse files
b1rdexondrejmirtes
authored andcommitted
Add another test
1 parent 4b52a58 commit 0af0399

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,4 +1737,17 @@ public function testBug4199(): void
17371737
]);
17381738
}
17391739

1740+
public function testBug4188(): void
1741+
{
1742+
if (!self::$useStaticReflectionProvider && PHP_VERSION_ID < 70400) {
1743+
$this->markTestSkipped('Test requires PHP 7.4.');
1744+
}
1745+
1746+
$this->checkThisOnly = false;
1747+
$this->checkNullables = true;
1748+
$this->checkUnionTypes = true;
1749+
1750+
$this->analyse([__DIR__ . '/data/bug-4188.php'], []);
1751+
}
1752+
17401753
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php // lint >= 7.4
2+
3+
namespace Bug4188;
4+
5+
interface A {}
6+
interface B {}
7+
8+
class Test
9+
{
10+
/** @param array<A|B> $data */
11+
public function set(array $data): void
12+
{
13+
$this->onlyB(array_filter(
14+
$data,
15+
function ($param): bool {
16+
return $param instanceof B;
17+
},
18+
));
19+
}
20+
21+
/** @param array<A|B> $data */
22+
public function setShort(array $data): void
23+
{
24+
$this->onlyB(array_filter(
25+
$data,
26+
fn($param): bool => $param instanceof B,
27+
));
28+
}
29+
30+
/** @param B[] $data */
31+
public function onlyB(array $data): void {}
32+
}

0 commit comments

Comments
 (0)