DX: fix phpstan errors

This commit is contained in:
Julien Fastré 2023-02-04 01:53:40 +01:00
parent 584ac05b53
commit 264a6ef43e
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
12 changed files with 25 additions and 25 deletions

View File

@ -80,7 +80,6 @@ class Country
/** /**
* Get name. * Get name.
* *
* @return string
*/ */
public function getName() public function getName()
{ {

View File

@ -45,7 +45,7 @@ interface ChillEntityRenderInterface
/** /**
* Return true if the class support this object for the given options. * Return true if the class support this object for the given options.
* *
* @param type $entity * @param object $entity
*/ */
public function supports($entity, array $options): bool; public function supports($entity, array $options): bool;
} }

View File

@ -24,9 +24,9 @@ final class EvaluationRepository implements EvaluationRepositoryInterface
$this->repository = $entityManager->getRepository(Evaluation::class); $this->repository = $entityManager->getRepository(Evaluation::class);
} }
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?Evaluation public function find($id): ?Evaluation
{ {
return $this->repository->find($id, $lockMode, $lockVersion); return $this->repository->find($id);
} }
/** /**

View File

@ -16,7 +16,7 @@ use Doctrine\Persistence\ObjectRepository;
interface EvaluationRepositoryInterface extends ObjectRepository interface EvaluationRepositoryInterface extends ObjectRepository
{ {
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?Evaluation; public function find($id): ?Evaluation;
/** /**
* @return array<int, Evaluation> * @return array<int, Evaluation>

View File

@ -38,9 +38,9 @@ final class GoalRepository implements ObjectRepository
->getSingleScalarResult(); ->getSingleScalarResult();
} }
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?Goal public function find($id): ?Goal
{ {
return $this->repository->find($id, $lockMode, $lockVersion); return $this->repository->find($id);
} }
/** /**

View File

@ -48,9 +48,9 @@ final class ResultRepository implements ObjectRepository
->getSingleScalarResult(); ->getSingleScalarResult();
} }
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?Result public function find($id): ?Result
{ {
return $this->repository->find($id, $lockMode, $lockVersion); return $this->repository->find($id);
} }
/** /**

View File

@ -32,9 +32,9 @@ final class SocialActionRepository implements ObjectRepository
return $this->repository->createQueryBuilder($alias, $indexBy); return $this->repository->createQueryBuilder($alias, $indexBy);
} }
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?SocialAction public function find($id): ?SocialAction
{ {
return $this->repository->find($id, $lockMode, $lockVersion); return $this->repository->find($id);
} }
/** /**

View File

@ -27,9 +27,9 @@ final class SocialIssueRepository implements ObjectRepository
$this->repository = $entityManager->getRepository(SocialIssue::class); $this->repository = $entityManager->getRepository(SocialIssue::class);
} }
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?SocialIssue public function find($id): ?SocialIssue
{ {
return $this->repository->find($id, $lockMode, $lockVersion); return $this->repository->find($id);
} }
/** /**

View File

@ -33,9 +33,8 @@ final class ThirdPartyRepository implements ObjectRepository
/** /**
* count amongst parties associated to $centers, with $terms parameters. * 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 = $this->buildQuery($centers, $terms);
$qb->select('COUNT(tp)'); $qb->select('COUNT(tp)');

View File

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

View File

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

View File

@ -76,7 +76,7 @@ final class ChillDocumentManager implements DocumentManagerInterface
$document->setFilename($data['name']); $document->setFilename($data['name']);
$this->entityManager->persist($document); $this->entityManager->persist($document);
$this->entityManager->flush($document); $this->entityManager->flush();
// TODO : Ask proper mapping. // TODO : Ask proper mapping.
// Available: basename, name, extension, content, size // Available: basename, name, extension, content, size