-
Notifications
You must be signed in to change notification settings - Fork 30
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
\JanGregor\Prophecy\Reflection\ObjectProphecyMethodReflection::hasSideEffects() should be 'yes' for PHP >7.0 #112
Comments
To be honest, I have no idea! Perhaps @ondrejmirtes can help us out here? |
Some internal methods from PHP are marked as having/not having side effects (https://github.com/phpstan/phpstan-src/blob/master/src/Reflection/SignatureMap/functionMetadata.php), so you can draw some inspiration from that. How it currently manifests:
If you don't want either of these things, return |
Thank you for the explanation, @ondrejmirtes! |
@ondrejmirtes |
@func0der What do you mean by "a problem"? When you're calling something that's not supposed to have a side effect (like a getter or a method on an immutable object), so the user is supposed to read the return value of the method, but they don't do it, then you get the error "on a separate line has no effect." because you cen simply remove the line. |
Ah, sorry. I overlooked the immutable object part. My bad. :) @localheinz Pretty sure it should be Thanks for the work. |
No problem! Let me know if you run into any issues - I will be here to quickly turn things around when necessary! |
\JanGregor\Prophecy\Reflection\ObjectProphecyMethodReflection::hasSideEffects()
returnsno
. As I found not documentation as for what\PHPStan\Reflection\MethodReflection::hasSideEffects()
should really mark, I can only guess, that this marks methods that simply return stuff or work on copies of internal values.As for
\Prophecy\Prophecy\ObjectProphecy::__call()
has side effects. I returns a new\Prophecy\Prophecy\MethodProphecy
, which's__constructor()
method changes theObjectProphecy
it was was called on as of PHP >7.0.I tries to guess the return type of the method that is prophecied registers itself on the
ObjectProphepcy
in the\Prophecy\Prophecy\MethodProphecy::will()
call.I might be wrong here, because I really can not find ANY definition of
sideEffect
regarding a method, but as this not only creates a new object, but also changes the object it was created AND also changes the outcome of the test it is constructed in (changes return type toX
instead ofnull
for unregistered calls), it should not considered to be side effect free.The text was updated successfully, but these errors were encountered: