DX: fix phpstan errors

This commit is contained in:
2023-02-04 01:53:40 +01:00
parent 584ac05b53
commit 264a6ef43e
12 changed files with 25 additions and 25 deletions

View File

@@ -33,9 +33,8 @@ final class ThirdPartyRepository implements ObjectRepository
/**
* count amongst parties associated to $centers, with $terms parameters.
*
* @param type $terms
*/
public function countByMemberOfCenters(array $centers, $terms = []): int
public function countByMemberOfCenters(array $centers, array $terms = []): int
{
$qb = $this->buildQuery($centers, $terms);
$qb->select('COUNT(tp)');

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Search\SearchInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@@ -47,16 +48,20 @@ class ThirdPartySearch implements SearchInterface
*/
protected $tokenStorage;
private ThirdPartyRepository $thirdPartyRepository;
public function __construct(
EntityManagerInterface $em,
TokenStorageInterface $tokenStorage,
AuthorizationHelper $authorizationHelper,
PaginatorFactory $paginatorFactory
PaginatorFactory $paginatorFactory,
ThirdPartyRepository $thirdPartyRepository
) {
$this->em = $em;
$this->tokenStorage = $tokenStorage;
$this->authorizationHelper = $authorizationHelper;
$this->paginatorFactory = $paginatorFactory;
$this->thirdPartyRepository = $thirdPartyRepository;
}
public function getOrder(): int
@@ -74,7 +79,7 @@ class ThirdPartySearch implements SearchInterface
$centers = $this->authorizationHelper
->getReachableCenters(
$this->tokenStorage->getToken()->getUser(),
new Role(ThirdPartyVoter::SHOW)
ThirdPartyVoter::SHOW
);
$total = $this->count($centers, $terms);
$paginator = $this->paginatorFactory->create($total);
@@ -84,7 +89,7 @@ class ThirdPartySearch implements SearchInterface
if ('json' === $format) {
return [
'results' => $this->em->getRepository(ThirdParty::class)
'results' => $this->thirdPartyRepository
->findByMemberOfCenters(
$centers,
$start,
@@ -104,7 +109,7 @@ class ThirdPartySearch implements SearchInterface
protected function count($centers, $terms): int
{
return $this->em->getRepository(ThirdParty::class)
return $this->thirdPartyRepository
->countByMemberOfCenters($centers, $terms);
}
}

View File

@@ -1,10 +1,7 @@
services:
Chill\ThirdPartyBundle\Search\ThirdPartySearch:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
$paginatorFactory: '@Chill\MainBundle\Pagination\PaginatorFactory'
autowire: true
autoconfigure: true
tags:
- { name: 'chill.search', alias: '3party' }