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
InstanceOf_ mutator #1232
InstanceOf_ mutator #1232
Conversation
A couple of questions:
|
By ensuring this check is actually required by using appropriately typed arguments, or by removing the check altogether. I think we have to come up with a style of explanation before writing any of them since stating the obvious might not be as useful. I we'd go with the negation approach you suggest, we'll have this:
Not to say it's bad, but not as nearly as lucrative as in the current implementation. Consider this escaping mutation in --- Original
+++ New
@@ @@
if ($node instanceof Node\Stmt\ClassMethod) {
return true;
}
- if ($node instanceof Node\Expr\Closure) {
+ if (false) {
return true;
}
return false; Are we really testing this method receives And why do test notice if we negate this comparison?.. |
yield new Node\Expr\ConstFetch(new Node\Name('false')); | ||
} | ||
|
||
public function canMutate(Node $node): bool |
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.
I think canMutate()
should be placed before mutate()
, but since it's hardly something we can enforce don't mind me if you don't agree with that
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.
Well, I took another mutator for a template, and that's how it was there.
@@ -43,7 +43,7 @@ public function leaveNode(Node $node) | |||
|
|||
// It is important to not rely on the keys here. It might otherwise result in some elements | |||
// being overridden, see https://3v4l.org/JLN73 | |||
foreach($this->mutator->mutate($node) as $mutatedNode) { | |||
foreach ($this->mutator->mutate($node) as $mutatedNode) { |
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.
I thought the CS fixer would pick that up...
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.
It doesn't fix fixtures for some reason I didn't yet have time to investigate.
Quite simple one. Replaces:
With either
true
orfalse
.true
we assume the value always the of same type, and the check is redundant.false
we assume the testing isn't thorough.Report for this mutator: