-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added error message to impossible instanceof rule to warn when comparing a trait. #1570
Added error message to impossible instanceof rule to warn when comparing a trait. #1570
Conversation
b11bbb2
to
6885b96
Compare
6885b96
to
6c45692
Compare
@@ -418,6 +419,16 @@ public function dataIsSuperTypeOf(): array | |||
new ObjectType(ExtendsThrowable::class), | |||
TrinaryLogic::createMaybe(), | |||
], | |||
59 => [ | |||
new ObjectType(DateTime::class), | |||
new ObjectType(ConstantNumericComparisonTypeTrait::class), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty sure php has no built-in traits so i used one that phpstan has, i feel like theres a better way to do this though
Maybe this rule is a better fit for this problem? https://github.com/phpstan/phpstan-src/blob/1.8.x/src/Rules/Classes/ExistingClassInInstanceOfRule.php |
i think either location works, though i think "existing class" is a bit more indirect than "impossible instanceof" when it comes to comparing a trait in instanceof as a trait is not a class |
On the other hand there's already ReflectionProvider in the "existing class" rule, and to me it makes more sense there because trait is not an existing class 😊 I just forgot that rule exists, sorry 😊 |
no worries mate, i've moved the check to the ExistingClassInInstanceOf rule |
Thank you! |
implements phpstan/phpstan#7720 (comment)