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!
Bug report
PHPStan reports
identical.alwaysFalseonget_parent_class($this) === self::classinside 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
truefor B,falsefor C.Code snippet that reproduces the problem
https://phpstan.org/r/170a2fc8-177d-4ea3-8e27-3d41f4edd7d9
Expected output
identical.alwaysFalsewas 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!