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
Multiplication mutator should not mutate when return value is integer #1515
Multiplication mutator should not mutate when return value is integer #1515
Conversation
composer.json
Outdated
@@ -46,7 +46,7 @@ | |||
"ext-dom": "*", | |||
"ext-json": "*", | |||
"ext-libxml": "*", | |||
"composer/xdebug-handler": "^1.3.3", | |||
"composer/xdebug-handler": "^2.0", |
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.
seems like this commit should not be in this PR (already in master)
@@ -94,7 +96,19 @@ public function canMutate(Node $node): bool | |||
return false; | |||
} | |||
|
|||
return true; | |||
$functionScope = $node->getAttribute(ReflectionVisitor::FUNCTION_SCOPE_KEY); |
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 believe we should also check that the current node is a return
expression as it's done e.g. here: https://github.com/infection/infection/blob/master/src/Mutator/ReturnValue/This.php#L84
Otherwise, the following code will not be mutated, but it should:
public function mul(int $a, int $b): int
{
$c = $a * $b;
return 1;
}
btw, could you please add such case to tests so that we are sure it is mutated?
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.
done
233ee09
to
c9bb822
Compare
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.
👌
Thank you @sidz |
This PR fixes #1514 request.