Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Invalid behavior of ReturnValue\FunctionCall mutator with return type hint? #191

Open
lcobucci opened this issue Oct 23, 2016 · 3 comments
Milestone

Comments

@lcobucci
Copy link

The Humbug\Mutator\ReturnValue\FunctionCall is replacing the return statement with a null value even when a non-nullable return type hint is set, generating a TypeError.

I believe that this mutator should be just executed when return type is not set or is nullable (PHP 7.1+), however I'm not sure how to implement that (or if you think that it should be done).

@padraic padraic added the bug label Apr 13, 2017
@padraic
Copy link
Collaborator

padraic commented Apr 13, 2017

I'm not really sure if that's a bug though. Generating an error after a mutation is generally a Good Thing. Is there a scenario where it's not?

@lcobucci
Copy link
Author

It might not be a bug indeed.
I agree that generating an error after a mutation is a good thing but should it be presented together with the "bad things"?

(btw good to see you back here 😉 )

@padraic padraic added this to the 2.0.0 milestone May 5, 2017
@padraic padraic removed the bug label May 5, 2017
@padraic
Copy link
Collaborator

padraic commented May 5, 2017

@lcobucci With a bit more time to recover from being on vacation (my brain may have wanted to stay there ;)), the proper response to this issue should have been that while this is not a bug, it is an omitted feature. Operating under PHP 7, we should be mutating the return value based on the return type hint, so it’s a definite enhancement for Humbug 2.0. This would only apply where we know the return type, or can infer it, otherwise NULL would be the default. The mutation return value would follow the rules for explicit values of the same type, already implemented (e.g. flipping Booleans).

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

No branches or pull requests

2 participants