Mark nullable EntityRepository methods as impure#648
Mark nullable EntityRepository methods as impure#648ondrejmirtes merged 1 commit intophpstan:2.0.xfrom
Conversation
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
|
At a glance, all of the failures seem to be due to missing Microsoft ODBC Driver which is completely unrelated to the changes in this PR |
cs278
left a comment
There was a problem hiding this comment.
Should findAll(), findBy(), matching(), createQueryBuilder() and count() also be marked as impure?
|
They don't return a union type so them being pure isn't a bug in the context of type checking Unless PHPStan has some functionality that relies on caching actual values returned (as opposed to just their type), I don't think it's worth being that pedantic about it. |
PHPStan's type system is more descriptive than PHP's: https://phpstan.org/r/ab040ba5-b25a-465e-8c65-3560fa1b20b3
|
|
This PR aims to address a specific bug that is actively breaking builds that, to the best of my knowledge, does not affect the methods you've highlighted. Unless @ondrejmirtes chimes in with desire for those methods to also be changed in this PR I am leaving it as is. Any larger efforts to address semantic correctness of the stubs in this projects can be taken care off in a separate PR |
|
Thank you. |
Resolves #550