From 74ed34ba9788f18305e3e7c3dac899b3c309021a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Jul 2023 22:48:26 +0200 Subject: [PATCH] apply rules rector --- .../Controller/ActivityController.php | 8 +- .../ACPAggregators/DateAggregator.php | 14 +- .../Menu/PersonMenuBuilder.php | 18 +- .../Service/DocGenerator/ActivityContext.php | 49 +---- ...anyingPeriodActivityGenericDocRenderer.php | 8 +- ...anyingPeriodCalendarGenericDocRenderer.php | 5 +- .../DocumentAccompanyingCourseController.php | 15 +- .../Controller/DocumentPersonController.php | 15 +- ...ericDocForAccompanyingPeriodController.php | 2 - .../GenericDoc/FetchQueryToSqlBuilder.php | 1 - .../ChillEventBundle/Search/EventSearch.php | 37 +--- .../Controller/ExportController.php | 88 ++------ .../Controller/UserExportController.php | 2 - .../ChillMainBundle/Cron/CronManager.php | 27 +-- .../Entity/CronJobExecution.php | 15 +- src/Bundle/ChillMainBundle/Entity/User.php | 5 +- .../ChillMainBundle/Export/ExportManager.php | 42 +--- .../Form/Type/Export/PickCenterType.php | 15 +- .../Repository/NotificationRepository.php | 7 +- .../PasswordRecover/PasswordRecoverEvent.php | 3 +- .../FilterOrderGetActiveFilterHelper.php | 3 +- .../Listing/FilterOrderHelperBuilder.php | 12 +- .../Listing/FilterOrderHelperFactory.php | 12 +- .../Export/Export/ListHouseholdInPeriod.php | 53 ++--- .../StepFilterBetweenDates.php | 12 +- .../Helper/ListAccompanyingPeriodHelper.php | 197 ++++++++---------- .../Menu/HouseholdMenuBuilder.php | 5 +- ...kEvaluationDocumentNotificationHandler.php | 5 +- ...ompanyingPeriodWorkNotificationHandler.php | 5 +- .../AccompanyingPeriodACLAwareRepository.php | 23 +- .../Authorization/AccompanyingPeriodVoter.php | 5 +- .../AccompanyingPeriodContext.php | 50 +---- ...ccompanyingPeriodWorkEvaluationContext.php | 32 +-- .../Service/DocGenerator/PersonContext.php | 65 ++---- ...companyingPeriodACLAwareRepositoryTest.php | 2 - .../RelationshipNoDuplicateValidator.php | 6 +- .../DataFixtures/ORM/LoadReports.php | 2 +- .../Controller/SingleTaskController.php | 78 ++----- .../ChillTaskBundle/Entity/RecurringTask.php | 2 + .../Form/ThirdPartyType.php | 2 +- 40 files changed, 250 insertions(+), 697 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 1e911ff08..d5c859fee 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -77,10 +77,8 @@ final class ActivityController extends AbstractController /** * Deletes a Activity entity. - * - * @param mixed $id */ - public function deleteAction(Request $request, $id) + public function deleteAction(Request $request, mixed $id) { $view = null; @@ -679,8 +677,8 @@ final class ActivityController extends AbstractController throw $this->createNotFoundException('Accompanying Period not found'); } - // TODO Add permission - // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + // TODO Add permission + // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); } else { throw $this->createNotFoundException('Person or Accompanying Period not found'); } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php index 4ede5b4c4..59803bb61 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php @@ -94,17 +94,9 @@ class DateAggregator implements AggregatorInterface return ''; } - switch ($data['frequency']) { - case 'month': - case 'week': - //return $this->translator->trans('for week') .' '. $value ; - - case 'year': - //return $this->translator->trans('in year') .' '. $value ; - - default: - return $value; - } + return match ($data['frequency']) { + default => $value, + }; }; } diff --git a/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php index a3cebec38..d058d11d8 100644 --- a/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php @@ -23,22 +23,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ final class PersonMenuBuilder implements LocalMenuBuilderInterface { - /** - * @var AuthorizationCheckerInterface - */ - private $authorizationChecker; - - /** - * @var TranslatorInterface - */ - private $translator; - - public function __construct( - AuthorizationCheckerInterface $authorizationChecker, - TranslatorInterface $translator - ) { - $this->translator = $translator; - $this->authorizationChecker = $authorizationChecker; + public function __construct(private AuthorizationCheckerInterface $authorizationChecker, private TranslatorInterface $translator) + { } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php index a20ca365b..30dad654a 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php @@ -42,48 +42,17 @@ class ActivityContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - private BaseContextData $baseContextData; - - private DocumentCategoryRepository $documentCategoryRepository; - - private EntityManagerInterface $em; - - private NormalizerInterface $normalizer; - - private PersonRenderInterface $personRender; - - private PersonRepository $personRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - - private ThirdPartyRender $thirdPartyRender; - - private ThirdPartyRepository $thirdPartyRepository; - public function __construct( - DocumentCategoryRepository $documentCategoryRepository, - NormalizerInterface $normalizer, - TranslatableStringHelperInterface $translatableStringHelper, - EntityManagerInterface $em, - PersonRenderInterface $personRender, - PersonRepository $personRepository, - TranslatorInterface $translator, - BaseContextData $baseContextData, - ThirdPartyRender $thirdPartyRender, - ThirdPartyRepository $thirdPartyRepository + private NormalizerInterface $normalizer, + private TranslatableStringHelperInterface $translatableStringHelper, + private EntityManagerInterface $em, + private PersonRenderInterface $personRender, + private PersonRepository $personRepository, + private TranslatorInterface $translator, + private BaseContextData $baseContextData, + private ThirdPartyRender $thirdPartyRender, + private ThirdPartyRepository $thirdPartyRepository ) { - $this->documentCategoryRepository = $documentCategoryRepository; - $this->normalizer = $normalizer; - $this->translatableStringHelper = $translatableStringHelper; - $this->em = $em; - $this->personRender = $personRender; - $this->personRepository = $personRepository; - $this->translator = $translator; - $this->baseContextData = $baseContextData; - $this->thirdPartyRender = $thirdPartyRender; - $this->thirdPartyRepository = $thirdPartyRepository; } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php index c465dbca1..586a977b5 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php @@ -21,14 +21,8 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod; final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRendererInterface { - private StoredObjectRepository $objectRepository; - - private ActivityRepository $activityRepository; - - public function __construct(StoredObjectRepository $storedObjectRepository, ActivityRepository $activityRepository) + public function __construct(private StoredObjectRepository $objectRepository, private ActivityRepository $activityRepository) { - $this->objectRepository = $storedObjectRepository; - $this->activityRepository = $activityRepository; } public function supports(GenericDocDTO $genericDocDTO, $options = []): bool diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php index b15c091c6..64b5b75db 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php @@ -19,11 +19,8 @@ use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; final class AccompanyingPeriodCalendarGenericDocRenderer implements GenericDocRendererInterface { - private CalendarDocRepository $repository; - - public function __construct(CalendarDocRepository $calendarDocRepository) + public function __construct(private CalendarDocRepository $repository) { - $this->repository = $calendarDocRepository; } public function supports(GenericDocDTO $genericDocDTO, $options = []): bool diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php index 384eeb510..883c2a9a0 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -33,23 +33,14 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class DocumentAccompanyingCourseController extends AbstractController { - protected AuthorizationHelper $authorizationHelper; - - protected EventDispatcherInterface $eventDispatcher; - - protected TranslatorInterface $translator; - /** * DocumentAccompanyingCourseController constructor. */ public function __construct( - TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher, - AuthorizationHelper $authorizationHelper, + protected TranslatorInterface $translator, + protected EventDispatcherInterface $eventDispatcher, + protected AuthorizationHelper $authorizationHelper ) { - $this->translator = $translator; - $this->eventDispatcher = $eventDispatcher; - $this->authorizationHelper = $authorizationHelper; } /** diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php index 20e8e9b03..512a4daf0 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php @@ -39,23 +39,14 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class DocumentPersonController extends AbstractController { - protected AuthorizationHelper $authorizationHelper; - - protected EventDispatcherInterface $eventDispatcher; - - protected TranslatorInterface $translator; - /** * DocumentPersonController constructor. */ public function __construct( - TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher, - AuthorizationHelper $authorizationHelper, + protected TranslatorInterface $translator, + protected EventDispatcherInterface $eventDispatcher, + protected AuthorizationHelper $authorizationHelper ) { - $this->translator = $translator; - $this->eventDispatcher = $eventDispatcher; - $this->authorizationHelper = $authorizationHelper; } /** diff --git a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php index 70c41db50..522cc57c5 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php @@ -35,8 +35,6 @@ final readonly class GenericDocForAccompanyingPeriodController } /** - * @param AccompanyingPeriod $accompanyingPeriod - * @return Response * @throws \Doctrine\DBAL\Exception * * @Route("/{_locale}/doc-store/generic-doc/by-period/{id}/index", name="chill_docstore_generic-doc_by-period_index") diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php index 2c0c59cff..dad645ff9 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php @@ -25,7 +25,6 @@ final readonly class FetchQueryToSqlBuilder SQL; /** - * @param FetchQueryInterface $query * @return array{sql: string, params: list, types: list} */ public function toSql(FetchQueryInterface $query): array diff --git a/src/Bundle/ChillEventBundle/Search/EventSearch.php b/src/Bundle/ChillEventBundle/Search/EventSearch.php index 6bb3d435d..59d241878 100644 --- a/src/Bundle/ChillEventBundle/Search/EventSearch.php +++ b/src/Bundle/ChillEventBundle/Search/EventSearch.php @@ -41,40 +41,13 @@ class EventSearch extends AbstractSearch { public const NAME = 'event_regular'; - private $security; - - /** - * @var EventRepository - */ - private $er; - - /** - * @var AuthorizationHelper - */ - private $authorizationHelper; - - /** - * @var PaginatorFactory - */ - private $paginationFactory; - - /** - * @var TemplatingEngine - */ - private $templating; - public function __construct( - Security $security, - EventRepository $eventRepository, - AuthorizationHelper $authorizationHelper, - TemplatingEngine $templating, - PaginatorFactory $paginatorFactory + private Security $security, + private EventRepository $er, + private AuthorizationHelper $authorizationHelper, + private TemplatingEngine $templating, + private PaginatorFactory $paginationFactory ) { - $this->security = $security; - $this->er = $eventRepository; - $this->authorizationHelper = $authorizationHelper; - $this->templating = $templating; - $this->paginationFactory = $paginatorFactory; } public function getOrder() diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index e8ee9b97b..762c2f7ae 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -52,57 +52,18 @@ use function unserialize; */ class ExportController extends AbstractController { - private EntityManagerInterface $entityManager; - - /** - * @var ExportManager - */ - private $exportManager; - - /** - * @var FormFactoryInterface - */ - private $formFactory; - - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var ChillRedis - */ - private $redis; - - /** - * @var SessionInterface - */ - private $session; - - /** - * @var TranslatorInterface - */ - private $translator; - public function __construct( - ChillRedis $chillRedis, - ExportManager $exportManager, - FormFactoryInterface $formFactory, - LoggerInterface $logger, - SessionInterface $session, - TranslatorInterface $translator, - EntityManagerInterface $entityManager, + private ChillRedis $redis, + private ExportManager $exportManager, + private FormFactoryInterface $formFactory, + private LoggerInterface $logger, + private SessionInterface $session, + private TranslatorInterface $translator, + private EntityManagerInterface $entityManager, private readonly ExportFormHelper $exportFormHelper, private readonly SavedExportRepositoryInterface $savedExportRepository, - private readonly Security $security, + private readonly Security $security ) { - $this->entityManager = $entityManager; - $this->redis = $chillRedis; - $this->exportManager = $exportManager; - $this->formFactory = $formFactory; - $this->logger = $logger; - $this->session = $session; - $this->translator = $translator; } public function downloadResultAction(Request $request, $alias) @@ -228,22 +189,13 @@ class ExportController extends AbstractController $step = $request->query->getAlpha('step', 'centers'); - switch ($step) { - case 'centers': - return $this->selectCentersStep($request, $export, $alias, $savedExport); - - case 'export': - return $this->exportFormStep($request, $export, $alias, $savedExport); - - case 'formatter': - return $this->formatterFormStep($request, $export, $alias, $savedExport); - - case 'generate': - return $this->forwardToGenerate($request, $export, $alias, $savedExport); - - default: - throw $this->createNotFoundException("The given step '{$step}' is invalid"); - } + return match ($step) { + 'centers' => $this->selectCentersStep($request, $export, $alias, $savedExport), + 'export' => $this->exportFormStep($request, $export, $alias, $savedExport), + 'formatter' => $this->formatterFormStep($request, $export, $alias, $savedExport), + 'generate' => $this->forwardToGenerate($request, $export, $alias, $savedExport), + default => throw $this->createNotFoundException("The given step '{$step}' is invalid"), + }; } /** @@ -317,7 +269,7 @@ class ExportController extends AbstractController { /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ $exportManager = $this->exportManager; - $isGenerate = strpos($step, 'generate_') === 0; + $isGenerate = str_starts_with($step, 'generate_'); $options = match ($step) { 'export', 'generate_export' => [ @@ -493,7 +445,7 @@ class ExportController extends AbstractController * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - private function forwardToGenerate(Request $request, $export, $alias, ?SavedExport $savedExport) + private function forwardToGenerate(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias, ?SavedExport $savedExport) { $dataCenters = $this->session->get('centers_step_raw', null); $dataFormatter = $this->session->get('formatter_step_raw', null); @@ -560,12 +512,10 @@ class ExportController extends AbstractController } /** - * @param \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export * @param string $alias - * * @return Response */ - private function selectCentersStep(Request $request, $export, $alias, ?SavedExport $savedExport = null) + private function selectCentersStep(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias, ?SavedExport $savedExport = null) { /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ $exportManager = $this->exportManager; @@ -647,7 +597,7 @@ class ExportController extends AbstractController * * @return string the next/current step */ - private function getNextStep($step, $export, $reverse = false) + private function getNextStep($step, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $reverse = false) { switch ($step) { case 'centers': diff --git a/src/Bundle/ChillMainBundle/Controller/UserExportController.php b/src/Bundle/ChillMainBundle/Controller/UserExportController.php index 530ac19b7..9c2898447 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserExportController.php @@ -92,11 +92,9 @@ final readonly class UserExportController } /** - * @return StreamedResponse * @throws \League\Csv\CannotInsertRecord * @throws \League\Csv\Exception * @throws \League\Csv\UnavailableStream - * * @Route("/{_locale}/admin/main/users/export/permissions.{_format}", requirements={"_format": "csv"}, name="chill_main_users_export_permissions") */ public function userPermissionsList(string $_format = 'csv'): StreamedResponse diff --git a/src/Bundle/ChillMainBundle/Cron/CronManager.php b/src/Bundle/ChillMainBundle/Cron/CronManager.php index a3e82a170..3a4d548da 100644 --- a/src/Bundle/ChillMainBundle/Cron/CronManager.php +++ b/src/Bundle/ChillMainBundle/Cron/CronManager.php @@ -39,7 +39,7 @@ use function array_key_exists; * If a tasks is "forced", there is no test about eligibility of the task (the `canRun` method is not called), * and the last task execution is not recorded. */ -class CronManager implements CronManagerInterface +final readonly class CronManager implements CronManagerInterface { private const LOG_PREFIX = '[cron manager] '; @@ -49,30 +49,15 @@ class CronManager implements CronManagerInterface private const UPDATE_LAST_EXECUTION_DATA = 'UPDATE ' . CronJobExecution::class . ' cr SET cr.lastExecutionData = :data WHERE cr.key = :key'; - private CronJobExecutionRepositoryInterface $cronJobExecutionRepository; - - private EntityManagerInterface $entityManager; - - /** - * @var iterable - */ - private iterable $jobs; - - private LoggerInterface $logger; - /** * @param CronJobInterface[] $jobs */ public function __construct( - CronJobExecutionRepositoryInterface $cronJobExecutionRepository, - EntityManagerInterface $entityManager, - iterable $jobs, - LoggerInterface $logger + private CronJobExecutionRepositoryInterface $cronJobExecutionRepository, + private EntityManagerInterface $entityManager, + private iterable $jobs, + private LoggerInterface $logger ) { - $this->cronJobExecutionRepository = $cronJobExecutionRepository; - $this->entityManager = $entityManager; - $this->jobs = $jobs; - $this->logger = $logger; } public function run(?string $forceJob = null): void @@ -134,7 +119,7 @@ class CronManager implements CronManagerInterface $this->logger->info(sprintf('%sSuccessfully run job', self::LOG_PREFIX), ['job' => $job->getKey()]); return; - } catch (Exception $e) { + } catch (Exception) { $this->logger->error(sprintf('%sRunning job failed', self::LOG_PREFIX), ['job' => $job->getKey()]); $this->entityManager ->createQuery(self::UPDATE_AFTER_EXEC) diff --git a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php index 2883055fc..4a242b3fe 100644 --- a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php +++ b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php @@ -24,12 +24,6 @@ class CronJobExecution public const SUCCESS = 1; - /** - * @ORM\Column(type="text", nullable=false) - * @ORM\Id - */ - private string $key; - /** * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) */ @@ -50,9 +44,12 @@ class CronJobExecution */ private array $lastExecutionData = []; - public function __construct(string $key) - { - $this->key = $key; + public function __construct(/** + * @ORM\Column(type="text", nullable=false) + * @ORM\Id + */ + private string $key + ) { $this->lastStart = new DateTimeImmutable('now'); } diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 1240ecd22..75d0ac94a 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -272,10 +272,7 @@ class User implements UserInterface, \Stringable return ['ROLE_USER']; } - /** - * @return string|null - */ - public function getSalt() + public function getSalt(): ?string { return $this->salt; } diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index 3f9c839a5..8497a83dd 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -43,10 +43,6 @@ class ExportManager */ private array $aggregators = []; - private AuthorizationCheckerInterface $authorizationChecker; - - private AuthorizationHelperInterface $authorizationHelper; - /** * Collected Exports, injected by DI. * @@ -68,17 +64,15 @@ class ExportManager */ private array $formatters = []; - private LoggerInterface $logger; - /** * @var \Symfony\Component\Security\Core\User\UserInterface */ private $user; public function __construct( - LoggerInterface $logger, - AuthorizationCheckerInterface $authorizationChecker, - AuthorizationHelperInterface $authorizationHelper, + private LoggerInterface $logger, + private AuthorizationCheckerInterface $authorizationChecker, + private AuthorizationHelperInterface $authorizationHelper, TokenStorageInterface $tokenStorage, iterable $exports, iterable $aggregators, @@ -86,9 +80,6 @@ class ExportManager //iterable $formatters, //iterable $exportElementProvider ) { - $this->logger = $logger; - $this->authorizationChecker = $authorizationChecker; - $this->authorizationHelper = $authorizationHelper; $this->user = $tokenStorage->getToken()->getUser(); $this->exports = iterator_to_array($exports); $this->aggregators = iterator_to_array($aggregators); @@ -166,7 +157,7 @@ class ExportManager } elseif ($element instanceof FormatterInterface) { $this->addFormatter($element, $alias); } else { - throw new LogicException('This element ' . get_class($element) . ' ' + throw new LogicException('This element ' . $element::class . ' ' . 'is not an instance of export element'); } } @@ -285,7 +276,6 @@ class ExportManager } /** - * @param array $aliases * @return iterable */ public function getAggregators(array $aliases): iterable @@ -352,7 +342,6 @@ class ExportManager /** * Get all exports grouped in an array. * - * @param bool $whereUserIsGranted * * @return array> where keys are the groups's name and value is an array of exports */ @@ -372,8 +361,6 @@ class ExportManager } /** - * @param string $alias - * * @throws RuntimeException if the filter is not known */ public function getFilter(string $alias): FilterInterface @@ -467,11 +454,9 @@ class ExportManager * Return true if the current user has access to the ExportElement for every * center, false if the user hasn't access to element for at least one center. * - * @param \Chill\MainBundle\Export\ExportElementInterface $element - * @param DirectExportInterface|ExportInterface $export * */ - public function isGrantedForElement(ExportElementInterface $element, ?ExportElementInterface $export = null, ?array $centers = null): bool + public function isGrantedForElement(ExportElementInterface $element, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export = null, ?array $centers = null): bool { if ($element instanceof ExportInterface || $element instanceof DirectExportInterface) { $role = $element->requiredRole(); @@ -504,7 +489,7 @@ class ExportManager //debugging $this->logger->debug('user has no access to element', [ 'method' => __METHOD__, - 'type' => get_class($element), + 'type' => $element::class, 'center' => $center->getName(), 'role' => $role, ]); @@ -574,7 +559,7 @@ class ExportManager private function handleFilters( ExportInterface $export, QueryBuilder $qb, - $data, + mixed $data, array $centers ) { $filters = $this->retrieveUsedFilters($data); @@ -595,11 +580,9 @@ class ExportManager } /** - * @param mixed $data - * * @return iterable */ - private function retrieveUsedAggregators($data): iterable + private function retrieveUsedAggregators(mixed $data): iterable { if (null === $data) { return []; @@ -613,11 +596,9 @@ class ExportManager } /** - * @param mixed $data - * * @return string[] */ - private function retrieveUsedAggregatorsType($data) + private function retrieveUsedAggregatorsType(mixed $data) { if (null === $data) { return []; @@ -657,7 +638,7 @@ class ExportManager * * @return array an array with types */ - private function retrieveUsedFiltersType($data) + private function retrieveUsedFiltersType(mixed $data) { if (null === $data) { return []; @@ -681,11 +662,10 @@ class ExportManager /** * parse the data to retrieve the used filters and aggregators. * - * @param mixed $data * * @return string[] */ - private function retrieveUsedModifiers($data) + private function retrieveUsedModifiers(mixed $data) { if (null === $data) { return []; diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index c51676b32..a8981082a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -34,20 +34,11 @@ final class PickCenterType extends AbstractType { public const CENTERS_IDENTIFIERS = 'c'; - private AuthorizationHelperForCurrentUserInterface $authorizationHelper; - - private ExportManager $exportManager; - - private RegroupmentRepository $regroupmentRepository; - public function __construct( - ExportManager $exportManager, - RegroupmentRepository $regroupmentRepository, - AuthorizationHelperForCurrentUserInterface $authorizationHelper + private ExportManager $exportManager, + private RegroupmentRepository $regroupmentRepository, + private AuthorizationHelperForCurrentUserInterface $authorizationHelper ) { - $this->exportManager = $exportManager; - $this->authorizationHelper = $authorizationHelper; - $this->regroupmentRepository = $regroupmentRepository; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php index fe42578d9..3476d1304 100644 --- a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php @@ -23,8 +23,6 @@ use Doctrine\Persistence\ObjectRepository; final class NotificationRepository implements ObjectRepository { - private EntityManagerInterface $em; - private ?Statement $notificationByRelatedEntityAndUserAssociatedStatement = null; private EntityRepository $repository; @@ -38,10 +36,9 @@ final class NotificationRepository implements ObjectRepository SQL; - public function __construct(EntityManagerInterface $entityManager) + public function __construct(private EntityManagerInterface $em) { - $this->em = $entityManager; - $this->repository = $entityManager->getRepository(Notification::class); + $this->repository = $em->getRepository(Notification::class); } public function countAllForAttendee(User $addressee): int diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php index 5c8a01e1d..1180e71c7 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php @@ -30,8 +30,7 @@ class PasswordRecoverEvent extends Event private ?User $user = null, private $ip = null, private bool $safelyGenerated = false, - ) - { + ) { } public function getIp() diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderGetActiveFilterHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderGetActiveFilterHelper.php index 5b36e52b3..6f090ca27 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderGetActiveFilterHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderGetActiveFilterHelper.php @@ -28,7 +28,6 @@ final readonly class FilterOrderGetActiveFilterHelper /** * Return all the data required to display the active filters * - * @param FilterOrderHelper $filterOrderHelper * @return array */ public function getActiveFilters(FilterOrderHelper $filterOrderHelper): array @@ -65,7 +64,7 @@ final readonly class FilterOrderGetActiveFilterHelper $value = $this->propertyAccessor->getValue($selected, $options['choice_label']); } else { if (!$selected instanceof \Stringable) { - throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \\Stringable or add a 'choice_label' option to the filterFormBuilder", get_class($selected))); + throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \\Stringable or add a 'choice_label' option to the filterFormBuilder", $selected::class)); } $value = (string)$selected; diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php index 56c73871c..42de9837d 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php @@ -23,10 +23,6 @@ class FilterOrderHelperBuilder private array $dateRanges = []; - private FormFactoryInterface $formFactory; - - private RequestStack $requestStack; - private ?array $searchBoxFields = null; /** @@ -44,12 +40,8 @@ class FilterOrderHelperBuilder */ private array $userPickers = []; - public function __construct( - FormFactoryInterface $formFactory, - RequestStack $requestStack, - ) { - $this->formFactory = $formFactory; - $this->requestStack = $requestStack; + public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack) + { } public function addSingleCheckbox(string $name, string $label): self diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php index 6665750dd..adb662821 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php @@ -18,16 +18,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface { - private FormFactoryInterface $formFactory; - - private RequestStack $requestStack; - - public function __construct( - FormFactoryInterface $formFactory, - RequestStack $requestStack, - ) { - $this->formFactory = $formFactory; - $this->requestStack = $requestStack; + public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack) + { } public function create(string $context, ?array $options = []): FilterOrderHelperBuilder diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php index 4dcc89495..b6508dd87 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php @@ -45,28 +45,13 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface 'compositionType', ]; - private ExportAddressHelper $addressHelper; - - private AggregateStringHelper $aggregateStringHelper; - - private EntityManagerInterface $entityManager; - - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringExportLabelHelper $translatableStringHelper; - public function __construct( - ExportAddressHelper $addressHelper, - AggregateStringHelper $aggregateStringHelper, - EntityManagerInterface $entityManager, - RollingDateConverterInterface $rollingDateConverter, - TranslatableStringExportLabelHelper $translatableStringHelper + private ExportAddressHelper $addressHelper, + private AggregateStringHelper $aggregateStringHelper, + private EntityManagerInterface $entityManager, + private RollingDateConverterInterface $rollingDateConverter, + private TranslatableStringExportLabelHelper $translatableStringHelper ) { - $this->addressHelper = $addressHelper; - $this->aggregateStringHelper = $aggregateStringHelper; - $this->entityManager = $entityManager; - $this->rollingDateConverter = $rollingDateConverter; - $this->translatableStringHelper = $translatableStringHelper; } public function buildForm(FormBuilderInterface $builder) @@ -100,27 +85,21 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { - if (substr($key, 0, strlen('address_fields')) === 'address_fields') { + if (str_starts_with($key, 'address_fields')) { return $this->addressHelper->getLabel($key, $values, $data, 'address_fields'); } - switch ($key) { - case 'membersId': - case 'membersName': - return $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key); + return match ($key) { + 'membersId', 'membersName' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key), + 'compositionType' => $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.' . $key), + default => static function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.household.' . $key; + } - case 'compositionType': - return $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.' . $key); - - default: - return static function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.household.' . $key; - } - - return (string) $value; - }; - } + return (string) $value; + }, + }; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterBetweenDates.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterBetweenDates.php index 9033c64b3..36fd426a9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterBetweenDates.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterBetweenDates.php @@ -39,16 +39,8 @@ class StepFilterBetweenDates implements FilterInterface 'course.inactive_long' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, ]; - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatorInterface $translator; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter, - TranslatorInterface $translator - ) { - $this->rollingDateConverter = $rollingDateConverter; - $this->translator = $translator; + public function __construct(private RollingDateConverterInterface $rollingDateConverter, private TranslatorInterface $translator) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php index 5fa2252cd..9be34ea29 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php @@ -92,129 +92,104 @@ final readonly class ListAccompanyingPeriodHelper return $this->addressHelper->getLabel($key, $values, $data, 'acp_address_fields'); } - switch ($key) { - case 'stepSince': - case 'openingDate': - case 'closingDate': - case 'referrerSince': - case 'acpCreatedAt': - case 'acpUpdatedAt': - return $this->dateTimeHelper->getLabel('export.list.acp.' . $key); + return match ($key) { + 'stepSince', 'openingDate', 'closingDate', 'referrerSince', 'acpCreatedAt', 'acpUpdatedAt' => $this->dateTimeHelper->getLabel('export.list.acp.' . $key), + 'origin', 'closingMotive', 'job' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - case 'origin': - case 'closingMotive': - case 'job': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } + if (null === $value) { + return ''; + } - if (null === $value) { - return ''; - } + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); + }, + 'locationPersonName', 'requestorPerson' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); - }; + if (null === $value || null === $person = $this->personRepository->find($value)) { + return ''; + } - case 'locationPersonName': - case 'requestorPerson': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } + return $this->personRender->renderString($person, []); + }, + 'requestorThirdParty' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - if (null === $value || null === $person = $this->personRepository->find($value)) { - return ''; - } + if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) { + return ''; + } - return $this->personRender->renderString($person, []); - }; + return $this->thirdPartyRender->renderString($thirdparty, []); + }, + 'scopes' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - case 'requestorThirdParty': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } + if (null === $value) { + return ''; + } - if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) { - return ''; - } + return implode( + '|', + array_map( + fn ($s) => $this->translatableStringHelper->localize($s), + json_decode($value, true, 512, JSON_THROW_ON_ERROR) + ) + ); + }, + 'socialIssues' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - return $this->thirdPartyRender->renderString($thirdparty, []); - }; + if (null === $value) { + return ''; + } - case 'scopes': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } + return implode( + '|', + array_map( + fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []), + json_decode($value, true, 512, JSON_THROW_ON_ERROR) + ) + ); + }, + 'step' => fn ($value) => match ($value) { + '_header' => 'export.list.acp.step', + null => '', + AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'), + AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'), + AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'), + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'), + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'), + default => $value, + }, + 'intensity' => fn ($value) => match ($value) { + '_header' => 'export.list.acp.intensity', + null => '', + AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'), + AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'), + default => $value, + }, + default => static function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - if (null === $value) { - return ''; - } + if (null === $value) { + return ''; + } - return implode( - '|', - array_map( - fn ($s) => $this->translatableStringHelper->localize($s), - json_decode($value, true, 512, JSON_THROW_ON_ERROR) - ) - ); - }; - - case 'socialIssues': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } - - if (null === $value) { - return ''; - } - - return implode( - '|', - array_map( - fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []), - json_decode($value, true, 512, JSON_THROW_ON_ERROR) - ) - ); - }; - - case 'step': - return fn ($value) => match ($value) { - '_header' => 'export.list.acp.step', - null => '', - AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'), - AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'), - AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'), - AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'), - AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'), - default => $value, - }; - - case 'intensity': - return fn ($value) => match ($value) { - '_header' => 'export.list.acp.intensity', - null => '', - AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'), - AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'), - default => $value, - }; - - default: - return static function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } - - if (null === $value) { - return ''; - } - - return $value; - }; - } + return $value; + }, + }; } public function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calcDate): void diff --git a/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php index 13291bdd1..ac7f3e8e6 100644 --- a/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php @@ -24,12 +24,9 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface */ protected $translator; - private Security $security; - - public function __construct(TranslatorInterface $translator, Security $security) + public function __construct(TranslatorInterface $translator, private Security $security) { $this->translator = $translator; - $this->security = $security; } public function buildMenu($menuId, MenuItem $menu, array $parameters): void diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php index 4dcb03489..4561f95e6 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php @@ -19,11 +19,8 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvalu final class AccompanyingPeriodWorkEvaluationDocumentNotificationHandler implements NotificationHandlerInterface { - private AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository; - - public function __construct(AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository) + public function __construct(private AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository) { - $this->accompanyingPeriodWorkEvaluationDocumentRepository = $accompanyingPeriodWorkEvaluationDocumentRepository; } public function getTemplate(Notification $notification, array $options = []): string diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php index b111c131f..858dd1430 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php @@ -19,11 +19,8 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepos final class AccompanyingPeriodWorkNotificationHandler implements NotificationHandlerInterface { - private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository; - - public function __construct(AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) + public function __construct(private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) { - $this->accompanyingPeriodWorkRepository = $accompanyingPeriodWorkRepository; } public function getTemplate(Notification $notification, array $options = []): string diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 79a7710ff..032d3f0f7 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -37,24 +37,12 @@ use function count; */ final readonly class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface { - private AccompanyingPeriodRepository $accompanyingPeriodRepository; - - private AuthorizationHelperForCurrentUserInterface $authorizationHelper; - - private CenterResolverManagerInterface $centerResolver; - - private Security $security; - public function __construct( - AccompanyingPeriodRepository $accompanyingPeriodRepository, - Security $security, - AuthorizationHelperForCurrentUserInterface $authorizationHelper, - CenterResolverManagerInterface $centerResolverDispatcher + private AccompanyingPeriodRepository $accompanyingPeriodRepository, + private Security $security, + private AuthorizationHelperForCurrentUserInterface $authorizationHelper, + private CenterResolverManagerInterface $centerResolver ) { - $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; - $this->security = $security; - $this->authorizationHelper = $authorizationHelper; - $this->centerResolver = $centerResolverDispatcher; } public function buildQueryOpenedAccompanyingCourseByUserAndPostalCodes(?User $user, array $postalCodes = []): QueryBuilder @@ -178,7 +166,6 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin * @param QueryBuilder $qb where the accompanying period have the `ap` alias * @param array $scopesCanSee * @param array $scopesCanSeeConfidential - * @return QueryBuilder */ public function addACLClauses(QueryBuilder $qb, array $scopesCanSee, array $scopesCanSeeConfidential): QueryBuilder { @@ -272,10 +259,8 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin } /** - * @param QueryBuilder $qb * @param list, scopeCanSeeConfidential: list}> $centerScopes * @param bool $allowNoCenter if true, will allow to see the periods linked to person which does not have any center. Very few edge case when some Person are not associated to a center. - * @return QueryBuilder */ public function addACLMultiCenterOnQuery(QueryBuilder $qb, array $centerScopes, bool $allowNoCenter = false): QueryBuilder { diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 795a921e7..f7dac49bd 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -107,15 +107,12 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH */ public const SEE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL'; - private Security $security; - private VoterHelperInterface $voterHelper; public function __construct( - Security $security, + private Security $security, VoterHelperFactoryInterface $voterHelperFactory ) { - $this->security = $security; $this->voterHelper = $voterHelperFactory ->generate(self::class) ->addCheckFor(null, [self::CREATE, self::REASSIGN_BULK]) diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index 4f6235930..e9ef7bba0 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -51,48 +51,18 @@ class AccompanyingPeriodContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - private BaseContextData $baseContextData; - - private DocumentCategoryRepository $documentCategoryRepository; - - private EntityManagerInterface $em; - - private NormalizerInterface $normalizer; - - private PersonRenderInterface $personRender; - - private PersonRepository $personRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - - private ThirdPartyRender $thirdPartyRender; - - private ThirdPartyRepository $thirdPartyRepository; - public function __construct( - DocumentCategoryRepository $documentCategoryRepository, - NormalizerInterface $normalizer, - TranslatableStringHelperInterface $translatableStringHelper, - EntityManagerInterface $em, - PersonRenderInterface $personRender, - PersonRepository $personRepository, - TranslatorInterface $translator, - BaseContextData $baseContextData, - ThirdPartyRender $thirdPartyRender, - ThirdPartyRepository $thirdPartyRepository + private DocumentCategoryRepository $documentCategoryRepository, + private NormalizerInterface $normalizer, + private TranslatableStringHelperInterface $translatableStringHelper, + private EntityManagerInterface $em, + private PersonRenderInterface $personRender, + private PersonRepository $personRepository, + private TranslatorInterface $translator, + private BaseContextData $baseContextData, + private ThirdPartyRender $thirdPartyRender, + private ThirdPartyRepository $thirdPartyRepository ) { - $this->documentCategoryRepository = $documentCategoryRepository; - $this->normalizer = $normalizer; - $this->translatableStringHelper = $translatableStringHelper; - $this->em = $em; - $this->personRender = $personRender; - $this->personRepository = $personRepository; - $this->translator = $translator; - $this->baseContextData = $baseContextData; - $this->thirdPartyRender = $thirdPartyRender; - $this->thirdPartyRepository = $thirdPartyRepository; } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index f58788120..78921a7e7 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -38,36 +38,8 @@ class AccompanyingPeriodWorkEvaluationContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - private AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext; - - private EntityManagerInterface $em; - - private EvaluationRepository $evaluationRepository; - - private NormalizerInterface $normalizer; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private ThirdPartyRender $thirdPartyRender; - - private TranslatorInterface $translator; - - public function __construct( - AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext, - EntityManagerInterface $em, - EvaluationRepository $evaluationRepository, - NormalizerInterface $normalizer, - TranslatableStringHelperInterface $translatableStringHelper, - ThirdPartyRender $thirdPartyRender, - TranslatorInterface $translator - ) { - $this->accompanyingPeriodWorkContext = $accompanyingPeriodWorkContext; - $this->em = $em; - $this->evaluationRepository = $evaluationRepository; - $this->normalizer = $normalizer; - $this->translatableStringHelper = $translatableStringHelper; - $this->thirdPartyRender = $thirdPartyRender; - $this->translator = $translator; + public function __construct(private AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext, private EntityManagerInterface $em, private EvaluationRepository $evaluationRepository, private NormalizerInterface $normalizer, private TranslatableStringHelperInterface $translatableStringHelper, private ThirdPartyRender $thirdPartyRender, private TranslatorInterface $translator) + { } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index 5b5773922..7aa10edca 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -56,64 +56,25 @@ use function count; */ final class PersonContext implements PersonContextInterface { - private AuthorizationHelperInterface $authorizationHelper; - - private BaseContextData $baseContextData; - - private CenterResolverManagerInterface $centerResolverManager; - - private DocumentCategoryRepository $documentCategoryRepository; - - private EntityManagerInterface $em; - - private NormalizerInterface $normalizer; - - private ScopeRepositoryInterface $scopeRepository; - - private Security $security; - private bool $showScopes; - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - - private ThirdPartyRender $thirdPartyRender; - - private ThirdPartyRepository $thirdPartyRepository; - - private ResidentialAddressRepository $residentialAddressRepository; - public function __construct( - AuthorizationHelperInterface $authorizationHelper, - BaseContextData $baseContextData, - CenterResolverManagerInterface $centerResolverManager, - DocumentCategoryRepository $documentCategoryRepository, - EntityManagerInterface $em, - NormalizerInterface $normalizer, + private AuthorizationHelperInterface $authorizationHelper, + private BaseContextData $baseContextData, + private CenterResolverManagerInterface $centerResolverManager, + private DocumentCategoryRepository $documentCategoryRepository, + private EntityManagerInterface $em, + private NormalizerInterface $normalizer, ParameterBagInterface $parameterBag, - ScopeRepositoryInterface $scopeRepository, - Security $security, - TranslatorInterface $translator, - TranslatableStringHelperInterface $translatableStringHelper, - ThirdPartyRender $thirdPartyRender, - ThirdPartyRepository $thirdPartyRepository, - ResidentialAddressRepository $residentialAddressRepository + private ScopeRepositoryInterface $scopeRepository, + private Security $security, + private TranslatorInterface $translator, + private TranslatableStringHelperInterface $translatableStringHelper, + private ThirdPartyRender $thirdPartyRender, + private ThirdPartyRepository $thirdPartyRepository, + private ResidentialAddressRepository $residentialAddressRepository ) { - $this->authorizationHelper = $authorizationHelper; - $this->centerResolverManager = $centerResolverManager; - $this->baseContextData = $baseContextData; - $this->documentCategoryRepository = $documentCategoryRepository; - $this->em = $em; - $this->normalizer = $normalizer; - $this->scopeRepository = $scopeRepository; - $this->security = $security; $this->showScopes = $parameterBag->get('chill_main')['acl']['form_show_scopes']; - $this->translator = $translator; - $this->translatableStringHelper = $translatableStringHelper; - $this->thirdPartyRender = $thirdPartyRender; - $this->thirdPartyRepository = $thirdPartyRepository; - $this->residentialAddressRepository = $residentialAddressRepository; } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php index cb8d56ba3..9e2bf622f 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php @@ -488,9 +488,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase } /** - * @param Person $person * @param array $scopes - * @return AccompanyingPeriod */ private function buildPeriod(Person $person, array $scopes, User|null $creator, bool $confirm): AccompanyingPeriod { diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index a480f0d38..7a70dd0f1 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -44,11 +44,9 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator foreach ($relationships as $r) { if (spl_object_hash($r) !== spl_object_hash($value) - and - ( + and ( ($r->getFromPerson() === $fromPerson and $r->getToPerson() === $toPerson) - || - ($r->getFromPerson() === $toPerson and $r->getToPerson() === $fromPerson) + || ($r->getFromPerson() === $toPerson and $r->getToPerson() === $fromPerson) ) ) { $this->context->buildViolation($constraint->message) diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php index 30477f269..6a77b5629 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php @@ -168,7 +168,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or * * @return string|string[] */ - private function getRandomChoice(CustomField $field) + private function getRandomChoice(CustomField $field): string|array { $choices = $field->getOptions()['choices']; $multiple = $field->getOptions()['multiple']; diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 4c6ab338f..b4c9129e5 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -48,41 +48,17 @@ use function array_merge; final class SingleTaskController extends AbstractController { - private CenterResolverDispatcherInterface $centerResolverDispatcher; - - private EventDispatcherInterface $eventDispatcher; - - private FilterOrderHelperFactoryInterface $filterOrderHelperFactory; - - private LoggerInterface $logger; - - private PaginatorFactory $paginatorFactory; - - private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository; - - private TimelineBuilder $timelineBuilder; - - private TranslatorInterface $translator; - public function __construct( - CenterResolverDispatcherInterface $centerResolverDispatcher, - PaginatorFactory $paginatorFactory, - SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, - TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher, - TimelineBuilder $timelineBuilder, - LoggerInterface $logger, - FilterOrderHelperFactoryInterface $filterOrderHelperFactory, + private CenterResolverDispatcherInterface $centerResolverDispatcher, + private PaginatorFactory $paginatorFactory, + private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, + private TranslatorInterface $translator, + private EventDispatcherInterface $eventDispatcher, + private TimelineBuilder $timelineBuilder, + private LoggerInterface $logger, + private FilterOrderHelperFactoryInterface $filterOrderHelperFactory, private SingleTaskStateRepository $singleTaskStateRepository ) { - $this->eventDispatcher = $eventDispatcher; - $this->timelineBuilder = $timelineBuilder; - $this->logger = $logger; - $this->translator = $translator; - $this->centerResolverDispatcher = $centerResolverDispatcher; - $this->paginatorFactory = $paginatorFactory; - $this->singleTaskAclAwareRepository = $singleTaskAclAwareRepository; - $this->filterOrderHelperFactory = $filterOrderHelperFactory; } /** @@ -90,10 +66,8 @@ final class SingleTaskController extends AbstractController * "/{_locale}/task/single-task/{id}/delete", * name="chill_task_single_task_delete" * ) - * - * @param mixed $id */ - public function deleteAction(Request $request, $id) + public function deleteAction(Request $request, mixed $id) { $course = null; $em = $this->getDoctrine()->getManager(); @@ -600,24 +574,19 @@ final class SingleTaskController extends AbstractController } } - switch ($entityType) { - case 'person': - return $this->render('@ChillTask/SingleTask/Person/new.html.twig', [ - 'form' => $form->createView(), - 'task' => $task, - 'person' => $task->getPerson(), - ]); - - case 'course': - return $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', [ - 'form' => $form->createView(), - 'task' => $task, - 'accompanyingCourse' => $task->getCourse(), - ]); - - default: - throw new LogicException('entity context not supported'); - } + return match ($entityType) { + 'person' => $this->render('@ChillTask/SingleTask/Person/new.html.twig', [ + 'form' => $form->createView(), + 'task' => $task, + 'person' => $task->getPerson(), + ]), + 'course' => $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', [ + 'form' => $form->createView(), + 'task' => $task, + 'accompanyingCourse' => $task->getCourse(), + ]), + default => throw new LogicException('entity context not supported'), + }; } /** @@ -701,9 +670,8 @@ final class SingleTaskController extends AbstractController /** * Creates a form to delete a Task entity by id. - * @param mixed $id */ - private function createDeleteForm($id): FormInterface + private function createDeleteForm(mixed $id): FormInterface { return $this->createFormBuilder() ->setAction($this->generateUrl( diff --git a/src/Bundle/ChillTaskBundle/Entity/RecurringTask.php b/src/Bundle/ChillTaskBundle/Entity/RecurringTask.php index 557c12edd..6c1bc4bcc 100644 --- a/src/Bundle/ChillTaskBundle/Entity/RecurringTask.php +++ b/src/Bundle/ChillTaskBundle/Entity/RecurringTask.php @@ -186,6 +186,7 @@ class RecurringTask extends AbstractTask * * * @return RecurringTask + * @param mixed $occurenceStartDate */ public function setOccurenceStartDate($occurenceStartDate) { @@ -199,6 +200,7 @@ class RecurringTask extends AbstractTask * * * @return RecurringTask + * @param mixed $occurenceWarningInterval */ public function setOccurenceWarningInterval($occurenceWarningInterval) { diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 8aa8b9a01..91e915e09 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -102,7 +102,7 @@ class ThirdPartyType extends AbstractType 'label' => 'thirdparty.Contact data are confidential', ]); - // Institutional ThirdParty (parent) + // Institutional ThirdParty (parent) } else { $builder ->add('nameCompany', TextType::class, [