Conversation
|
I think loose comparisons should be implemented via a new method like |
|
I see. This implies we also need to implement moving the code arround will touch stuff already changed in #1634, so I will wait until #1634 is merged before starting the refactoring. |
|
Strict compare method isn't needed, that's already basically isSuperTypeOf, if you see how Identical is implemented in MutatingScope. I don't know of any bug that would suggest lack of something in this area. |
staabm
left a comment
There was a problem hiding this comment.
added the new type method.
looked into the test errors and as far as I can say, these look like unrelated to this PR.
| return new BooleanType(); | ||
| } | ||
|
|
||
| public function resolveEqualType(Type $leftType, Type $rightType): BooleanType |
There was a problem hiding this comment.
if desired, resolveEqualType could be inlined as it is now a single line method
ondrejmirtes
left a comment
There was a problem hiding this comment.
The implementations of looseCompare are going to be much more complicated, also i don't think there's such a thing as NonLooseComparableTrait. Every type can be put in ==...
|
ok, just to get it right: I need to implement/test all types compared against all other types (+itself), right? |
|
Yes. It's PITA for sure 😊 |
|
If you're going to pursue this, submit an implementation in one or two types first before fully diving in, to make sure we're on the same page. For example
The UnionType/IntersectionType is probably going to be solved similarly as |
|
ok thanks. before bringing up the first looseCompare type, I will give other open PRs of mine some love, which are not blocked by external changes - so we can clean up the pull request queue first |
|
Hi, I'm cleaning up old and stale PRs. Please send a new PR if you're still interested, thanks. |
the tests added with his PR represent the comparison table from https://www.php.net/manual/en/types.comparisons.php inspired by #1602 (comment)
the more time I spent while working with loose comparisons, the more I realize how crazy those compare rules actually are.