-
Notifications
You must be signed in to change notification settings - Fork 102
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
Repository methods considered pure #550
Comments
Based on this issue for phpstan it self: phpstan/phpstan#5727 Could the fix be as simple as adding |
Can confirm that copying over and enabling the stub in my project then adding the annotation fixes the problem for me. But it does introduce a new error 😢:
Happy to submit a PR if there no objections to the approach |
The result of these functions depends on the underlying database state which can change between multiple invocations. For example: Calling find() or findOneBy() and asserting the result to be null as a precondition of a test will generate false errors later in the test when the underlying record is added and the method is called again See phpstan#550
I have the same issue, leading me to believe that all methods on the repository should be considered impure. |
@ruudk which methods in particular are you seeing this issue with? |
PHPStan 1.10.59, phpstan-doctrine 1.3.62, phpstan-phpunit 1.3.16, bleeding edge + strict rules
I have a piece of code in my tests that roughly looks like this:
PHPStan emits an error:
If I remove the first
assertNull()
call, the error is gone. Apparently, PHPStan treats thefindOneBy()
call as pure which is a mistake from my POV.The text was updated successfully, but these errors were encountered: