Skip to content

Commit 41a3fb9

Browse files
committed
Added regression test
1 parent 05d1818 commit 41a3fb9

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,4 +556,16 @@ public function testNewIsAlwaysFinalClass(): void
556556
]);
557557
}
558558

559+
public function testBug13469(): void
560+
{
561+
$this->treatPhpDocTypesAsCertain = false;
562+
$this->analyse([__DIR__ . '/data/bug-13469.php'], [
563+
[
564+
'Instanceof between Bug13469\Foo and Stringable will always evaluate to true.',
565+
23
566+
567+
]
568+
]);
569+
}
570+
559571
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Bug13469;
4+
5+
use Stringable;
6+
7+
trait FooTrait
8+
{
9+
public function __toString(): string
10+
{
11+
return 'foo';
12+
}
13+
}
14+
15+
class Foo
16+
{
17+
use FooTrait;
18+
}
19+
20+
function doFoo() {
21+
$foo = new Foo();
22+
23+
var_dump($foo instanceof Stringable);
24+
}
25+

0 commit comments

Comments
 (0)