Skip to content

Conversation

VincentLanglet
Copy link
Contributor

I'm not sure about the purpose of the InvalidComparisonOperationRule which seams to forbid comparison between number and object or number and arrays. Technically something like $int == $array is supported by php (and 0 == [] for instance).
Maybe the message

Comparison operation "!=" between array and 0 results in an error.

should be improved, but that's another topic.

Looking at the implementation, both isPossiblyNullableObjectType and isPossiblyNullableArrayType shouldn't use the RuleLevelHelper, because it will removed non-array/non-object on lower level and this is the reason why an error happen on level 6 (and then disappear in level 7).

Finally, I notice that currently a comparison between int and object|array is not reported.
This is easy to fix, but since I dunno the whole purpose of this rule, I prefer to ask you first @ondrejmirtes if I should fix it too.

Closes phpstan/phpstan#3364

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Level 6 - Comparison operation ... results in an error ; Level 7 - No errors
1 participant