From 916a4f318f0b43891631fababab6ed5cb7633079 Mon Sep 17 00:00:00 2001 From: Dimitar Rekinov Date: Thu, 29 Aug 2024 15:53:40 +0300 Subject: [PATCH] fix syntax error when using doctrine/orm v3 where setParameters expects ArrayCollection but still maintain doctrine 2.3 compatibility --- Entity/AuthCodeManager.php | 6 ++++-- Entity/TokenManager.php | 6 ++++-- Tests/Entity/AuthCodeManagerTest.php | 8 ++++---- Tests/Entity/TokenManagerTest.php | 6 +++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Entity/AuthCodeManager.php b/Entity/AuthCodeManager.php index 52dbf82c..8ba69e23 100644 --- a/Entity/AuthCodeManager.php +++ b/Entity/AuthCodeManager.php @@ -17,6 +17,8 @@ use FOS\OAuthServerBundle\Model\AuthCodeInterface; use FOS\OAuthServerBundle\Model\AuthCodeManager as BaseAuthCodeManager; +use function time; + class AuthCodeManager extends BaseAuthCodeManager { /** @@ -80,8 +82,8 @@ public function deleteExpired(): int $qb = $repository->createQueryBuilder('a'); $qb ->delete() - ->where('a.expiresAt < ?1') - ->setParameters([1 => time()]) + ->where('a.expiresAt < :time') + ->setParameter('time', time()) ; return $qb->getQuery()->execute(); diff --git a/Entity/TokenManager.php b/Entity/TokenManager.php index 17950d27..d66c7d7a 100644 --- a/Entity/TokenManager.php +++ b/Entity/TokenManager.php @@ -18,6 +18,8 @@ use FOS\OAuthServerBundle\Model\TokenInterface; use FOS\OAuthServerBundle\Model\TokenManager as BaseTokenManager; +use function time; + class TokenManager extends BaseTokenManager { /** @@ -88,8 +90,8 @@ public function deleteExpired(): int $qb = $this->repository->createQueryBuilder('t'); $qb ->delete() - ->where('t.expiresAt < ?1') - ->setParameters([1 => time()]) + ->where('t.expiresAt < :time') + ->setParameter('time', time()) ; return $qb->getQuery()->execute(); diff --git a/Tests/Entity/AuthCodeManagerTest.php b/Tests/Entity/AuthCodeManagerTest.php index 4b4b22e3..866c4b37 100644 --- a/Tests/Entity/AuthCodeManagerTest.php +++ b/Tests/Entity/AuthCodeManagerTest.php @@ -170,14 +170,14 @@ public function testDeleteExpired(): void $queryBuilder ->expects($this->once()) ->method('where') - ->with('a.expiresAt < ?1') + ->with('a.expiresAt < :time') ->willReturn($queryBuilder) ; $queryBuilder ->expects($this->once()) - ->method('setParameters') - ->with([1 => time()]) + ->method('setParameter') + ->with('time', time()) ->willReturn($queryBuilder) ; @@ -202,4 +202,4 @@ public function testDeleteExpired(): void $this->assertSame($randomResult, $this->instance->deleteExpired()); } -} \ No newline at end of file +} diff --git a/Tests/Entity/TokenManagerTest.php b/Tests/Entity/TokenManagerTest.php index 230bac31..8cf673e6 100644 --- a/Tests/Entity/TokenManagerTest.php +++ b/Tests/Entity/TokenManagerTest.php @@ -177,14 +177,14 @@ public function testDeleteExpired(): void $queryBuilder ->expects($this->once()) ->method('where') - ->with('t.expiresAt < ?1') + ->with('t.expiresAt < :time') ->willReturn($queryBuilder) ; $queryBuilder ->expects($this->once()) - ->method('setParameters') - ->with([1 => time()]) + ->method('setParameter') + ->with('time', time()) ->willReturn($queryBuilder) ;