From 14d65fa931ebbc8a5feede90b323299c547f31d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 30 Oct 2025 01:20:52 +0100 Subject: [PATCH] apply rector rules --- .../Export/LinkedToPerson/ListActivity.php | 16 +++--- .../ActivityReasonCategoryRepository.php | 2 + .../Repository/ActivityReasonRepository.php | 2 + .../Repository/ActivityRepository.php | 2 + .../ActivityTypeCategoryRepository.php | 2 + .../Repository/AsideActivityRepository.php | 2 + .../Repository/ChargeRepository.php | 7 +-- .../Repository/ResourceRepository.php | 7 +-- .../Authorization/BudgetElementVoter.php | 2 +- .../MapAndSubscribeUserCalendarCommand.php | 36 +++--------- .../SendTestShortMessageOnCalendarCommand.php | 8 +-- .../ChillCalendarBundle/Entity/Calendar.php | 10 +--- .../Repository/CalendarRangeRepository.php | 6 +- .../Repository/CalendarRepository.php | 14 +---- .../Repository/CancelReasonRepository.php | 2 + .../Security/Voter/CalendarDocVoter.php | 2 +- .../Security/Voter/InviteVoter.php | 2 +- .../Command/CreateFieldsOnGroupCommand.php | 28 ++-------- .../CustomFields/CustomFieldNumber.php | 6 +- .../CustomFieldsDefaultGroupRepository.php | 3 + .../Twig/CustomFieldRenderingTwig.php | 2 +- ...ConfigureOpenstackObjectStorageCommand.php | 1 - .../Templating/AsyncUploadExtension.php | 13 +---- .../AccompanyingCourseDocumentRepository.php | 2 + .../StoredObjectPointInTimeRepository.php | 2 + .../Authorization/AsyncUploadVoter.php | 2 +- .../Authorization/StoredObjectVoter.php | 2 +- .../Export/Export/ListEvents.php | 16 +++--- .../Repository/ParticipationRepository.php | 2 + .../Repository/StatusRepository.php | 3 + .../ChillJobBundle/src/Export/ListCV.php | 18 +++--- .../ChillJobBundle/src/Export/ListFrein.php | 18 +++--- .../src/Export/ListProjetProfessionnel.php | 18 +++--- .../Command/ChillImportUsersCommand.php | 26 ++++----- .../ChillUserSendRenewPasswordCodeCommand.php | 19 ++----- .../Command/DumpListPermissionsCommand.php | 6 +- .../Command/ExecuteCronJobCommand.php | 22 ++++---- .../LoadAddressesBEFromBestAddressCommand.php | 31 ++++------- .../Command/LoadAddressesFRFromBANCommand.php | 20 ++----- .../LoadAddressesFRFromBANOCommand.php | 20 ++----- .../LoadAddressesLUFromBDAddressCommand.php | 19 ++----- .../Command/LoadAndUpdateLanguagesCommand.php | 39 +++---------- .../Command/LoadCountriesCommand.php | 16 +----- .../Command/LoadPostalCodeFR.php | 9 +-- .../Command/LoadPostalCodesCommand.php | 55 ++++--------------- .../Command/SetPasswordCommand.php | 24 +++----- .../SynchronizeEntityInfoViewsCommand.php | 9 +-- .../Controller/PasswordController.php | 26 ++++----- .../Event/TrackCreateUpdateSubscriber.php | 13 +---- .../Form/Type/DateIntervalType.php | 4 +- .../ChillMainBundle/Form/UserPasswordType.php | 38 +++++-------- src/Bundle/ChillMainBundle/Form/UserType.php | 14 ++--- .../Phonenumber/Templating.php | 13 +---- .../Repository/LocationRepository.php | 2 + .../Repository/LocationTypeRepository.php | 2 + .../EntityWorkflowStepHoldRepository.php | 2 + .../EntityWorkflowStepSignatureRepository.php | 2 + .../Authorization/ChillExportVoter.php | 2 +- .../EntityWorkflowAttachmentVoter.php | 2 +- .../EntityWorkflowStepSignatureVoter.php | 2 +- .../EntityWorkflowTransitionVoter.php | 2 +- .../Authorization/EntityWorkflowVoter.php | 2 +- .../Authorization/ExportGenerationVoter.php | 2 +- .../Authorization/NotificationVoter.php | 2 +- .../Authorization/SavedExportVoter.php | 2 +- .../Security/Authorization/UserGroupVoter.php | 2 +- .../WorkflowEntityDeletionVoter.php | 2 +- .../PasswordRecover/PasswordRecoverVoter.php | 2 +- .../Resolver/ResolverTwigExtension.php | 16 ++---- .../Templating/ChillTwigRoutingHelper.php | 12 +--- .../Templating/TranslatableStringTwig.php | 21 +------ .../Command/ChillPersonMoveCommand.php | 1 - .../Command/ImportSocialWorkMetadata.php | 23 +++----- ...emoveOldDraftAccompanyingPeriodCommand.php | 25 +++------ .../ReassignAccompanyingPeriodController.php | 2 +- ...mpanyingPeriodWorkEvaluationRepository.php | 6 +- .../AccompanyingPeriodWorkRepository.php | 6 +- .../AdministrativeStatusRepository.php | 3 + .../Repository/EmploymentStatusRepository.php | 3 + .../PersonIdentifierDefinitionRepository.php | 2 + .../ResidentialAddressRepository.php | 2 + .../AccompanyingPeriodCommentVoter.php | 2 +- .../AccompanyingPeriodResourceVoter.php | 2 +- ...nyingPeriodWorkEvaluationDocumentVoter.php | 2 +- .../AccompanyingPeriodWorkEvaluationVoter.php | 2 +- .../AccompanyingPeriodWorkVoter.php | 2 +- .../Security/Authorization/HouseholdVoter.php | 2 +- .../Export/Export/ReportList.php | 16 +++--- .../Templating/TaskTwigExtension.php | 12 +--- .../ThirdPartyCategoryRepository.php | 2 + .../ThirdPartyProfessionRepository.php | 2 + 91 files changed, 306 insertions(+), 571 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index c152fc8e5..464091fe6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -67,15 +67,13 @@ class ListActivity implements ListInterface, GroupedExportInterface 'expanded' => true, 'choices' => array_combine($this->fields, $this->fields), 'label' => 'Fields to include in export', - 'constraints' => [new Callback([ - 'callback' => static function ($selected, ExecutionContextInterface $context) { - if (0 === \count($selected)) { - $context->buildViolation('You must select at least one element') - ->atPath('fields') - ->addViolation(); - } - }, - ])], + 'constraints' => [new Callback(callback: static function ($selected, ExecutionContextInterface $context) { + if (0 === \count($selected)) { + $context->buildViolation('You must select at least one element') + ->atPath('fields') + ->addViolation(); + } + })], ]); } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityReasonCategoryRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonCategoryRepository.php index 2ae642c64..4e8b3f262 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityReasonCategoryRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonCategoryRepository.php @@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry; * @method ActivityReasonCategory|null findOneBy(array $criteria, array $orderBy = null) * @method ActivityReasonCategory[] findAll() * @method ActivityReasonCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ActivityBundle\Entity\ActivityReasonCategory> */ class ActivityReasonCategoryRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php index 7943c0fb3..ce5cfad52 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php @@ -20,6 +20,8 @@ use Symfony\Component\HttpFoundation\RequestStack; * @method ActivityReason|null find($id, $lockMode = null, $lockVersion = null) * @method ActivityReason|null findOneBy(array $criteria, array $orderBy = null) * @method ActivityReason[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ActivityBundle\Entity\ActivityReason> */ class ActivityReasonRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php index ff4904f9e..a500b7736 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php @@ -24,6 +24,8 @@ use Doctrine\Persistence\ManagerRegistry; * @method Activity|null findOneBy(array $criteria, array $orderBy = null) * @method Activity[] findAll() * @method Activity[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ActivityBundle\Entity\Activity> */ class ActivityRepository extends ServiceEntityRepository implements AssociatedEntityToStoredObjectInterface { diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeCategoryRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeCategoryRepository.php index 3259f0567..73ab02fa5 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeCategoryRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeCategoryRepository.php @@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry; * @method ActivityTypeCategory|null findOneBy(array $criteria, array $orderBy = null) * @method ActivityTypeCategory[] findAll() * @method ActivityTypeCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ActivityBundle\Entity\ActivityTypeCategory> */ class ActivityTypeCategoryRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityRepository.php b/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityRepository.php index b3dc46f87..6e9ea7f51 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityRepository.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityRepository.php @@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry; * @method AsideActivity|null findOneBy(array $criteria, array $orderBy = null) * @method AsideActivity[] findAll() * @method AsideActivity[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\AsideActivityBundle\Entity\AsideActivity> */ final class AsideActivityRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillBudgetBundle/Repository/ChargeRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ChargeRepository.php index fdc795896..d61eadd35 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ChargeRepository.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ChargeRepository.php @@ -22,6 +22,8 @@ use Doctrine\Persistence\ManagerRegistry; * * This class was generated by the Doctrine ORM. Add your own custom * repository methods below. + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\BudgetBundle\Entity\Charge> */ class ChargeRepository extends ServiceEntityRepository { @@ -59,10 +61,7 @@ class ChargeRepository extends ServiceEntityRepository $qb->orderBy($sort); } - $qb->setParameters([ - 'entity' => $entity, - 'date' => $date, - ]); + $qb->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('entity', $entity), new \Doctrine\ORM\Query\Parameter('date', $date)])); return $qb->getQuery()->getResult(); } diff --git a/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php index 64d166345..33fdc2108 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php @@ -22,6 +22,8 @@ use Doctrine\Persistence\ManagerRegistry; * * This class was generated by the Doctrine ORM. Add your own custom * repository methods below. + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\BudgetBundle\Entity\Resource> */ class ResourceRepository extends ServiceEntityRepository { @@ -59,10 +61,7 @@ class ResourceRepository extends ServiceEntityRepository $qb->orderBy($sort); } - $qb->setParameters([ - 'entity' => $entity, - 'date' => $date, - ]); + $qb->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('entity', $entity), new \Doctrine\ORM\Query\Parameter('date', $date)])); return $qb->getQuery()->getResult(); } diff --git a/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php b/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php index 405bcb2fa..3f40f9f2c 100644 --- a/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php +++ b/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php @@ -69,7 +69,7 @@ class BudgetElementVoter extends Voter implements ProvideRoleHierarchyInterface return $this->voter->supports($attribute, $subject); } - protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { if ( $subject instanceof Person diff --git a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php index 9017b300a..ffb1e002f 100644 --- a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php @@ -26,14 +26,13 @@ use Chill\MainBundle\Repository\UserRepositoryInterface; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:calendar:msgraph-user-map-subscribe')] -final class MapAndSubscribeUserCalendarCommand extends Command +final class MapAndSubscribeUserCalendarCommand { - protected static $defaultDescription = 'MSGraph: collect user metadata and create subscription on events for users, and sync the user absence-presence'; + private static $defaultDescription = 'MSGraph: collect user metadata and create subscription on events for users, and sync the user absence-presence'; public function __construct( private readonly EntityManagerInterface $em, @@ -43,16 +42,20 @@ final class MapAndSubscribeUserCalendarCommand extends Command private readonly UserRepositoryInterface $userRepository, private readonly MSUserAbsenceSync $userAbsenceSync, ) { - parent::__construct('chill:calendar:msgraph-user-map-subscribe'); } - public function execute(InputInterface $input, OutputInterface $output): int + public function __invoke( + #[\Symfony\Component\Console\Attribute\Option(name: 'renew-before-end-interval', shortcut: 'r', mode: InputOption::VALUE_OPTIONAL, description: 'delay before renewing subscription')] + string $renewBeforeEndInterval = 'P1D', + #[\Symfony\Component\Console\Attribute\Option(name: 'subscription-duration', shortcut: 's', mode: InputOption::VALUE_OPTIONAL, description: 'duration for the subscription')] + string $subscriptionDuration = 'PT4230M', + OutputInterface $output): int { $this->logger->info(self::class.' execute command'); $limit = 50; $offset = 0; - $expiration = (new \DateTimeImmutable('now'))->add(new \DateInterval($input->getOption('subscription-duration'))); + $expiration = (new \DateTimeImmutable('now'))->add(new \DateInterval($subscriptionDuration)); $users = $this->userRepository->findAllAsArray('fr'); $created = 0; $renewed = 0; @@ -156,25 +159,4 @@ final class MapAndSubscribeUserCalendarCommand extends Command return Command::SUCCESS; } - - protected function configure(): void - { - parent::configure(); - - $this - ->addOption( - 'renew-before-end-interval', - 'r', - InputOption::VALUE_OPTIONAL, - 'delay before renewing subscription', - 'P1D' - ) - ->addOption( - 'subscription-duration', - 's', - InputOption::VALUE_OPTIONAL, - 'duration for the subscription', - 'PT4230M' - ); - } } diff --git a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php index e0bba8ac9..c14879190 100644 --- a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php @@ -30,14 +30,13 @@ use libphonenumber\PhoneNumberType; use libphonenumber\PhoneNumberUtil; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\QuestionHelper; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; use Symfony\Component\Notifier\TexterInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:calendar:test-send-short-message', description: 'Test sending a SMS for a dummy calendar appointment')] -class SendTestShortMessageOnCalendarCommand extends Command +class SendTestShortMessageOnCalendarCommand { protected static $defaultDescription = 'Test sending a SMS for a dummy calendar appointment'; @@ -48,12 +47,9 @@ class SendTestShortMessageOnCalendarCommand extends Command private readonly TexterInterface $transporter, private readonly UserRepositoryInterface $userRepository, ) { - parent::__construct('chill:calendar:test-send-short-message'); } - protected function configure() {} - - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $calendar = new Calendar(); $calendar->setSendSMS(true); diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 153ffd01a..8f4f32345 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -499,15 +499,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente public static function loadValidatorMetadata(ClassMetadata $metadata): void { $metadata->addPropertyConstraint('startDate', new NotBlank()); - $metadata->addPropertyConstraint('startDate', new Range([ - 'min' => '2 years ago', - 'max' => '+ 2 years', - ])); + $metadata->addPropertyConstraint('startDate', new Range(min: '2 years ago', max: '+ 2 years')); $metadata->addPropertyConstraint('endDate', new NotBlank()); - $metadata->addPropertyConstraint('endDate', new Range([ - 'min' => '2 years ago', - 'max' => '+ 2 years', - ])); + $metadata->addPropertyConstraint('endDate', new Range(min: '2 years ago', max: '+ 2 years')); } /** diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php index 33f2f5818..7adb3ca35 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php @@ -156,10 +156,6 @@ class CalendarRangeRepository implements ObjectRepository $qb->expr()->isNull('calendar') ) ) - ->setParameters([ - 'user' => $user, - 'startDate' => $from, - 'endDate' => $to, - ]); + ->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('user', $user), new \Doctrine\ORM\Query\Parameter('startDate', $from), new \Doctrine\ORM\Query\Parameter('endDate', $to)])); } } diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php index 3121854e5..c37906552 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php @@ -193,11 +193,7 @@ class CalendarRepository implements ObjectRepository $qb->expr()->lte('c.endDate', ':endDate'), ) ) - ->setParameters([ - 'user' => $user, - 'startDate' => $from, - 'endDate' => $to, - ]); + ->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('user', $user), new \Doctrine\ORM\Query\Parameter('startDate', $from), new \Doctrine\ORM\Query\Parameter('endDate', $to)])); } private function queryByNotificationAvailable(\DateTimeImmutable $startDate, \DateTimeImmutable $endDate): QueryBuilder @@ -216,13 +212,7 @@ class CalendarRepository implements ObjectRepository ) ); - $qb->setParameters([ - 'true' => true, - 'startDate' => $startDate, - 'endDate' => $endDate, - 'pending' => Calendar::SMS_PENDING, - 'cancel_pending' => Calendar::SMS_CANCEL_PENDING, - ]); + $qb->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('true', true), new \Doctrine\ORM\Query\Parameter('startDate', $startDate), new \Doctrine\ORM\Query\Parameter('endDate', $endDate), new \Doctrine\ORM\Query\Parameter('pending', Calendar::SMS_PENDING), new \Doctrine\ORM\Query\Parameter('cancel_pending', Calendar::SMS_CANCEL_PENDING)])); return $qb; } diff --git a/src/Bundle/ChillCalendarBundle/Repository/CancelReasonRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CancelReasonRepository.php index 102882c9e..d55e5a3b7 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CancelReasonRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CancelReasonRepository.php @@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry; * @method CancelReason|null findOneBy(array $criteria, array $orderBy = null) * @method CancelReason[] findAll() * @method CancelReason[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\CalendarBundle\Entity\CancelReason> */ class CancelReasonRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php index 94bb6f1aa..b44190726 100644 --- a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php +++ b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php @@ -36,7 +36,7 @@ class CalendarDocVoter extends Voter return \in_array($attribute, self::ALL, true) && ($subject instanceof CalendarDoc || $subject instanceof Calendar); } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { if ($subject instanceof Calendar) { return match ($attribute) { diff --git a/src/Bundle/ChillCalendarBundle/Security/Voter/InviteVoter.php b/src/Bundle/ChillCalendarBundle/Security/Voter/InviteVoter.php index 72aa806e6..fec3cbd9f 100644 --- a/src/Bundle/ChillCalendarBundle/Security/Voter/InviteVoter.php +++ b/src/Bundle/ChillCalendarBundle/Security/Voter/InviteVoter.php @@ -35,7 +35,7 @@ class InviteVoter extends Voter * @param string $attribute * @param Invite $subject */ - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { return $token->getUser() === $subject->getUser(); } diff --git a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php index a18f295bd..79374f4ad 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php +++ b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php @@ -17,7 +17,6 @@ use Chill\CustomFieldsBundle\Service\CustomFieldProvider; use Doctrine\ORM\EntityManager; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Table; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; @@ -30,7 +29,7 @@ use Symfony\Component\Yaml\Parser; * Create custom fields from a yml file. */ #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:custom_fields:populate_group')] -class CreateFieldsOnGroupCommand extends Command +class CreateFieldsOnGroupCommand { protected static $defaultDescription = 'Create custom fields from a yml file'; final public const ARG_DELETE = 'delete'; @@ -47,23 +46,6 @@ class CreateFieldsOnGroupCommand extends Command private $availableLanguages, private $customizablesEntities, ) { - parent::__construct(); - } - - protected function configure() - { - $this - ->addArgument( - self::ARG_PATH, - InputOption::VALUE_REQUIRED, - 'Path to description file' - ) - ->addOption( - self::ARG_DELETE, - null, - InputOption::VALUE_NONE, - 'If set, delete existing fields' - ); } /** @@ -80,7 +62,9 @@ class CreateFieldsOnGroupCommand extends Command } } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: self::ARG_PATH, description: 'Path to description file')] + ?string $path, #[\Symfony\Component\Console\Attribute\Option(name: self::ARG_DELETE, mode: InputOption::VALUE_NONE, description: 'If set, delete existing fields')] + bool $delete = false, OutputInterface $output): int { $helper = $this->getHelperSet()->get('question'); @@ -120,12 +104,12 @@ class CreateFieldsOnGroupCommand extends Command ); $customFieldsGroup = $helper->ask($input, $output, $question); - if ($input->getOption(self::ARG_DELETE)) { + if ($delete) { $this->deleteFieldsForCFGroup($customFieldsGroup); } $fieldsInput = $this->_parse( - $input->getArgument(self::ARG_PATH), + $path, $output ); diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php index 90b016f40..bb0651567 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php @@ -75,7 +75,7 @@ class CustomFieldNumber extends AbstractCustomField 'scale' => 0, 'label' => 'Precision', 'constraints' => [ - new GreaterThanOrEqual(['value' => 0]), + new GreaterThanOrEqual(value: 0), ], ]) ->add(self::POST_TEXT, TextType::class, [ @@ -136,11 +136,11 @@ class CustomFieldNumber extends AbstractCustomField // add constraints if required if (null !== $options[self::MIN]) { - $fieldOptions['constraints'][] = new GreaterThanOrEqual(['value' => $options[self::MIN]]); + $fieldOptions['constraints'][] = new GreaterThanOrEqual(value: $options[self::MIN]); } if (null !== $options[self::MAX]) { - $fieldOptions['constraints'][] = new LessThanOrEqual(['value' => $options[self::MAX]]); + $fieldOptions['constraints'][] = new LessThanOrEqual(value: $options[self::MAX]); } // add precision to options if required diff --git a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldsDefaultGroupRepository.php b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldsDefaultGroupRepository.php index a336970dc..844889a7b 100644 --- a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldsDefaultGroupRepository.php +++ b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldsDefaultGroupRepository.php @@ -15,6 +15,9 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; +/** + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup> + */ class CustomFieldsDefaultGroupRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) diff --git a/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php b/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php index 2d5beecef..0982ee9d9 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php +++ b/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php @@ -52,7 +52,6 @@ class CustomFieldRenderingTwig extends AbstractExtension ], 'needs_environment' => true, ]), - new TwigFunction('chill_custom_field_is_empty', $this->isEmptyValue(...)), ]; } @@ -64,6 +63,7 @@ class CustomFieldRenderingTwig extends AbstractExtension return 'chill_custom_fields_rendering'; } + #[\Twig\Attribute\AsTwigFunction('chill_custom_field_is_empty')] public function isEmptyValue($fields, CustomField $customField) { return $this->customFieldsHelper diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/ConfigureOpenstackObjectStorageCommand.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/ConfigureOpenstackObjectStorageCommand.php index f9c633db7..23d2c48b8 100644 --- a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/ConfigureOpenstackObjectStorageCommand.php +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/ConfigureOpenstackObjectStorageCommand.php @@ -34,7 +34,6 @@ class ConfigureOpenstackObjectStorageCommand extends Command $this->tempUrlKey = $config['temp_url_key']; $this->basePath = $config['temp_url_base_path']; - parent::__construct(); } protected function configure() diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Templating/AsyncUploadExtension.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Templating/AsyncUploadExtension.php index 8bece267b..1e0af53c7 100644 --- a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Templating/AsyncUploadExtension.php +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Templating/AsyncUploadExtension.php @@ -15,27 +15,19 @@ use Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface; use Chill\DocStoreBundle\Entity\StoredObject; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Twig\Extension\AbstractExtension; -use Twig\TwigFilter; /** * This class extends the AbstractExtension class and provides Twig filter functions for generating URLs for asynchronous * file uploads. */ -class AsyncUploadExtension extends AbstractExtension +class AsyncUploadExtension { public function __construct( private readonly TempUrlGeneratorInterface $tempUrlGenerator, private readonly UrlGeneratorInterface $routingUrlGenerator, ) {} - public function getFilters() - { - return [ - new TwigFilter('file_url', $this->computeSignedUrl(...)), - new TwigFilter('generate_url', $this->computeGenerateUrl(...)), - ]; - } - + #[\Twig\Attribute\AsTwigFilter('file_url')] public function computeSignedUrl(StoredObject|string $file, string $method = 'GET', ?int $expiresDelay = null): string { if ($file instanceof StoredObject) { @@ -47,6 +39,7 @@ class AsyncUploadExtension extends AbstractExtension return $this->tempUrlGenerator->generate($method, $object_name, $expiresDelay)->url; } + #[\Twig\Attribute\AsTwigFilter('generate_url')] public function computeGenerateUrl(StoredObject|string $file, string $method = 'GET', ?int $expiresDelay = null): string { if ($file instanceof StoredObject) { diff --git a/src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php b/src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php index cb45d7d45..fc789fcd6 100644 --- a/src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php +++ b/src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php @@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry; * @method AccompanyingCourseDocument|null findOneBy(array $criteria, array $orderBy = null) * @method AccompanyingCourseDocument[] findAll() * @method AccompanyingCourseDocument[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\DocStoreBundle\Entity\AccompanyingCourseDocument> */ class AccompanyingCourseDocumentRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillDocStoreBundle/Repository/StoredObjectPointInTimeRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/StoredObjectPointInTimeRepository.php index c5c923ac9..e523ef8d5 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/StoredObjectPointInTimeRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/StoredObjectPointInTimeRepository.php @@ -17,6 +17,8 @@ use Doctrine\Persistence\ManagerRegistry; /** * @template-extends ServiceEntityRepository + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\DocStoreBundle\Entity\StoredObjectPointInTime> */ class StoredObjectPointInTimeRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AsyncUploadVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AsyncUploadVoter.php index a0489cb77..83f5fc1f1 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AsyncUploadVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AsyncUploadVoter.php @@ -31,7 +31,7 @@ final class AsyncUploadVoter extends Voter return self::GENERATE_SIGNATURE === $attribute && $subject instanceof SignedUrl; } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { /** @var SignedUrl $subject */ if (!in_array($subject->method, ['POST', 'GET', 'HEAD', 'PUT'], true)) { diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php index 582954bd5..b74626cd2 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php @@ -41,7 +41,7 @@ class StoredObjectVoter extends Voter && $subject instanceof StoredObject; } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { /** @var StoredObject $subject */ $attributeAsEnum = StoredObjectRoleEnum::from($attribute); diff --git a/src/Bundle/ChillEventBundle/Export/Export/ListEvents.php b/src/Bundle/ChillEventBundle/Export/Export/ListEvents.php index 7065e87c7..ea5e14f32 100644 --- a/src/Bundle/ChillEventBundle/Export/Export/ListEvents.php +++ b/src/Bundle/ChillEventBundle/Export/Export/ListEvents.php @@ -77,15 +77,13 @@ class ListEvents implements ListInterface, GroupedExportInterface 'expanded' => true, 'choices' => array_combine($this->fields, $this->fields), 'label' => 'Fields to include in export', - 'constraints' => [new Callback([ - 'callback' => static function ($selected, ExecutionContextInterface $context) { - if (0 === \count($selected)) { - $context->buildViolation('You must select at least one element') - ->atPath('fields') - ->addViolation(); - } - }, - ])], + 'constraints' => [new Callback(callback: static function ($selected, ExecutionContextInterface $context) { + if (0 === \count($selected)) { + $context->buildViolation('You must select at least one element') + ->atPath('fields') + ->addViolation(); + } + })], ]); } diff --git a/src/Bundle/ChillEventBundle/Repository/ParticipationRepository.php b/src/Bundle/ChillEventBundle/Repository/ParticipationRepository.php index 8d348e056..a9216040f 100644 --- a/src/Bundle/ChillEventBundle/Repository/ParticipationRepository.php +++ b/src/Bundle/ChillEventBundle/Repository/ParticipationRepository.php @@ -17,6 +17,8 @@ use Doctrine\Persistence\ManagerRegistry; /** * Class ParticipationRepository. + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\EventBundle\Entity\Participation> */ class ParticipationRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillEventBundle/Repository/StatusRepository.php b/src/Bundle/ChillEventBundle/Repository/StatusRepository.php index 644281bdb..c8da57326 100644 --- a/src/Bundle/ChillEventBundle/Repository/StatusRepository.php +++ b/src/Bundle/ChillEventBundle/Repository/StatusRepository.php @@ -15,6 +15,9 @@ use Chill\EventBundle\Entity\Status; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; +/** + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\EventBundle\Entity\Status> + */ class StatusRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) diff --git a/src/Bundle/ChillJobBundle/src/Export/ListCV.php b/src/Bundle/ChillJobBundle/src/Export/ListCV.php index 431f475e3..b09e957f9 100644 --- a/src/Bundle/ChillJobBundle/src/Export/ListCV.php +++ b/src/Bundle/ChillJobBundle/src/Export/ListCV.php @@ -99,16 +99,14 @@ class ListCV implements ListInterface, ExportElementValidatedInterface 'data' => array_combine($this->getFields(), $this->getFields()), 'choice_attr' => [], 'attr' => ['class' => ''], - 'constraints' => [new Callback([ - 'callback' => function ($selected, ExecutionContextInterface $context) { - if (0 === count($selected)) { - $context - ->buildViolation('You must select at least one element') - ->atPath('fields') - ->addViolation(); - } - }, - ])], + 'constraints' => [new Callback(callback: function ($selected, ExecutionContextInterface $context) { + if (0 === count($selected)) { + $context + ->buildViolation('You must select at least one element') + ->atPath('fields') + ->addViolation(); + } + })], ]) ->add('reportdate_min', ChillDateType::class, [ 'label' => 'Date du rapport après le', diff --git a/src/Bundle/ChillJobBundle/src/Export/ListFrein.php b/src/Bundle/ChillJobBundle/src/Export/ListFrein.php index 4e443715f..dd3125619 100644 --- a/src/Bundle/ChillJobBundle/src/Export/ListFrein.php +++ b/src/Bundle/ChillJobBundle/src/Export/ListFrein.php @@ -112,16 +112,14 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface 'data' => array_combine($this->getFields(), $this->getFields()), 'choice_attr' => [], 'attr' => ['class' => ''], - 'constraints' => [new Callback([ - 'callback' => function ($selected, ExecutionContextInterface $context) { - if (0 === count($selected)) { - $context - ->buildViolation('You must select at least one element') - ->atPath('fields') - ->addViolation(); - } - }, - ])], + 'constraints' => [new Callback(callback: function ($selected, ExecutionContextInterface $context) { + if (0 === count($selected)) { + $context + ->buildViolation('You must select at least one element') + ->atPath('fields') + ->addViolation(); + } + })], ]) ->add('reportdate_min', ChillDateType::class, [ 'label' => 'Date du rapport après le', diff --git a/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php b/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php index 1e2e81411..19f926789 100644 --- a/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php +++ b/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php @@ -118,16 +118,14 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn 'data' => array_combine($this->getFields(), $this->getFields()), 'choice_attr' => [], 'attr' => ['class' => ''], - 'constraints' => [new Callback([ - 'callback' => function ($selected, ExecutionContextInterface $context) { - if (0 === count($selected)) { - $context - ->buildViolation('You must select at least one element') - ->atPath('fields') - ->addViolation(); - } - }, - ])], + 'constraints' => [new Callback(callback: function ($selected, ExecutionContextInterface $context) { + if (0 === count($selected)) { + $context + ->buildViolation('You must select at least one element') + ->atPath('fields') + ->addViolation(); + } + })], ]) ->add('reportdate_min', ChillDateType::class, [ 'label' => 'Date du rapport après le', diff --git a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php index ee313a000..d526800eb 100644 --- a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php @@ -21,7 +21,6 @@ use League\Csv\Reader; use League\Csv\Writer; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -30,8 +29,10 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; -#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:main:import-users')] -class ChillImportUsersCommand extends Command +#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:main:import-users', help: <<<'TXT' +Import users from a csv file. Users are added to centers contained in the file. Headers are used to detect columns. Adding to multiple centers can be done by using a `grouping centers` file, which will group multiple centers into a signle alias, used in 'centers' column. +TXT)] +class ChillImportUsersCommand { protected static $defaultDescription = 'Import users from csv file'; /** @@ -60,7 +61,6 @@ class ChillImportUsersCommand extends Command protected ValidatorInterface $validator, protected UserRepository $userRepository, ) { - parent::__construct('chill:main:import-users'); } protected function appendUserToFile(User $user) @@ -84,16 +84,6 @@ class ChillImportUsersCommand extends Command return \implode(';', $str); } - protected function configure() - { - $this - ->setHelp("Import users from a csv file. Users are added to centers contained in the file. Headers are used to detect columns. Adding to multiple centers can be done by using a `grouping centers` file, which will group multiple centers into a signle alias, used in 'centers' column.") - ->addArgument('csvfile', InputArgument::REQUIRED, 'Path to the csv file. Columns are: `username`, `email`, `center` (can contain alias), `permission group`') - ->addOption('grouping-centers', null, InputOption::VALUE_OPTIONAL, 'Path to a csv file to aggregate multiple centers into a single alias') - ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Do not commit the changes') - ->addOption('csv-dump', null, InputOption::VALUE_REQUIRED, 'A path to dump a summary of the created file'); - } - protected function createOrGetGroupCenter(Center $center, PermissionsGroup $pg): GroupCenter { if (\array_key_exists($center->getId(), $this->groupCenters)) { @@ -186,12 +176,16 @@ class ChillImportUsersCommand extends Command return false; } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'csvfile', description: 'Path to the csv file. Columns are: `username`, `email`, `center` (can contain alias), `permission group`')] + string $csvfile, #[\Symfony\Component\Console\Attribute\Option(name: 'grouping-centers', mode: InputOption::VALUE_OPTIONAL, description: 'Path to a csv file to aggregate multiple centers into a single alias')] + $groupingCenters, #[\Symfony\Component\Console\Attribute\Option(name: 'dry-run', mode: InputOption::VALUE_NONE, description: 'Do not commit the changes')] + bool $dryRun = false, #[\Symfony\Component\Console\Attribute\Option(name: 'csv-dump', mode: InputOption::VALUE_REQUIRED, description: 'A path to dump a summary of the created file')] + $csvDump, OutputInterface $output): int { $this->tempOutput = $output; $this->tempInput = $input; - if ($input->getOption('dry-run')) { + if ($dry_run) { $this->doChanges = false; } diff --git a/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php b/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php index eb3392bda..bb8f01d91 100644 --- a/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php @@ -18,7 +18,6 @@ use Doctrine\ORM\EntityManagerInterface; use League\Csv\Reader; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -28,7 +27,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; * Class ChillUserSendRenewPasswordCodeCommand. */ #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:user:send-password-recover-code')] -class ChillUserSendRenewPasswordCodeCommand extends Command +class ChillUserSendRenewPasswordCodeCommand { protected static $defaultDescription = 'Send a message with code to recover password'; /** @@ -77,19 +76,13 @@ class ChillUserSendRenewPasswordCodeCommand extends Command $this->recoverPasswordHelper = $recoverPasswordHelper; $this->eventDispatcher = $eventDispatcher; - parent::__construct(); } - protected function configure() - { - $this - ->addArgument('csvfile', InputArgument::REQUIRED, 'CSV file with the list of users') - ->addOption('template', null, InputOption::VALUE_REQUIRED, 'Template for email') - ->addOption('expiration', null, InputOption::VALUE_REQUIRED, 'Expiration of the link, as an unix timestamp') - ->addOption('subject', null, InputOption::VALUE_REQUIRED, 'Subject of the email', 'Recover your password'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'csvfile', description: 'CSV file with the list of users')] + string $csvfile, #[\Symfony\Component\Console\Attribute\Option(name: 'template', mode: InputOption::VALUE_REQUIRED, description: 'Template for email')] + $template, #[\Symfony\Component\Console\Attribute\Option(name: 'expiration', mode: InputOption::VALUE_REQUIRED, description: 'Expiration of the link, as an unix timestamp')] + $expiration, #[\Symfony\Component\Console\Attribute\Option(name: 'subject', mode: InputOption::VALUE_REQUIRED, description: 'Subject of the email')] + string $subject = 'Recover your password', OutputInterface $output): int { $this->input = $input; $this->output = $output; diff --git a/src/Bundle/ChillMainBundle/Command/DumpListPermissionsCommand.php b/src/Bundle/ChillMainBundle/Command/DumpListPermissionsCommand.php index cd5510eb3..914287fa4 100644 --- a/src/Bundle/ChillMainBundle/Command/DumpListPermissionsCommand.php +++ b/src/Bundle/ChillMainBundle/Command/DumpListPermissionsCommand.php @@ -14,18 +14,16 @@ namespace Chill\MainBundle\Command; use Chill\MainBundle\Security\RoleDumper; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand(name: 'chill:main:dump-list-permissions', description: 'Print a markdown reference of permissions (roles) grouped by title with dependencies).')] -final class DumpListPermissionsCommand extends Command +final class DumpListPermissionsCommand { public function __construct(private readonly RoleDumper $roleDumper) { - parent::__construct(); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $markdown = $this->roleDumper->dumpAsMarkdown(); $output->writeln($markdown); diff --git a/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php b/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php index 01b11e94b..b8ad311e9 100644 --- a/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php @@ -14,37 +14,37 @@ namespace Chill\MainBundle\Command; use Chill\MainBundle\Cron\CronManagerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:cron-job:execute')] -class ExecuteCronJobCommand extends Command +#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:cron-job:execute', help: <<<'TXT' +If no job is specified, the next available cronjob will be executed by system. +This command should be execute every 15 minutes (more or less) +TXT)] +class ExecuteCronJobCommand { protected static $defaultDescription = 'Execute the cronjob(s) given as argument, or one cronjob scheduled by system.'; public function __construct( private readonly CronManagerInterface $cronManager, ) { - parent::__construct('chill:cron-job:execute'); } protected function configure() { $this - ->setHelp("If no job is specified, the next available cronjob will be executed by system.\nThis command should be execute every 15 minutes (more or less)") ->addArgument('job', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'one or more job to force execute (by default, all jobs are executed)', []) ->addUsage(''); } - protected function execute(InputInterface $input, OutputInterface $output): int - { - if ([] === $input->getArgument('job')) { + public function __invoke( + #[\Symfony\Component\Console\Attribute\Argument(name: 'job', description: 'one or more job to force execute (by default, all jobs are executed)')] + array $job = [], + ): int { + if ([] === $job) { $this->cronManager->run(); return Command::SUCCESS; } - - foreach ($input->getArgument('job') as $jobName) { + foreach ($job as $jobName) { $this->cronManager->run($jobName); } diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php index 79d5de2cb..26ecab06c 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php @@ -14,13 +14,10 @@ namespace Chill\MainBundle\Command; use Chill\MainBundle\Service\Import\AddressReferenceBEFromBestAddress; use Chill\MainBundle\Service\Import\PostalCodeBEFromBestAddress; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-from-best-addresses')] -class LoadAddressesBEFromBestAddressCommand extends Command +class LoadAddressesBEFromBestAddressCommand { protected static $defaultDescription = 'Import BE addresses from BeST Address (see https://osoc19.github.io/best/)'; @@ -28,25 +25,21 @@ class LoadAddressesBEFromBestAddressCommand extends Command private readonly AddressReferenceBEFromBestAddress $addressImporter, private readonly PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter, ) { - parent::__construct(); } - protected function configure() - { - $this - ->addArgument('lang', InputArgument::REQUIRED, "Language code, for example 'fr'") - ->addArgument('list', InputArgument::IS_ARRAY, "The list to add, for example 'full', or 'extract' (dev) or '1xxx' (brussel CP)") - ->addOption('send-report-email', 's', InputOption::VALUE_REQUIRED, 'Email address where a list of unimported addresses can be send'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { + public function __invoke( + #[\Symfony\Component\Console\Attribute\Argument(name: 'lang', description: "Language code, for example 'fr'")] + string $lang, + #[\Symfony\Component\Console\Attribute\Argument(name: 'list', description: "The list to add, for example 'full', or 'extract' (dev) or '1xxx' (brussel CP)")] + array $list, + #[\Symfony\Component\Console\Attribute\Option(name: 'send-report-email', shortcut: 's', mode: InputOption::VALUE_REQUIRED, description: 'Email address where a list of unimported addresses can be send')] + $sendReportEmail, + ): int { $this->postalCodeBEFromBestAddressImporter->import(); - $this->addressImporter->import( - $input->getArgument('lang'), - $input->getArgument('list'), - $input->hasOption('send-report-email') ? $input->getOption('send-report-email') : null + $lang, + $list, + $input->hasOption('send-report-email') ? $send_report_email : null ); return Command::SUCCESS; diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANCommand.php index 1bb1082b6..d5d93964d 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANCommand.php @@ -13,35 +13,27 @@ namespace Chill\MainBundle\Command; use Chill\MainBundle\Service\Import\AddressReferenceFromBAN; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-from-ban')] -class LoadAddressesFRFromBANCommand extends Command +class LoadAddressesFRFromBANCommand { protected static $defaultDescription = 'Import FR addresses from BAN (see https://adresses.data.gouv.fr'; public function __construct(private readonly AddressReferenceFromBAN $addressReferenceFromBAN) { - parent::__construct(); } - protected function configure() - { - $this - ->addArgument('departementNo', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'a list of departement numbers') - ->addOption('send-report-email', 's', InputOption::VALUE_REQUIRED, 'Email address where a list of unimported addresses can be send'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'departementNo', description: 'a list of departement numbers')] + array $departementno, #[\Symfony\Component\Console\Attribute\Option(name: 'send-report-email', shortcut: 's', mode: InputOption::VALUE_REQUIRED, description: 'Email address where a list of unimported addresses can be send')] + $sendReportEmail, OutputInterface $output): int { dump(__METHOD__); - foreach ($input->getArgument('departementNo') as $departementNo) { + foreach ($departementNo as $departementNo) { $output->writeln('Import addresses for '.$departementNo); - $this->addressReferenceFromBAN->import($departementNo, $input->hasOption('send-report-email') ? $input->getOption('send-report-email') : null); + $this->addressReferenceFromBAN->import($departementNo, $input->hasOption('send-report-email') ? $send_report_email : null); } return Command::SUCCESS; diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php index e81be9431..1401c97c9 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php @@ -13,34 +13,26 @@ namespace Chill\MainBundle\Command; use Chill\MainBundle\Service\Import\AddressReferenceFromBano; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-from-bano')] -class LoadAddressesFRFromBANOCommand extends Command +class LoadAddressesFRFromBANOCommand { protected static $defaultDescription = 'Import FR addresses from bano (see https://bano.openstreetmap.fr'; public function __construct(private readonly AddressReferenceFromBano $addressReferenceFromBano) { - parent::__construct(); } - protected function configure() + public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'departementNo', description: 'a list of departement numbers')] + array $departementno, #[\Symfony\Component\Console\Attribute\Option(name: 'send-report-email', shortcut: 's', mode: InputOption::VALUE_REQUIRED, description: 'Email address where a list of unimported addresses can be send')] + $sendReportEmail, OutputInterface $output): int { - $this - ->addArgument('departementNo', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'a list of departement numbers') - ->addOption('send-report-email', 's', InputOption::VALUE_REQUIRED, 'Email address where a list of unimported addresses can be send'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - foreach ($input->getArgument('departementNo') as $departementNo) { + foreach ($departementNo as $departementNo) { $output->writeln('Import addresses for '.$departementNo); - $this->addressReferenceFromBano->import($departementNo, $input->hasOption('send-report-email') ? $input->getOption('send-report-email') : null); + $this->addressReferenceFromBano->import($departementNo, $input->hasOption('send-report-email') ? $send_report_email : null); } return Command::SUCCESS; diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesLUFromBDAddressCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesLUFromBDAddressCommand.php index d8d3035a9..cc571a577 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesLUFromBDAddressCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesLUFromBDAddressCommand.php @@ -13,31 +13,24 @@ namespace Chill\MainBundle\Command; use Chill\MainBundle\Service\Import\AddressReferenceLU; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-lux')] -class LoadAddressesLUFromBDAddressCommand extends Command +class LoadAddressesLUFromBDAddressCommand { protected static $defaultDescription = 'Import LUX addresses from BD addresses (see https://data.public.lu/fr/datasets/adresses-georeferencees-bd-adresses/)'; public function __construct( private readonly AddressReferenceLU $addressImporter, ) { - parent::__construct(); } - protected function configure() - { - $this - ->addOption('send-report-email', 's', InputOption::VALUE_REQUIRED, 'Email address where a list of unimported addresses can be send'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { + public function __invoke( + #[\Symfony\Component\Console\Attribute\Option(name: 'send-report-email', shortcut: 's', mode: InputOption::VALUE_REQUIRED, description: 'Email address where a list of unimported addresses can be send')] + $sendReportEmail, + ): int { $this->addressImporter->import( - $input->hasOption('send-report-email') ? $input->getOption('send-report-email') : null, + $input->hasOption('send-report-email') ? $send_report_email : null, ); return Command::SUCCESS; diff --git a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php index 3dc5bbdb3..cb4d6f3a2 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php @@ -14,9 +14,7 @@ namespace Chill\MainBundle\Command; use Chill\MainBundle\Entity\Language; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Intl\Languages; @@ -24,7 +22,7 @@ use Symfony\Component\Intl\Languages; * Load or update the languages entities command */ #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:languages:populate')] -class LoadAndUpdateLanguagesCommand extends Command +class LoadAndUpdateLanguagesCommand { final public const INCLUDE_ANCIENT = 'include_ancient'; @@ -43,31 +41,6 @@ class LoadAndUpdateLanguagesCommand extends Command */ public function __construct(private readonly EntityManagerInterface $entityManager, private readonly ParameterBagInterface $parameterBag) { - parent::__construct(); - } - - /** - * (non-PHPdoc). - * - * @see \Symfony\Component\Console\Command\Command::configure() - */ - protected function configure() - { - $this - ->addOption( - self::INCLUDE_REGIONAL_VERSION, - null, - InputOption::VALUE_NONE, - 'Include the regional languages. The regional languages are languages with code containing _ excepted ' - .implode(',', $this->regionalVersionToInclude).'.' - ) - ->addOption( - self::INCLUDE_ANCIENT, - null, - InputOption::VALUE_NONE, - 'Include the ancient languages that are languages with code ' - .implode(', ', $this->ancientToExclude).'.' - ); } /** @@ -75,7 +48,11 @@ class LoadAndUpdateLanguagesCommand extends Command * * @see \Symfony\Component\Console\Command\Command::execute() */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke( + #[\Symfony\Component\Console\Attribute\Option(name: self::INCLUDE_REGIONAL_VERSION, mode: InputOption::VALUE_NONE, description: 'Include the regional languages. The regional languages are languages with code containing')] + bool $includeRegional = false, + #[\Symfony\Component\Console\Attribute\Option(name: self::INCLUDE_ANCIENT, mode: InputOption::VALUE_NONE, description: 'Include the ancient languages that are languages with code ')] + bool $includeAncient = false): int { $em = $this->entityManager; $chillAvailableLanguages = $this->parameterBag->get('chill_main.available_languages'); @@ -88,11 +65,11 @@ class LoadAndUpdateLanguagesCommand extends Command foreach (Languages::getNames() as $code => $lang) { $excludeCode = ( ( - null === $input->getOption(self::INCLUDE_REGIONAL_VERSION) + null === $include_regional && strpos($code, '_') && !\in_array($code, $this->regionalVersionToInclude, true) ) || ( - null === $input->getOption(self::INCLUDE_ANCIENT) + null === $include_ancient && \in_array($code, $this->ancientToExclude, true) ) ); diff --git a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php index c8cc69a39..3f49502e2 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php @@ -14,19 +14,16 @@ namespace Chill\MainBundle\Command; use Chill\MainBundle\Entity\Country; use Doctrine\ORM\EntityManager; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Intl\Countries; #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:countries:populate')] -class LoadCountriesCommand extends Command +class LoadCountriesCommand { /** * LoadCountriesCommand constructor. */ public function __construct(private readonly EntityManager $entityManager, private $availableLanguages) { - parent::__construct(); } public static function prepareCountryList($languages) @@ -49,23 +46,15 @@ class LoadCountriesCommand extends Command return $countryEntities; } - /** - * (non-PHPdoc). - * - * @see \Symfony\Component\Console\Command\Command::configure() - */ - protected function configure() {} - /** * (non-PHPdoc). * * @see \Symfony\Component\Console\Command\Command::execute() */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(): int { $countries = static::prepareCountryList($this->availableLanguages); $em = $this->entityManager; - foreach ($countries as $country) { $countryStored = $em->getRepository(Country::class) ->findOneBy(['countryCode' => $country->getCountryCode()]); @@ -76,7 +65,6 @@ class LoadCountriesCommand extends Command $countryStored->setName($country->getName()); } } - $em->flush(); return Command::SUCCESS; diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php index 9e71eef61..c2f833e67 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php @@ -13,22 +13,17 @@ namespace Chill\MainBundle\Command; use Chill\MainBundle\Service\Import\PostalCodeFRFromOpenData; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:postal-code:load:FR')] -class LoadPostalCodeFR extends Command +class LoadPostalCodeFR { protected static $defaultDescription = 'Load France\'s postal code from online open data'; public function __construct(private readonly PostalCodeFRFromOpenData $loader) { - parent::__construct(); } - public function configure(): void {} - - public function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(): int { $this->loader->import(); diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index 372ffb6bc..804ba12f2 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -16,7 +16,6 @@ use Chill\MainBundle\Entity\Country; use Chill\MainBundle\Entity\PostalCode; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -24,58 +23,26 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Validator\Validator\ValidatorInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:postal-code:populate')] -class LoadPostalCodesCommand extends Command +class LoadPostalCodesCommand { protected static $defaultDescription = 'Add the postal code from a csv file.'; public function __construct(private readonly EntityManagerInterface $entityManager, private readonly ValidatorInterface $validator) { - parent::__construct(); } - protected function configure() - { - $this - ->setHelp('This script will try to avoid existing postal code ' - ."using the postal code and name. \n" - .'The CSV file must have the following columns: ' - .'postal code, label, country code.' - .'Optionally, the csv file can have the following ' - .'columns after the country code: reference code, latitude, longitude, source. ' - .'The latitude and longitude columns are supposed to be in WGS84 and expressed in decimal degrees. ' - .'The CSV file should not have any header row.') - ->addArgument('csv_file', InputArgument::REQUIRED, 'the path to ' - .'the csv file. See the help for specifications.') - ->addOption( - 'delimiter', - 'd', - InputOption::VALUE_OPTIONAL, - 'The delimiter character of the csv file', - ',' - ) - ->addOption( - 'enclosure', - null, - InputOption::VALUE_OPTIONAL, - 'The enclosure character of the csv file', - '"' - ) - ->addOption( - 'escape', - null, - InputOption::VALUE_OPTIONAL, - 'The escape character of the csv file', - '\\' - ); - } - - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'csv_file', description: 'the path to ' + .'the csv file. See the help for specifications.')] + string $csvFile, #[\Symfony\Component\Console\Attribute\Option(name: 'delimiter', shortcut: 'd', mode: InputOption::VALUE_OPTIONAL, description: 'The delimiter character of the csv file')] + string $delimiter = ',', #[\Symfony\Component\Console\Attribute\Option(name: 'enclosure', mode: InputOption::VALUE_OPTIONAL, description: 'The enclosure character of the csv file')] + string $enclosure = '"', #[\Symfony\Component\Console\Attribute\Option(name: 'escape', mode: InputOption::VALUE_OPTIONAL, description: 'The escape character of the csv file')] + string $escape = '\\', OutputInterface $output): int { $csv = $this->getCSVResource($input); if (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) { $output->writeln('The content of the file is ...'); - $output->write(file_get_contents($input->getArgument('csv_file'))); + $output->write(file_get_contents($csv_file)); } $num = 0; @@ -85,9 +52,9 @@ class LoadPostalCodesCommand extends Command false !== ($row = fgetcsv( $csv, 0, - $input->getOption('delimiter'), - $input->getOption('enclosure'), - (string) $input->getOption('escape') + $delimiter, + $enclosure, + (string) $escape )) ) { try { diff --git a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php index 99d0e912b..caa881a82 100644 --- a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php +++ b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php @@ -14,8 +14,6 @@ namespace Chill\MainBundle\Command; use Chill\MainBundle\Entity\User; use Doctrine\ORM\EntityManager; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Security\Core\Encoder\EncoderFactory; @@ -23,7 +21,7 @@ use Symfony\Component\Security\Core\Encoder\EncoderFactory; * Class SetPasswordCommand. */ #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:user:set_password')] -class SetPasswordCommand extends Command +class SetPasswordCommand { protected static $defaultDescription = 'set a password to user'; @@ -32,7 +30,6 @@ class SetPasswordCommand extends Command */ public function __construct(private readonly EntityManager $entityManager) { - parent::__construct(); } public function _getUser($username): ?object @@ -55,23 +52,18 @@ class SetPasswordCommand extends Command $this->entityManager->flush(); } - public function configure(): void + public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'username', description: 'the user\'s ' + .'username you want to change password')] + string $username, #[\Symfony\Component\Console\Attribute\Argument(name: 'password', description: 'the new password')] + ?string $password, OutputInterface $output): int { - $this - ->addArgument('username', InputArgument::REQUIRED, 'the user\'s ' - .'username you want to change password') - ->addArgument('password', InputArgument::OPTIONAL, 'the new password'); - } - - public function execute(InputInterface $input, OutputInterface $output): int - { - $user = $this->_getUser($input->getArgument('username')); + $user = $this->_getUser($username); if (null === $user) { - throw new \LogicException("The user with username '".$input->getArgument('username')."' is not found"); + throw new \LogicException("The user with username '".$username."' is not found"); } - $password = $input->getArgument('password'); + $password = $password; if (null === $password) { $dialog = $this->getHelperSet()->get('dialog'); diff --git a/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php b/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php index 695e84f5b..e907b4ae1 100644 --- a/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php +++ b/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php @@ -13,23 +13,18 @@ namespace Chill\MainBundle\Command; use Chill\MainBundle\Service\EntityInfo\ViewEntityInfoManager; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:db:sync-views')] -class SynchronizeEntityInfoViewsCommand extends Command +class SynchronizeEntityInfoViewsCommand { protected static $defaultDescription = 'Update or create sql views which provide info for various entities'; public function __construct( private readonly ViewEntityInfoManager $viewEntityInfoManager, ) { - parent::__construct('chill:db:sync-views'); } - protected function configure(): void {} - - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(): int { $this->viewEntityInfoManager->synchronizeOnDB(); diff --git a/src/Bundle/ChillMainBundle/Controller/PasswordController.php b/src/Bundle/ChillMainBundle/Controller/PasswordController.php index 368bc2bc8..a8011f27f 100644 --- a/src/Bundle/ChillMainBundle/Controller/PasswordController.php +++ b/src/Bundle/ChillMainBundle/Controller/PasswordController.php @@ -243,21 +243,19 @@ final class PasswordController extends AbstractController ->add('username_or_email', TextType::class, [ 'label' => 'Username or email', 'constraints' => [ - new Callback([ - 'callback' => function ($pattern, ExecutionContextInterface $context, $payload) { - $qb = $this->managerRegistry->getManager() - ->createQueryBuilder(); - $qb->select('COUNT(u)') - ->from(User::class, 'u') - ->where($qb->expr()->eq('u.usernameCanonical', 'UNACCENT(LOWER(:pattern))')) - ->orWhere($qb->expr()->eq('u.emailCanonical', 'UNACCENT(LOWER(:pattern))')) - ->setParameter('pattern', $pattern); + new Callback(callback: function ($pattern, ExecutionContextInterface $context, $payload) { + $qb = $this->managerRegistry->getManager() + ->createQueryBuilder(); + $qb->select('COUNT(u)') + ->from(User::class, 'u') + ->where($qb->expr()->eq('u.usernameCanonical', 'UNACCENT(LOWER(:pattern))')) + ->orWhere($qb->expr()->eq('u.emailCanonical', 'UNACCENT(LOWER(:pattern))')) + ->setParameter('pattern', $pattern); - if (1 !== (int) $qb->getQuery()->getSingleScalarResult()) { - $context->addViolation('This username or email does not exists'); - } - }, - ]), + if (1 !== (int) $qb->getQuery()->getSingleScalarResult()) { + $context->addViolation('This username or email does not exists'); + } + }), ], ]) ->add('submit', SubmitType::class, [ diff --git a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php index 67ef22b18..1231a52b5 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php @@ -14,24 +14,17 @@ namespace Chill\MainBundle\Doctrine\Event; use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Entity\User; -use Doctrine\Common\EventSubscriber; use Doctrine\ORM\Event\PrePersistEventArgs; use Doctrine\ORM\Event\PreUpdateEventArgs; use Doctrine\ORM\Events; use Symfony\Bundle\SecurityBundle\Security; -class TrackCreateUpdateSubscriber implements EventSubscriber +#[\Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener(event: Events::prePersist)] +#[\Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener(event: Events::preUpdate)] +class TrackCreateUpdateSubscriber { public function __construct(private readonly Security $security) {} - public function getSubscribedEvents(): array - { - return [ - Events::prePersist, - Events::preUpdate, - ]; - } - public function prePersist(PrePersistEventArgs $args): void { $object = $args->getObject(); diff --git a/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php b/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php index 352585d1c..143eedb5f 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php @@ -60,9 +60,7 @@ class DateIntervalType extends AbstractType 'step' => 1, ], 'constraints' => [ - new GreaterThan([ - 'value' => 0, - ]), + new GreaterThan(value: 0), ], ]) ->add('unit', ChoiceType::class, [ diff --git a/src/Bundle/ChillMainBundle/Form/UserPasswordType.php b/src/Bundle/ChillMainBundle/Form/UserPasswordType.php index a3fffaee5..112567f29 100644 --- a/src/Bundle/ChillMainBundle/Form/UserPasswordType.php +++ b/src/Bundle/ChillMainBundle/Form/UserPasswordType.php @@ -58,37 +58,29 @@ class UserPasswordType extends AbstractType ], 'invalid_message' => 'The password fields must match', 'constraints' => [ - new Length([ - 'min' => 14, - 'minMessage' => 'The password must be greater than {{ limit }} characters', - ]), + new Length(min: 14, minMessage: 'The password must be greater than {{ limit }} characters'), new NotBlank(), - new Regex([ - 'pattern' => "/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!,;:+\"'-\\/{}~=µ\\(\\)£]).{6,})/", - 'message' => 'The password must contains one letter, one ' - .'capitalized letter, one number and one special character ' - ."as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed.", - ]), + new Regex(pattern: "/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!,;:+\"'-\\/{}~=µ\\(\\)£]).{6,})/", message: 'The password must contains one letter, one ' + .'capitalized letter, one number and one special character ' + ."as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed."), ], ]) ->add('actual_password', PasswordType::class, [ 'label' => 'Your actual password', 'mapped' => false, 'constraints' => [ - new Callback([ - 'callback' => function ($password, ExecutionContextInterface $context, $payload) use ($options) { - if (true === $this->passwordEncoder->isPasswordValid($options['user'], $password)) { - return; - } + new Callback(callback: function ($password, ExecutionContextInterface $context, $payload) use ($options) { + if (true === $this->passwordEncoder->isPasswordValid($options['user'], $password)) { + return; + } - // password problem :-) - $this->chillLogger - ->notice('incorrect password when trying to change password', [ - 'username' => $options['user']->getUsername(), - ]); - $context->addViolation('Incorrect password'); - }, - ]), + // password problem :-) + $this->chillLogger + ->notice('incorrect password when trying to change password', [ + 'username' => $options['user']->getUsername(), + ]); + $context->addViolation('Incorrect password'); + }), ], ]); } diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index 52ac34150..988353006 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -127,17 +127,11 @@ class UserType extends AbstractType ], 'invalid_message' => 'The password fields must match', 'constraints' => [ - new Length([ - 'min' => 9, - 'minMessage' => 'The password must be greater than {{ limit }} characters', - ]), + new Length(min: 9, minMessage: 'The password must be greater than {{ limit }} characters'), new NotBlank(), - new Regex([ - 'pattern' => "/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!,;:+\"'-\\/{}~=µ\\(\\)£]).{6,})/", - 'message' => 'The password must contains one letter, one ' - .'capitalized letter, one number and one special character ' - ."as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed.", - ]), + new Regex(pattern: "/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!,;:+\"'-\\/{}~=µ\\(\\)£]).{6,})/", message: 'The password must contains one letter, one ' + .'capitalized letter, one number and one special character ' + ."as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed."), ], ]); } else { diff --git a/src/Bundle/ChillMainBundle/Phonenumber/Templating.php b/src/Bundle/ChillMainBundle/Phonenumber/Templating.php index 51d57c9e9..c41b762e9 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/Templating.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/Templating.php @@ -11,22 +11,13 @@ declare(strict_types=1); namespace Chill\MainBundle\Phonenumber; -use Twig\Extension\AbstractExtension; -use Twig\TwigFilter; - -class Templating extends AbstractExtension +class Templating { public function __construct(protected PhonenumberHelper $phonenumberHelper) {} + #[\Twig\Attribute\AsTwigFilter('chill_format_phonenumber')] public function formatPhonenumber($phonenumber) { return $this->phonenumberHelper->format($phonenumber) ?? $phonenumber; } - - public function getFilters() - { - return [ - new TwigFilter('chill_format_phonenumber', $this->formatPhonenumber(...)), - ]; - } } diff --git a/src/Bundle/ChillMainBundle/Repository/LocationRepository.php b/src/Bundle/ChillMainBundle/Repository/LocationRepository.php index 55b6b0117..95388fe5f 100644 --- a/src/Bundle/ChillMainBundle/Repository/LocationRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/LocationRepository.php @@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry; * @method Location|null findOneBy(array $criteria, array $orderBy = null) * @method Location[] findAll() * @method Location[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\MainBundle\Entity\Location> */ class LocationRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillMainBundle/Repository/LocationTypeRepository.php b/src/Bundle/ChillMainBundle/Repository/LocationTypeRepository.php index 9fe29980f..3ed815188 100644 --- a/src/Bundle/ChillMainBundle/Repository/LocationTypeRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/LocationTypeRepository.php @@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry; * @method LocationType|null findOneBy(array $criteria, array $orderBy = null) * @method LocationType[] findAll() * @method LocationType[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\MainBundle\Entity\LocationType> */ class LocationTypeRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepHoldRepository.php b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepHoldRepository.php index a925246e4..132a1c1eb 100644 --- a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepHoldRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepHoldRepository.php @@ -21,6 +21,8 @@ use Doctrine\Persistence\ManagerRegistry; /** * @template-extends ServiceEntityRepository + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\MainBundle\Entity\Workflow\EntityWorkflowStepHold> */ class EntityWorkflowStepHoldRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepSignatureRepository.php b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepSignatureRepository.php index 8bd3de586..2d00762fe 100644 --- a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepSignatureRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepSignatureRepository.php @@ -18,6 +18,8 @@ use Doctrine\Persistence\ManagerRegistry; /** * @template-extends ServiceEntityRepository + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature> */ class EntityWorkflowStepSignatureRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php index 4e6719d0c..a1d155f06 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php @@ -42,7 +42,7 @@ class ChillExportVoter extends Voter implements ProvideRoleHierarchyInterface return $this->helper->supports($attribute, $subject); } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { return $this->helper->voteOnAttribute($attribute, $subject, $token); } diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowAttachmentVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowAttachmentVoter.php index dfdb92a65..d05fa4ba2 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowAttachmentVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowAttachmentVoter.php @@ -28,7 +28,7 @@ final class EntityWorkflowAttachmentVoter extends Voter return $subject instanceof EntityWorkflow && self::EDIT === $attribute; } - protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { if (!$subject instanceof EntityWorkflow) { throw new \UnexpectedValueException('Subject must be an instance of EntityWorkflow'); diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowStepSignatureVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowStepSignatureVoter.php index e0e90843c..9a4e7cbc5 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowStepSignatureVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowStepSignatureVoter.php @@ -30,7 +30,7 @@ final class EntityWorkflowStepSignatureVoter extends Voter && in_array($attribute, [self::SIGN, self::CANCEL, self::REJECT], true); } - protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { /** @var EntityWorkflowStepSignature $subject */ if ($subject->getSigner() instanceof Person) { diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowTransitionVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowTransitionVoter.php index 2c89f563a..748d6c52e 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowTransitionVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowTransitionVoter.php @@ -59,7 +59,7 @@ final class EntityWorkflowTransitionVoter extends Voter implements ProvideRoleHi return self::APPLY_ALL_TRANSITIONS === $attribute && ($subject instanceof EntityWorkflowStep || $subject instanceof EntityWorkflow); } - protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { /** @var EntityWorkflowStep|EntityWorkflow $subject */ $entityWorkflow = $subject instanceof EntityWorkflowStep ? $subject->getEntityWorkflow() : $subject; diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php index e42742dbf..d80175142 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php @@ -44,7 +44,7 @@ class EntityWorkflowVoter extends Voter /** * @param EntityWorkflow $subject */ - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { switch ($attribute) { case self::CREATE: diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/ExportGenerationVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/ExportGenerationVoter.php index 9457d35fc..6fba3492b 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/ExportGenerationVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/ExportGenerationVoter.php @@ -24,7 +24,7 @@ class ExportGenerationVoter extends Voter return self::VIEW === $attribute && $subject instanceof ExportGeneration; } - protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { /* @var ExportGeneration $subject */ return $token->getUser()->getUserIdentifier() === $subject->getCreatedBy()->getUserIdentifier(); diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/NotificationVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/NotificationVoter.php index 9cca4c019..0da00bff6 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/NotificationVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/NotificationVoter.php @@ -42,7 +42,7 @@ final class NotificationVoter extends Voter /** * @param string $attribute */ - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { $user = $token->getUser(); diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php index ec749f725..19b75b4d5 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php @@ -48,7 +48,7 @@ final class SavedExportVoter extends Voter return $subject instanceof SavedExport && \in_array($attribute, self::ALL, true); } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { /* @var SavedExport $subject */ $user = $token->getUser(); diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/UserGroupVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/UserGroupVoter.php index e6b5fee8c..2e5cafebf 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/UserGroupVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/UserGroupVoter.php @@ -28,7 +28,7 @@ final class UserGroupVoter extends Voter return self::APPEND_TO_GROUP === $attribute && $subject instanceof UserGroup; } - protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { /* @var UserGroup $subject */ if ($this->security->isGranted('ROLE_ADMIN')) { diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php index 72ee949dd..ae44bd242 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php @@ -39,7 +39,7 @@ class WorkflowEntityDeletionVoter extends Voter return false; } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { foreach ($this->handlers as $handler) { if ($handler->isObjectSupported($subject)) { diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php index ab847aa5e..47e5fe328 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php @@ -52,7 +52,7 @@ class PasswordRecoverVoter extends Voter return true; } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { switch ($attribute) { case self::TRY_TOKEN: diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php b/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php index e4e80a79d..ab758e318 100644 --- a/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php +++ b/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php @@ -11,21 +11,11 @@ declare(strict_types=1); namespace Chill\MainBundle\Security\Resolver; -use Twig\TwigFilter; - -final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension +final class ResolverTwigExtension { public function __construct(private readonly CenterResolverManagerInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher) {} - public function getFilters() - { - return [ - new TwigFilter('chill_resolve_center', $this->resolveCenter(...)), - new TwigFilter('chill_resolve_scope', $this->resolveScope(...)), - new TwigFilter('chill_is_scope_concerned', $this->isScopeConcerned(...)), - ]; - } - + #[\Twig\Attribute\AsTwigFilter('chill_is_scope_concerned')] public function isScopeConcerned($entity, ?array $options = []): bool { return $this->scopeResolverDispatcher->isConcerned($entity, $options); @@ -34,6 +24,7 @@ final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension /** * @return Center|Center[]|null */ + #[\Twig\Attribute\AsTwigFilter('chill_resolve_center')] public function resolveCenter(mixed $entity, ?array $options = []): array { return $this->centerResolverDispatcher->resolveCenters($entity, $options); @@ -42,6 +33,7 @@ final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension /** * @return array|\Chill\MainBundle\Entity\Scope|\Chill\MainBundle\Entity\Scope[] */ + #[\Twig\Attribute\AsTwigFilter('chill_resolve_scope')] public function resolveScope($entity, ?array $options = []): array|\Chill\MainBundle\Entity\Scope { return $this->scopeResolverDispatcher->resolveScope(); diff --git a/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php b/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php index 7404dc3be..b6a193221 100644 --- a/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php @@ -13,9 +13,7 @@ namespace Chill\MainBundle\Templating; use Symfony\Bridge\Twig\Extension\RoutingExtension; use Symfony\Component\HttpFoundation\RequestStack; -use Twig\Extension\AbstractExtension; use Twig\Node\Node; -use Twig\TwigFilter; use Twig\TwigFunction; /** @@ -23,7 +21,7 @@ use Twig\TwigFunction; * * The logic of the function is based on the original routing extension. */ -class ChillTwigRoutingHelper extends AbstractExtension +class ChillTwigRoutingHelper { /** * @var RoutingExtension @@ -43,13 +41,6 @@ class ChillTwigRoutingHelper extends AbstractExtension $this->originalExtension = $originalExtension; } - public function getFilters() - { - return [ - new TwigFilter('chill_return_path_label', $this->getLabelReturnPath(...)), - ]; - } - public function getFunctions() { return [ @@ -82,6 +73,7 @@ class ChillTwigRoutingHelper extends AbstractExtension return $this->originalExtension->getPath($name, $params, $relative); } + #[\Twig\Attribute\AsTwigFilter('chill_return_path_label')] public function getLabelReturnPath($default) { $request = $this->requestStack->getCurrentRequest(); diff --git a/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php b/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php index 0ec9f7afb..1f5443255 100644 --- a/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php +++ b/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php @@ -12,31 +12,15 @@ declare(strict_types=1); namespace Chill\MainBundle\Templating; use Twig\Extension\AbstractExtension; -use Twig\TwigFilter; +use Twig\Extension\ExtensionInterface; -class TranslatableStringTwig extends AbstractExtension +class TranslatableStringTwig { /** * TranslatableStringTwig constructor. */ public function __construct(private readonly TranslatableStringHelper $helper) {} - /** - * Returns a list of filters to add to the existing list. - * - * (non-PHPdoc) - * - * @see Twig_Extension::getFilters() - */ - public function getFilters() - { - return [ - new TwigFilter( - 'localize_translatable_string', - $this->localize(...) - ), ]; - } - /** * Returns the name of the extension. */ @@ -45,6 +29,7 @@ class TranslatableStringTwig extends AbstractExtension return 'chill_main_localize'; } + #[\Twig\Attribute\AsTwigFilter('localize_translatable_string')] public function localize(array $translatableStrings): ?string { return $this->helper diff --git a/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php b/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php index 07cd71f61..57a282ea7 100644 --- a/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php +++ b/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php @@ -31,7 +31,6 @@ final class ChillPersonMoveCommand extends Command private readonly EntityManagerInterface $em, private readonly LoggerInterface $chillLogger, ) { - parent::__construct('chill:person:move'); } protected function buildLoggingContext(Person $from, Person $to, $deleteEntities, $sqls) diff --git a/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php index 98182abda..cc35c317f 100644 --- a/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php +++ b/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php @@ -14,39 +14,32 @@ namespace Chill\PersonBundle\Command; use Chill\PersonBundle\Service\Import\SocialWorkMetadataInterface; use Doctrine\ORM\EntityManagerInterface; use League\Csv\Reader; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:person:import-socialwork')] -final class ImportSocialWorkMetadata extends Command +final class ImportSocialWorkMetadata { - protected EntityManagerInterface $em; + private EntityManagerInterface $em; public function __construct( - protected SocialWorkMetadataInterface $importer, + private SocialWorkMetadataInterface $importer, ) { - parent::__construct('chill:person:import-socialwork'); } - protected function configure(): void + private function configure(): void { $description = 'Imports a structured table containing social issues, social actions, objectives, results and evaluations.'; $help = 'File to csv format, no headers, semi-colon as delimiter, datas sorted by alphabetical order, column after column.'.PHP_EOL .'Columns are: social issues parent, social issues child, social actions parent, social actions child, goals, results, evaluations.'.PHP_EOL .PHP_EOL .'See social_work_metadata.csv as example.'.PHP_EOL; - - $this - ->addOption('filepath', 'f', InputOption::VALUE_REQUIRED, 'The file to import.') - ->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'The default language') - ->setHelp($help); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Option(name: 'filepath', shortcut: 'f', mode: InputOption::VALUE_REQUIRED, description: 'The file to import.')] + $filepath, #[\Symfony\Component\Console\Attribute\Option(name: 'language', shortcut: 'l', mode: InputOption::VALUE_OPTIONAL, description: 'The default language')] + $language): int { - $filepath = $input->getOption('filepath'); + $filepath = $filepath; try { $csv = Reader::from($filepath); diff --git a/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php b/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php index eb1d8e001..211f52d3b 100644 --- a/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php +++ b/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php @@ -14,42 +14,31 @@ namespace Chill\PersonBundle\Command; use Chill\PersonBundle\Service\AccompanyingPeriod\OldDraftAccompanyingPeriodRemoverInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:person:remove-old-draft-period')] -class RemoveOldDraftAccompanyingPeriodCommand extends Command +class RemoveOldDraftAccompanyingPeriodCommand { protected static $defaultDescription = 'Remove draft accompanying period which are still draft and unused'; public function __construct(private readonly LoggerInterface $logger, private readonly OldDraftAccompanyingPeriodRemoverInterface $remover) { - parent::__construct('chill:person:remove-old-draft-period'); } - protected function configure(): void - { - $this - ->addArgument('interval', InputArgument::OPTIONAL, 'The interval for unactive periods', 'P15D'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { + public function __invoke( + #[\Symfony\Component\Console\Attribute\Argument(name: 'interval', description: 'The interval for unactive periods')] + ?string $interval = 'P15D', + ): int { $this->logger->info('['.$this->getName().'] started', [ - 'interval' => $input->getArgument('interval'), + 'interval' => $interval, ]); - try { - $interval = new \DateInterval($input->getArgument('interval')); + $interval = new \DateInterval($interval); } catch (\Exception $e) { $this->logger->error('['.$this->getName().'] bad interval'); throw $e; } - $this->remover->remove($interval); - $this->logger->info('['.$this->getName().'] end of command'); return Command::SUCCESS; diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 7c4e6f443..158c10a82 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -148,7 +148,7 @@ class ReassignAccompanyingPeriodController extends AbstractController $builder = $this->formFactory->createNamedBuilder('reassign', FormType::class, $defaultData); if (null !== $userFrom) { - $constraints = [new NotIdenticalTo(['value' => $userFrom])]; + $constraints = [new NotIdenticalTo(value: $userFrom)]; } else { $constraints = []; } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php index 6110f8bb0..2537a55b0 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php @@ -99,11 +99,7 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository ) ) ) - ->setParameters([ - 'user' => $user, - 'now' => new \DateTimeImmutable('now'), - 'closed' => AccompanyingPeriod::STEP_CLOSED, - ]); + ->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('user', $user), new \Doctrine\ORM\Query\Parameter('now', new \DateTimeImmutable('now')), new \Doctrine\ORM\Query\Parameter('closed', AccompanyingPeriod::STEP_CLOSED)])); return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index df5ee6c66..928615dbf 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -253,11 +253,7 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository ) ) ) - ->setParameters([ - 'user' => $user, - 'since' => $since, - 'until' => $until, - ]); + ->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('user', $user), new \Doctrine\ORM\Query\Parameter('since', $since), new \Doctrine\ORM\Query\Parameter('until', $until)])); return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Repository/AdministrativeStatusRepository.php b/src/Bundle/ChillPersonBundle/Repository/AdministrativeStatusRepository.php index 637db23c5..d93fe1803 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AdministrativeStatusRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AdministrativeStatusRepository.php @@ -15,6 +15,9 @@ use Chill\PersonBundle\Entity\AdministrativeStatus; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; +/** + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\AdministrativeStatus> + */ class AdministrativeStatusRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) diff --git a/src/Bundle/ChillPersonBundle/Repository/EmploymentStatusRepository.php b/src/Bundle/ChillPersonBundle/Repository/EmploymentStatusRepository.php index 4f65a3c78..731eb6fcd 100644 --- a/src/Bundle/ChillPersonBundle/Repository/EmploymentStatusRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/EmploymentStatusRepository.php @@ -15,6 +15,9 @@ use Chill\PersonBundle\Entity\EmploymentStatus; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; +/** + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\EmploymentStatus> + */ class EmploymentStatusRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) diff --git a/src/Bundle/ChillPersonBundle/Repository/Identifier/PersonIdentifierDefinitionRepository.php b/src/Bundle/ChillPersonBundle/Repository/Identifier/PersonIdentifierDefinitionRepository.php index 33b531e5a..081cd3921 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Identifier/PersonIdentifierDefinitionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Identifier/PersonIdentifierDefinitionRepository.php @@ -17,6 +17,8 @@ use Doctrine\Persistence\ManagerRegistry; /** * @template-extends ServiceEntityRepository + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\Identifier\PersonIdentifierDefinition> */ class PersonIdentifierDefinitionRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php index 22556d747..68a5cc2f5 100644 --- a/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php @@ -23,6 +23,8 @@ use Doctrine\Persistence\ManagerRegistry; * @method ResidentialAddress|null findOneBy(array $criteria, array $orderBy = null) * @method ResidentialAddress[] findAll() * @method ResidentialAddress[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\Person\ResidentialAddress> */ class ResidentialAddressRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php index 3abaf4ad1..27b8917a5 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php @@ -29,7 +29,7 @@ class AccompanyingPeriodCommentVoter extends Voter return $subject instanceof Comment; } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { return match ($attribute) { self::EDIT => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()), diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php index 577ec38bb..4422e0475 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php @@ -27,7 +27,7 @@ class AccompanyingPeriodResourceVoter extends Voter return $subject instanceof Resource && self::EDIT === $attribute; } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { return match ($attribute) { self::EDIT => $this->accessDecisionManager->decide( diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php index 0e9f4201c..ea59add2b 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php @@ -40,7 +40,7 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter * * @return bool|void */ - public function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + public function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { return match ($attribute) { self::SEE => $this->accessDecisionManager->decide( diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php index a5c466ec1..201ed0fa1 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php @@ -43,7 +43,7 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterI * @param string $attribute * @param AccompanyingPeriodWorkEvaluation $subject */ - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { return match ($attribute) { self::STATS => $this->security->isGranted(AccompanyingPeriodVoter::STATS, $subject), diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php index 0115e4282..ded75dbfd 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php @@ -89,7 +89,7 @@ class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyI * @param string $attribute * @param AccompanyingPeriodWork $subject */ - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { if ($subject instanceof AccompanyingPeriodWork) { return match ($attribute) { diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php index c42964ca9..97383cc74 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php @@ -73,7 +73,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi || $this->helper->supports($attribute, $subject); } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { return match ($attribute) { self::SEE => $this->checkAssociatedMembersRole($subject, PersonVoter::SEE), diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index d8b3eb5f7..6d3cb4ee6 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -85,15 +85,13 @@ class ReportList implements ExportElementValidatedInterface, ListInterface default => $label. ' ('.$this->translator->trans("Report's question").')', }, - 'constraints' => [new Callback([ - 'callback' => static function ($selected, ExecutionContextInterface $context) { - if (0 === \count($selected)) { - $context->buildViolation('You must select at least one element') - ->atPath('fields') - ->addViolation(); - } - }, - ])], + 'constraints' => [new Callback(callback: static function ($selected, ExecutionContextInterface $context) { + if (0 === \count($selected)) { + $context->buildViolation('You must select at least one element') + ->atPath('fields') + ->addViolation(); + } + })], ]); $builder->add('address_date', ChillDateType::class, [ diff --git a/src/Bundle/ChillTaskBundle/Templating/TaskTwigExtension.php b/src/Bundle/ChillTaskBundle/Templating/TaskTwigExtension.php index 5ab051c03..d2998efdf 100644 --- a/src/Bundle/ChillTaskBundle/Templating/TaskTwigExtension.php +++ b/src/Bundle/ChillTaskBundle/Templating/TaskTwigExtension.php @@ -13,10 +13,8 @@ namespace Chill\TaskBundle\Templating; use Chill\TaskBundle\Entity\AbstractTask; use Chill\TaskBundle\Workflow\TaskWorkflowManager; -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; -class TaskTwigExtension extends AbstractExtension +class TaskTwigExtension { /** * @var TaskWorkflowManager @@ -28,13 +26,7 @@ class TaskTwigExtension extends AbstractExtension $this->taskWorkflowManager = $taskWorkflowManager; } - public function getFunctions() - { - return [ - new TwigFunction('task_workflow_metadata', $this->getWorkflowMetadata(...)), - ]; - } - + #[\Twig\Attribute\AsTwigFunction('task_workflow_metadata')] public function getWorkflowMetadata( AbstractTask $task, string $key, diff --git a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyCategoryRepository.php b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyCategoryRepository.php index 5a04ec8a5..6c1dad5d7 100644 --- a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyCategoryRepository.php +++ b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyCategoryRepository.php @@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry; * @method ThirdPartyCategory|null findOneBy(array $criteria, array $orderBy = null) * @method ThirdPartyCategory[] findAll() * @method ThirdPartyCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ThirdPartyBundle\Entity\ThirdPartyCategory> */ class ThirdPartyCategoryRepository extends ServiceEntityRepository { diff --git a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyProfessionRepository.php b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyProfessionRepository.php index 0344f312c..3b60426ec 100644 --- a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyProfessionRepository.php +++ b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyProfessionRepository.php @@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry; * @method ThirdPartyProfession|null findOneBy(array $criteria, array $orderBy = null) * @method ThirdPartyProfession[] findAll() * @method ThirdPartyProfession[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\ThirdPartyBundle\Entity\ThirdPartyProfession> */ class ThirdPartyProfessionRepository extends ServiceEntityRepository {