File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
tests/PHPStan/Rules/Methods Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments