From 264a6ef43e104f05ec65fa708e3e30d3cb05e47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 4 Feb 2023 01:53:40 +0100 Subject: [PATCH] DX: fix phpstan errors --- src/Bundle/ChillMainBundle/Entity/Country.php | 1 - .../Entity/ChillEntityRenderInterface.php | 2 +- .../Repository/SocialWork/EvaluationRepository.php | 4 ++-- .../SocialWork/EvaluationRepositoryInterface.php | 2 +- .../Repository/SocialWork/GoalRepository.php | 4 ++-- .../Repository/SocialWork/ResultRepository.php | 4 ++-- .../SocialWork/SocialActionRepository.php | 4 ++-- .../Repository/SocialWork/SocialIssueRepository.php | 4 ++-- .../Repository/ThirdPartyRepository.php | 3 +-- .../Search/ThirdPartySearch.php | 13 +++++++++---- .../config/services/search.yaml | 7 ++----- .../src/Service/Wopi/ChillDocumentManager.php | 2 +- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/Country.php b/src/Bundle/ChillMainBundle/Entity/Country.php index 23abf437a..313d62b3d 100644 --- a/src/Bundle/ChillMainBundle/Entity/Country.php +++ b/src/Bundle/ChillMainBundle/Entity/Country.php @@ -80,7 +80,6 @@ class Country /** * Get name. * - * @return string */ public function getName() { diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/ChillEntityRenderInterface.php b/src/Bundle/ChillMainBundle/Templating/Entity/ChillEntityRenderInterface.php index a5a433b5d..ca52b22ed 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/ChillEntityRenderInterface.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/ChillEntityRenderInterface.php @@ -45,7 +45,7 @@ interface ChillEntityRenderInterface /** * 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; } diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php index 925d4598b..e8de5a278 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php @@ -24,9 +24,9 @@ final class EvaluationRepository implements EvaluationRepositoryInterface $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); } /** diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepositoryInterface.php index 9ca390ff9..aa1de34eb 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepositoryInterface.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepositoryInterface.php @@ -16,7 +16,7 @@ use Doctrine\Persistence\ObjectRepository; interface EvaluationRepositoryInterface extends ObjectRepository { - public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?Evaluation; + public function find($id): ?Evaluation; /** * @return array diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php index fd24b7b9d..eaf8e9ee8 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php @@ -38,9 +38,9 @@ final class GoalRepository implements ObjectRepository ->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); } /** diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php index e751f88cb..76fbb592c 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php @@ -48,9 +48,9 @@ final class ResultRepository implements ObjectRepository ->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); } /** diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php index 370704aed..62ca3d853 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php @@ -32,9 +32,9 @@ final class SocialActionRepository implements ObjectRepository 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); } /** diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php index 8dd8f6a62..63dfcc510 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php @@ -27,9 +27,9 @@ final class SocialIssueRepository implements ObjectRepository $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); } /** diff --git a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php index 6739621ed..134957c0f 100644 --- a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php +++ b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php @@ -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)'); diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php index 22ae23014..5a46edad8 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php @@ -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); } } diff --git a/src/Bundle/ChillThirdPartyBundle/config/services/search.yaml b/src/Bundle/ChillThirdPartyBundle/config/services/search.yaml index 62b5dd205..08f8f5ad8 100644 --- a/src/Bundle/ChillThirdPartyBundle/config/services/search.yaml +++ b/src/Bundle/ChillThirdPartyBundle/config/services/search.yaml @@ -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' } diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php index 19b4dc9b4..c5efc4bfd 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php @@ -76,7 +76,7 @@ final class ChillDocumentManager implements DocumentManagerInterface $document->setFilename($data['name']); $this->entityManager->persist($document); - $this->entityManager->flush($document); + $this->entityManager->flush(); // TODO : Ask proper mapping. // Available: basename, name, extension, content, size