Skip to content

Commit a1d55bb

Browse files
committed
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 phpstan#550
1 parent a61a04a commit a1d55bb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

stubs/EntityRepository.stub

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class EntityRepository implements ObjectRepository
2020
* @phpstan-param int|null $lockMode
2121
* @phpstan-param int|null $lockVersion
2222
* @phpstan-return TEntityClass|null
23+
* @phpstan-impure
2324
*/
2425
public function find($id, $lockMode = null, $lockVersion = null);
2526

@@ -41,6 +42,7 @@ class EntityRepository implements ObjectRepository
4142
* @phpstan-param array<string, mixed> $criteria The criteria.
4243
* @phpstan-param array<string, string>|null $orderBy
4344
* @phpstan-return TEntityClass|null
45+
* @phpstan-impure
4446
*/
4547
public function findOneBy(array $criteria, ?array $orderBy = null);
4648

0 commit comments

Comments
 (0)