From a1d55bb0eb496fc317c691139ea1f9a3cff07dca Mon Sep 17 00:00:00 2001 From: Edvin Malinovskis <507466+nCrazed@users.noreply.github.com> Date: Thu, 13 Mar 2025 20:58:24 +0000 Subject: [PATCH] Mark nullable EntityRepository methods as impure 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 #550 --- stubs/EntityRepository.stub | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stubs/EntityRepository.stub b/stubs/EntityRepository.stub index 784b14c8..bdc11eca 100644 --- a/stubs/EntityRepository.stub +++ b/stubs/EntityRepository.stub @@ -20,6 +20,7 @@ class EntityRepository implements ObjectRepository * @phpstan-param int|null $lockMode * @phpstan-param int|null $lockVersion * @phpstan-return TEntityClass|null + * @phpstan-impure */ public function find($id, $lockMode = null, $lockVersion = null); @@ -41,6 +42,7 @@ class EntityRepository implements ObjectRepository * @phpstan-param array $criteria The criteria. * @phpstan-param array|null $orderBy * @phpstan-return TEntityClass|null + * @phpstan-impure */ public function findOneBy(array $criteria, ?array $orderBy = null);