🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

PHPStan reports identical.alwaysFalse on get_parent_class($this) === self::class inside a non-final class #14951

Description

@27pchrisl

Bug report

PHPStan reports identical.alwaysFalse on get_parent_class($this) === self::class inside a non-final class, claiming the comparison always evaluates to false.

Because the method can be inherited, and for any direct subclass, get_parent_class($this) returns the declaring class's name, this makes the comparison true at runtime.

This function is intended to help instances of B and C determine whether they are direct children of A (in the playground example). Therefore true for B, false for C.

Code snippet that reproduces the problem

https://phpstan.org/r/170a2fc8-177d-4ea3-8e27-3d41f4edd7d9

Expected output

identical.alwaysFalse was reported incorrectly.

Did PHPStan help you today? Did it make you happy in any way?

PHPStan's crucial, catches issues the test suite can't!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions