Remove IdenticalEqual#2248
Conversation
maks-rafalko
left a comment
There was a problem hiding this comment.
I personally have never used these 2 mutators since we disabled them by default. So LGTM
| identical operator (`===`)). | ||
| TXT | ||
| , | ||
| MutatorCategory::SEMANTIC_REDUCTION, |
There was a problem hiding this comment.
I know the other one is disabled because it is a semantic addition which is non-sense to have, but what was it about this one?
There was a problem hiding this comment.
That's a good question. For some reason we had it disabled too. What do you think is the best path?
I guess we could enable it back.
There was a problem hiding this comment.
Ah I think it was simply redundant with the not equal ones in the end
agree, I also feel its a breaking change. on github.com I found a single reference (outside of infection/* repos) |
…:sanmai/infection into fix/remove-IdenticalEqual-EqualIdentical
but we are on 0.x, and it was disabled by default - not a big deal.
it's disabled and located in a const named |
The test was incorrectly removing EqualIdentical when it should only remove IdenticalEqual. This restores the test case that verifies parsing of 'AssignmentEqual,EqualIdentical' mutator input. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Just ran into this while doing upgrades: I used this mutator, as it is important to check for identity vs equality in some domains (example: ORMs, serializers). Should not have been dropped, tbh. |
This sort of mutation was disabled in this codebase, but it was valuable in ORMs/serializers. Ref: infection/infection#2248 Ref: infection/infection#2248 (comment) Ref: infection/infection@8e177c8 Fixes: ``` In InvalidSchema.php line 60: "/github/workspace/infection.json.dist" does not match the expected JSON sc hema: - [mutators] The property IdenticalEqual is not defined and the definition does not allow additional properties ```
|
@Ocramius you can now create a custom one where you add it back. I admit I don't understand what it would allow you to check though. Note that it is |
|
I would really love to understand the use-case 🙏 |
|
In an identity-map-backed repository, the test must verify that object-hash-level identity is used. For example, written naively: public function remove(object $toRemove) {
foreach ($this->identityMap as $key => $item) {
if ($toRemove === $item) {
unset($this->identityMap[$key]);
}
}
}This is a case where In such a test, the author would need to add 2 equal, non-same objects to the |
|
@Ocramius this should still be tested I think? To step back for a moment: what we want here is to prove that this piece of code is bug free. Now let's say a developer accidentally changes this strict equality for a loose equality and the tests are green: public function remove(object $toRemove) {
foreach ($this->identityMap as $key => $item) {
if ($toRemove == $item) {
unset($this->identityMap[$key]);
}
}
}Then you will have the equal to identity mutation that will kick in: public function remove(object $toRemove) {
foreach ($this->identityMap as $key => $item) {
- if ($toRemove == $item) {
+ if ($toRemove === $item) {
unset($this->identityMap[$key]);
}
}
}Then you have two scenarios:
|
|
@theofidry didn't you just say this is |
Fixes #2111
This feels like a breaking change to me, so I guess it could be a good idea to make a minor version release before merging this, if we agree to do that.