Skip to content

Commit 0379b43

Browse files
phpstan-botclaude
andcommitted
Added regression test for static::class comparison in a generic class
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 03a99cb commit 0379b43

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

‎tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,11 @@ public function testBug14966(): void
12641264
$this->analyse([__DIR__ . '/data/bug-14966.php'], []);
12651265
}
12661266

1267+
public function testBug10498(): void
1268+
{
1269+
$this->analyse([__DIR__ . '/data/bug-10498.php'], []);
1270+
}
1271+
12671272
public function testBug14847(): void
12681273
{
12691274
$this->analyse([__DIR__ . '/data/bug-14847.php'], [
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Bug10498;
4+
5+
use const PHP_EOL;
6+
use function printf;
7+
8+
/**
9+
* @template T of object
10+
*/
11+
abstract class A
12+
{
13+
14+
public static function foo(): void
15+
{
16+
if (static::class === B::class) {
17+
printf("I'm a %s" . PHP_EOL, B::class);
18+
}
19+
}
20+
21+
}
22+
23+
/**
24+
* @extends A<C>
25+
*/
26+
class B extends A
27+
{
28+
29+
}
30+
31+
class C
32+
{
33+
34+
}

0 commit comments

Comments
 (0)