phpstan-src
phpstan-src copied to clipboard
Fix is_subclass_of(string, string) generates invalid prediction
Fixes https://github.com/phpstan/phpstan/issues/3979
Hi, I'm sorry, this isn't the right fix. We should look into why is this reported. This code sample goes shows more about the types involved (class-string and non-falsy-string): https://phpstan.org/r/4399bb2a-cf2b-4038-9716-97cac1e647d4
My guess is that the bug is rather in IsSubclassOfFunctionTypeSpecifyingExtension.
Hi @ondrejmirtes thanks for the hint!
I looked into IsSubclassOfFunctionTypeSpecifyingExtension and tried to make changes that hopefully fit a little better. Still I am not sure if this is the fix you were looking for as this is still somewhat ignoring the "root cause" so to say.
If this still isn't sufficient I'd appreciate some more directions as to where the problem should be fixed :)
I'd say the extension doesn't add any value and only confuses the analyser for class-string and non-falsy-string input types. So we'd have to identify for what types it adds some value for type inference, and in other cases just return empty new SpecifiedTypes()
.
I'm afraid I don't quite understand what you're trying to say or want me to change.
I'd say the extension doesn't add any value
Does this refer to my changes or to the IsSubclassOfFunctionTypeSpecifyingExtension
itself?
So we'd have to identify for what types it adds some value for type inference
How would I go about that? Is there some guideline/example I could base this off?
and in other cases just return empty new SpecifiedTypes().
So basically this would be "check if this extension can add valueable types", if not return SpecifiedTypes
, else return valueable types?
Hi, I'm cleaning up old and stale PRs. Please send a new PR if you're still interested, thanks.