-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Mark Connection::fetch methods as impure #7201
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
Conversation
|
@VincentLanglet maybe wait for phpstan/phpstan-src#4422 and utilize |
I hesitate about it... I'm not sure that all the method are impure in this class for instance
Also i cannot say
|
|
I think I'm OK with this annotation.
It's going to be weird if we have 1000 methods and people have to file 1000 bug reports. Maybe we should add the annotation of all methods of the public API that are impure? |
Sure, it's just that I'm not that familiar with all the doctrine code base/implementation and it was not obvious to me to know all the impure method (so I took the easy ones). But if someone is motivated to do so, it's better |
This is very questionable default. I don't think the DBAL (and by extension, any other libraries) should work around that. I don't think we should be making this change. Especially because there's no way for us to validate the correctness and consistency of these annotations. |
Because you're working at lot on/with doctrine, I understand you do not agree this default. But it's a useful one to
And it gives such behavior https://phpstan.org/r/3e4b3776-2dad-4511-a6d5-4f9eaeb3ea24 It still work well for multiple methods of doctrine. As a random example, if I call
If you consider the default behavior as wrong, you're basically asking to add Doing nothing seems the worst to me. PHPStan already have to maintain libs to improve the behavior and the PHPDoc of doctrine (https://github.com/phpstan/phpstan-doctrine), I can do the change there but I feel like it would be more benefit on the original repo. Such change will directly benefit you because you'll be able to stop ignoring error like this one in doctrine codebase (and you're not using phpstan-doctrine): |
|
Thank you @VincentLanglet, but I don't think this change will provide any value at this point. |
Summary
Related to phpstan/phpstan-phpunit#232 @greg0ire
and the doc https://phpstan.org/blog/remembering-and-forgetting-returned-values
By default phpstan consider method with a non void return type as pure. So it's better to declare them as explicitly impure.
This way phpstan doesn't remember the return value.
I think this is important for method which interact with an external database.
There is certainly tons in this lib (and other doctrine ones), I just wanted: