Support for class-string $class parameter in is_subclass_of()#1039
Support for class-string $class parameter in is_subclass_of()#1039ondrejmirtes merged 1 commit intophpstan:masterfrom
Conversation
when does this happen? Could it use This would work, when the |
|
Hi, I found some inconsistencies with falsey contexts and UPDATE: phpstan/phpstan#6704 is what I was referring to. |
|
@staabm this happens when the $object param is a string, and the $allow_string param is false, or if $object is not a super type of object|string. Both of these cases are not possible in a truthy context and IsSubclassOfFunctionTypeSpecifyingExtension will specify $object to I took more time to have a better understanding of TypeSpecifyingExtension / TypeSpecifier, and I've found that the intersect is not needed as it's already done by TypeSpecifier::create(). So I've just removed the intersect. |
c7d640d to
a109fd3
Compare
|
Thank you! |
This adds support for $class parameter of type class-string in is_subclass_of().
I tried to unify the logic for the cases when $class is a constant string, a class string, or something else.
I also tried to narrow the specified type when we know that the $object parameter is either a string or an object. For example if the parameter is a string, it will no longer be specified as class-string|object.
There is one caveat: the type specifier extension may now specify the $object parameter as
*NEVER*in some impossible cases. Is this acceptable ?This fixes phpstan/phpstan#6698