-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
phpstan/phpstan-src
#2336Labels
Milestone
Description
Bug report
When using get_parent_class($object) on something that may be a subclass, PHPStan assume that it can only return false.
Code snippet that reproduces the problem
class HelloWorld
{
public function theMethod(MyInterface $object) {
if (get_parent_class($object)) { // <-- ERROR: if condition is always false
return 1;
}
}
}
interface MyInterface {}https://phpstan.org/r/a374c54d-1422-4c1e-9a34-5005f6668c8c
Expected output
When using an interface or a superclass, PHPStan should not be sure about the return being false, it should keep the type string|false, because the real object may be a subclass of the one typehinted
Reactions are currently unavailable