Skip to content

Commit

Permalink
Workaround phpstan analysis error
Browse files Browse the repository at this point in the history
Doctrine hints ObjectRepository when DocumentRepository or EntityRepository is expected
  • Loading branch information
abienvenu committed Feb 1, 2018
1 parent 6975461 commit 48bf733
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Document/TokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace FOS\OAuthServerBundle\Document;

use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\DocumentRepository;
use FOS\OAuthServerBundle\Model\TokenInterface;
use FOS\OAuthServerBundle\Model\TokenManager as BaseTokenManager;

Expand Down Expand Up @@ -74,8 +75,10 @@ public function deleteToken(TokenInterface $token)
*/
public function deleteExpired()
{
$result = $this
->dm->getRepository($this->class)
// NOTE: bug in Doctrine, hinting DocumentRepository|ObjectRepository when only DocumentRepository is expected
/** @var DocumentRepository $repository */
$repository = $this->em->getRepository($this->class);
$result = $repository
->createQueryBuilder()
->remove()
->field('expiresAt')->lt(time())
Expand Down
6 changes: 5 additions & 1 deletion Entity/TokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace FOS\OAuthServerBundle\Entity;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use FOS\OAuthServerBundle\Model\TokenInterface;
use FOS\OAuthServerBundle\Model\TokenManager as BaseTokenManager;

Expand Down Expand Up @@ -74,7 +75,10 @@ public function deleteToken(TokenInterface $token)
*/
public function deleteExpired()
{
$qb = $this->em->getRepository($this->class)->createQueryBuilder('t');
// NOTE: bug in Doctrine, hinting EntityRepository|ObjectRepository when only EntityRepository is expected
/** @var EntityRepository $repository */
$repository = $this->em->getRepository($this->class);
$qb = $repository->createQueryBuilder('t');
$qb
->delete()
->where('t.expiresAt < ?1')
Expand Down

0 comments on commit 48bf733

Please sign in to comment.