Added error message to impossible instanceof rule to warn when comparing a trait.#1570
Conversation
b11bbb2 to
6885b96
Compare
6885b96 to
6c45692
Compare
| ], | ||
| 59 => [ | ||
| new ObjectType(DateTime::class), | ||
| new ObjectType(ConstantNumericComparisonTypeTrait::class), |
There was a problem hiding this comment.
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)