Skip to content

Commit 8dcc4a6

Browse files
staabmondrejmirtes
authored andcommitted
Added regression test
1 parent c75c035 commit 8dcc4a6

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,4 +556,15 @@ 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+
559570
}
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)