You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect "comparison will always evaluate to false" for comparison between static::class and <subclass>::class in class with @template #10498
<?phpabstractclass A
{
publicstaticfunctionfoo(): void
{
if (static::class === B::class) {
printf("I'm a %s" . PHP_EOL, B::class);
}
}
}
class B extends A {}
Fails:
<?php/** * @template T of object */abstractclass A
{
publicstaticfunctionfoo(): void
{
if (static::class === B::class) {
printf("I'm a %s" . PHP_EOL, B::class);
}
}
}
/** * @extends A<C> */class B extends A {}
class C {};
@@ @@-10: Strict comparison using === between class-string<static(A<T of object>)> and 'B' will always evaluate to false.+10: Strict comparison using === between class-string<static(A<T of object (class A, argument)>)> and 'B' will always evaluate to false.
Full report
Line
Error
10
Strict comparison using === between class-string<static(A<T of object (class A, argument)>)> and 'B' will always evaluate to false.
Activity
phpstan-bot commentedon Sep 26, 2024
@lkrms After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
Full report
Strict comparison using === between class-string<static(A<T of object (class A, argument)>)> and 'B' will always evaluate to false.Add regression test for #10498