Fix ClassConstFetch Identical specification with Yoda conditions#2498
Conversation
|
Hi, I'd be happier with NodeScopeResolverTest. We can leave the rule test but it'd be best to check the type inference (truthy/falsy context too). Thanks! |
ac0b40b to
1250516
Compare
|
sure. added it. |
1250516 to
7ee61dd
Compare
There was a problem hiding this comment.
There's a bad bug here. So you've eliminated that $translatable isn't TranslatableMessage. But it can still be a subclass of TranslatableMessage.
Most likely we should only specify the type for $context->true().
Same thing is done for get_class:
phpstan-src/src/Analyser/TypeSpecifier.php
Lines 194 to 210 in 2df1a59
There was a problem hiding this comment.
could we be "smarter" if TranslatableMessage is a reference to a final class (or a interface)?
There was a problem hiding this comment.
We could, but first we need to get rid of the bug, then we can improve it :)
There was a problem hiding this comment.
adapted. better? I didn't even notice this.. :)
There was a problem hiding this comment.
oh sorry, I was lazy and didn't run the full tests :/
Avoids false positive inheritance types in false context
fe58422 to
446ee63
Compare
Closes phpstan/phpstan#9542
Is this how you would have done it? Might be the simplest way I guess. It's just an adapted version to handle the left/right mixed variant of the block directly before it.
UPDATE: I had the urge to somehow simplify/cleanup things, like the way left and right types are fetched from the scope, assigned to variables and used, in Identical in a follow-up but I failed. Better not touch it too much 😅