From b9a7530f7af816a9d98a3cd1589ba862a21ebd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 29 Mar 2023 22:32:52 +0200 Subject: [PATCH 01/43] DX: apply rector rulesset up to PHP72 --- .../DataFixtures/ORM/LoadActivity.php | 4 +-- .../DependencyInjection/Configuration.php | 2 +- .../Form/ActivityReasonCategoryType.php | 2 +- .../ChillActivityBundle/Form/ActivityType.php | 4 +-- .../Type/TranslatableActivityReasonTest.php | 6 ++-- .../Authorization/ActivityVoterTest.php | 2 +- .../src/DependencyInjection/Configuration.php | 2 +- .../src/Form/AsideActivityFormType.php | 4 +-- .../Controller/AbstractElementController.php | 2 +- .../Compiler/CalculatorCompilerPass.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../MapAndSubscribeUserCalendarCommand.php | 14 ++++---- .../DependencyInjection/Configuration.php | 2 +- .../MSGraphChangeNotificationHandler.php | 6 ++-- .../RemoteToLocalSync/CalendarRangeSyncer.php | 6 ++-- .../RemoteToLocalSync/CalendarSyncer.php | 4 +-- .../BulkCalendarShortMessageSender.php | 2 +- .../Command/CreateFieldsOnGroupCommand.php | 8 ++--- .../CustomFields/CustomFieldChoice.php | 2 +- .../DataFixtures/ORM/LoadOption.php | 4 +-- .../DependencyInjection/Configuration.php | 2 +- .../Form/CustomFieldType.php | 2 +- .../Form/Type/ChoicesListType.php | 2 +- .../Form/Type/CustomFieldType.php | 2 +- .../Service/CustomFieldsHelper.php | 4 +-- .../CustomFieldsGroupControllerTest.php | 2 +- .../Tests/CustomFieldTestHelper.php | 4 +-- .../CustomFields/CustomFieldsTextTest.php | 4 +-- .../Twig/CustomFieldRenderingTwigTest.php | 2 +- .../CustomFieldsGroupRenderingTwigTest.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../DataFixtures/ORM/LoadParticipation.php | 4 +-- .../DependencyInjection/Configuration.php | 2 +- .../ChillEventBundle/Form/EventType.php | 2 +- .../ChillEventBundle/Form/EventTypeType.php | 2 +- src/Bundle/ChillEventBundle/Form/RoleType.php | 2 +- .../ChillEventBundle/Form/StatusType.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../Command/LoadPostalCodesCommand.php | 6 +--- .../Controller/ExportController.php | 4 +-- .../ORM/LoadAddressReferences.php | 6 ++-- .../CompilerPass/MenuCompilerPass.php | 6 +--- .../CompilerPass/ShortMessageCompilerPass.php | 10 +++--- .../DependencyInjection/Configuration.php | 2 +- .../Widget/AbstractWidgetsCompilerPass.php | 3 +- .../Widget/AddWidgetConfigurationTrait.php | 4 +-- src/Bundle/ChillMainBundle/Entity/Address.php | 16 +++------- .../Embeddable/PrivateCommentEmbeddable.php | 2 +- .../Export/Formatter/SpreadSheetFormatter.php | 4 +-- .../ChillMainBundle/Form/CenterType.php | 2 +- .../ChillMainBundle/Form/LocationFormType.php | 2 +- .../Form/PermissionsGroupType.php | 2 +- src/Bundle/ChillMainBundle/Form/ScopeType.php | 2 +- .../Form/Type/AppendScopeChoiceTypeTrait.php | 4 +-- .../Form/Type/ComposedGroupCenterType.php | 6 ++-- .../Form/Type/ComposedRoleScopeType.php | 2 +- .../Form/Type/Select2CountryType.php | 2 +- .../Form/Type/Select2LanguageType.php | 2 +- src/Bundle/ChillMainBundle/Form/UserType.php | 2 +- .../ChillMainBundle/Form/WorkflowStepType.php | 2 +- .../Pagination/PaginatorFactory.php | 5 ++- .../ChillMainBundle/Search/SearchProvider.php | 12 ++----- ...eographicalUnitMaterializedViewCronJob.php | 2 +- .../Import/PostalCodeBEFromBestAddress.php | 4 +-- .../Import/PostalCodeFRFromOpenData.php | 2 +- .../Test/Export/AbstractAggregatorTest.php | 2 +- .../Test/Export/AbstractExportTest.php | 2 +- .../Test/PrepareCenterTrait.php | 2 +- .../Test/PrepareCircleTrait.php | 2 +- .../Tests/Export/ExportManagerTest.php | 32 +++++++++---------- .../Tests/Form/Type/PickCenterTypeTest.php | 8 ++--- .../Tests/Search/AbstractSearchTest.php | 2 +- .../Tests/Search/SearchProviderTest.php | 4 +-- .../Authorization/AuthorizationHelperTest.php | 20 ++++++------ .../Controller/PersonController.php | 2 +- .../DataFixtures/ORM/LoadCustomFields.php | 4 +-- .../ChillPersonExtension.php | 4 +-- .../DependencyInjection/Configuration.php | 4 +-- .../Entity/Household/Household.php | 6 ++-- .../Entity/Household/HouseholdMember.php | 2 +- .../ChillPersonBundle/Entity/Person.php | 2 +- .../Export/Filter/PersonFilters/AgeFilter.php | 4 +-- .../Form/AccompanyingPeriodType.php | 2 +- .../ChillPersonBundle/Form/PersonType.php | 2 +- .../Form/Type/Select2MaritalStatusType.php | 4 +-- .../Household/MembersEditor.php | 2 +- .../ResidentialAddressRepository.php | 2 +- .../OldDraftAccompanyingPeriodRemover.php | 4 +-- .../Events/PersonMoveEventSubscriberTest.php | 2 +- .../Controller/PersonControllerCreateTest.php | 2 +- .../Authorization/PersonVoterTest.php | 2 +- ...mpanyingPeriodWorkDocGenNormalizerTest.php | 2 +- .../DocGenerator/PersonContextTest.php | 3 +- .../Controller/ReportController.php | 4 +-- .../DataFixtures/ORM/LoadCustomField.php | 6 ++-- .../ORM/LoadCustomFieldsGroup.php | 2 +- .../DataFixtures/ORM/LoadReports.php | 8 ++--- .../ChillReportExtension.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../ChillReportBundle/Form/ReportType.php | 4 +-- .../ChillReportBundle/Search/ReportSearch.php | 2 +- .../Controller/ReportControllerNextTest.php | 2 +- .../Tests/Controller/ReportControllerTest.php | 8 ++--- .../ChillReportExtensionTest.php | 2 +- .../Authorization/ReportVoterTest.php | 2 +- .../Tests/Timeline/TimelineProviderTest.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../ChillTaskBundle/Menu/MenuBuilder.php | 2 +- .../TaskLifeCycleEventTimelineProvider.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- 110 files changed, 194 insertions(+), 229 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php index 8c53ca2d9..82949d635 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php @@ -50,7 +50,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface ->findAll(); foreach ($persons as $person) { - $activityNbr = mt_rand(0, 3); + $activityNbr = random_int(0, 3); for ($i = 0; $i < $activityNbr; ++$i) { $activity = $this->newRandomActivity($person); @@ -75,7 +75,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface // ->setAttendee($this->faker->boolean()) - for ($i = 0; mt_rand(0, 4) > $i; ++$i) { + for ($i = 0; random_int(0, 4) > $i; ++$i) { $reason = $this->getRandomActivityReason(); if (null !== $reason) { diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php index e22f6242c..c6b3189cc 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php @@ -26,7 +26,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_activity'); - $rootNode = $treeBuilder->getRootNode('chill_activity'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityReasonCategoryType.php b/src/Bundle/ChillActivityBundle/Form/ActivityReasonCategoryType.php index b8e03d2c7..3a0f2a318 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityReasonCategoryType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityReasonCategoryType.php @@ -32,7 +32,7 @@ class ActivityReasonCategoryType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\ActivityBundle\Entity\ActivityReasonCategory', + 'data_class' => \Chill\ActivityBundle\Entity\ActivityReasonCategory::class, ]); } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 6d198c5fa..4bb1c1352 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -400,9 +400,7 @@ class ActivityType extends AbstractType // the datetimetransformer will then handle timezone as GMT $timezoneUTC = new DateTimeZone('GMT'); /** @var DateTime $data */ - $data = $formEvent->getData() === null ? - DateTime::createFromFormat('U', '300') : - $formEvent->getData(); + $data = $formEvent->getData() ?? DateTime::createFromFormat('U', '300'); $seconds = $data->getTimezone()->getOffset($data); $data->setTimeZone($timezoneUTC); $data->add(new DateInterval('PT' . $seconds . 'S')); diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php index 3c9777051..881e5a607 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php @@ -79,15 +79,15 @@ final class TranslatableActivityReasonTest extends TypeTestCase $request = $prophet->prophesize(); $translator = $prophet->prophesize(); - $request->willExtend('Symfony\Component\HttpFoundation\Request'); + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); $request->getLocale()->willReturn($fallbackLocale); - $requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack->willExtend(\Symfony\Component\HttpFoundation\RequestStack::class); $requestStack->getCurrentRequest()->will(static function () use ($request) { return $request; }); - $translator->willExtend('Symfony\Component\Translation\Translator'); + $translator->willExtend(\Symfony\Component\Translation\Translator::class); $translator->getFallbackLocales()->willReturn($locale); return new TranslatableStringHelper( diff --git a/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php b/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php index a9b9e2ec7..1fb90a4ae 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php @@ -160,7 +160,7 @@ final class ActivityVoterTest extends KernelTestCase { $token = $this->prophet->prophesize(); $token - ->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + ->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class); if (null === $user) { $token->getUser()->willReturn(null); diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php index d01998358..8341e0240 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php @@ -22,7 +22,7 @@ class Configuration implements ConfigurationInterface { $treeBuilder = new TreeBuilder('chill_aside_activity'); - $treeBuilder->getRootNode('chill_aside_activity') + $treeBuilder->getRootNode() ->children() ->arrayNode('form') ->canBeEnabled() diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php index 9a95a8d09..727287972 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php @@ -95,9 +95,7 @@ final class AsideActivityFormType extends AbstractType // the datetimetransformer will then handle timezone as GMT $timezoneUTC = new DateTimeZone('GMT'); /** @var DateTimeImmutable $data */ - $data = $formEvent->getData() === null ? - DateTime::createFromFormat('U', '300') : - $formEvent->getData(); + $data = $formEvent->getData() ?? DateTime::createFromFormat('U', '300'); $seconds = $data->getTimezone()->getOffset($data); $data->setTimeZone($timezoneUTC); $data->add(new DateInterval('PT' . $seconds . 'S')); diff --git a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php index badccf3b3..125c72ce4 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php @@ -116,7 +116,7 @@ abstract class AbstractElementController extends AbstractController $indexPage = 'chill_budget_elements_household_index'; } - $entity = null !== $element->getPerson() ? $element->getPerson() : $element->getHousehold(); + $entity = $element->getPerson() ?? $element->getHousehold(); $form = $this->createForm($this->getType(), $element); $form->add('submit', SubmitType::class); diff --git a/src/Bundle/ChillBudgetBundle/DependencyInjection/Compiler/CalculatorCompilerPass.php b/src/Bundle/ChillBudgetBundle/DependencyInjection/Compiler/CalculatorCompilerPass.php index 64df79202..012c4eab5 100644 --- a/src/Bundle/ChillBudgetBundle/DependencyInjection/Compiler/CalculatorCompilerPass.php +++ b/src/Bundle/ChillBudgetBundle/DependencyInjection/Compiler/CalculatorCompilerPass.php @@ -19,7 +19,7 @@ class CalculatorCompilerPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { - $manager = $container->getDefinition('Chill\BudgetBundle\Calculator\CalculatorManager'); + $manager = $container->getDefinition(\Chill\BudgetBundle\Calculator\CalculatorManager::class); foreach ($container->findTaggedServiceIds('chill_budget.calculator') as $id => $tags) { foreach ($tags as $tag) { diff --git a/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php index 8856df22b..ff9931f2d 100644 --- a/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php @@ -19,7 +19,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_budget'); - $rootNode = $treeBuilder->getRootNode('chill_budget'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php index 902fe4c38..63ac15348 100644 --- a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php @@ -60,7 +60,7 @@ class MapAndSubscribeUserCalendarCommand extends Command public function execute(InputInterface $input, OutputInterface $output): int { - $this->logger->info(__CLASS__ . ' execute command'); + $this->logger->info(self::class . ' execute command'); $limit = 50; $offset = 0; @@ -71,7 +71,7 @@ class MapAndSubscribeUserCalendarCommand extends Command $created = 0; $renewed = 0; - $this->logger->info(__CLASS__ . ' the number of user to get - renew', [ + $this->logger->info(self::class . ' the number of user to get - renew', [ 'total' => $total, 'expiration' => $expiration->format(DateTimeImmutable::ATOM), ]); @@ -92,7 +92,7 @@ class MapAndSubscribeUserCalendarCommand extends Command // we first try to renew an existing subscription, if any. // if not, or if it fails, we try to create a new one if ($this->mapCalendarToUser->hasActiveSubscription($user)) { - $this->logger->debug(__CLASS__ . ' renew a subscription for', [ + $this->logger->debug(self::class . ' renew a subscription for', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); @@ -104,7 +104,7 @@ class MapAndSubscribeUserCalendarCommand extends Command if (0 !== $expirationTs) { ++$renewed; } else { - $this->logger->warning(__CLASS__ . ' could not renew subscription for a user', [ + $this->logger->warning(self::class . ' could not renew subscription for a user', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); @@ -112,7 +112,7 @@ class MapAndSubscribeUserCalendarCommand extends Command } if (!$this->mapCalendarToUser->hasActiveSubscription($user)) { - $this->logger->debug(__CLASS__ . ' create a subscription for', [ + $this->logger->debug(self::class . ' create a subscription for', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); @@ -124,7 +124,7 @@ class MapAndSubscribeUserCalendarCommand extends Command if (0 !== $expirationTs) { ++$created; } else { - $this->logger->warning(__CLASS__ . ' could not create subscription for a user', [ + $this->logger->warning(self::class . ' could not create subscription for a user', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); @@ -139,7 +139,7 @@ class MapAndSubscribeUserCalendarCommand extends Command $this->em->clear(); } - $this->logger->warning(__CLASS__ . ' process executed', [ + $this->logger->warning(self::class . ' process executed', [ 'created' => $created, 'renewed' => $renewed, ]); diff --git a/src/Bundle/ChillCalendarBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillCalendarBundle/DependencyInjection/Configuration.php index 127b69047..a3e4ae391 100644 --- a/src/Bundle/ChillCalendarBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillCalendarBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_calendar'); - $rootNode = $treeBuilder->getRootNode('chill_calendar'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php index 9c1e84511..a09c70c1e 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php @@ -77,7 +77,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface $user = $this->userRepository->find($changeNotificationMessage->getUserId()); if (null === $user) { - $this->logger->warning(__CLASS__ . ' notification concern non-existent user, skipping'); + $this->logger->warning(self::class . ' notification concern non-existent user, skipping'); return; } @@ -86,7 +86,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface $secret = $this->mapCalendarToUser->getSubscriptionSecret($user); if ($secret !== ($notification['clientState'] ?? -1)) { - $this->logger->warning(__CLASS__ . ' could not validate secret, skipping'); + $this->logger->warning(self::class . ' could not validate secret, skipping'); continue; } @@ -101,7 +101,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface $this->calendarSyncer->handleCalendarSync($calendar, $notification, $user); $this->em->flush(); } else { - $this->logger->info(__CLASS__ . ' id not found in any calendar nor calendar range'); + $this->logger->info(self::class . ' id not found in any calendar nor calendar range'); } } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php index a9227282d..d05adfed7 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php @@ -59,7 +59,7 @@ class CalendarRangeSyncer } $calendarRange->preventEnqueueChanges = true; - $this->logger->info(__CLASS__ . ' remove a calendar range because deleted on remote calendar'); + $this->logger->info(self::class . ' remove a calendar range because deleted on remote calendar'); $this->em->remove($calendarRange); break; @@ -71,7 +71,7 @@ class CalendarRangeSyncer $notification['resource'] )->toArray(); } catch (ClientExceptionInterface $clientException) { - $this->logger->warning(__CLASS__ . ' could not retrieve event from ms graph. Already deleted ?', [ + $this->logger->warning(self::class . ' could not retrieve event from ms graph. Already deleted ?', [ 'calendarRangeId' => $calendarRange->getId(), 'remoteEventId' => $notification['resource'], ]); @@ -82,7 +82,7 @@ class CalendarRangeSyncer $lastModified = RemoteEventConverter::convertStringDateWithTimezone($new['lastModifiedDateTime']); if ($calendarRange->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) { - $this->logger->info(__CLASS__ . ' change key is equals. Source is probably a local update', [ + $this->logger->info(self::class . ' change key is equals. Source is probably a local update', [ 'calendarRangeId' => $calendarRange->getId(), 'remoteEventId' => $notification['resource'], ]); diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php index c5a640f32..b3febf4d4 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php @@ -79,7 +79,7 @@ class CalendarSyncer $notification['resource'] )->toArray(); } catch (ClientExceptionInterface $clientException) { - $this->logger->warning(__CLASS__ . ' could not retrieve event from ms graph. Already deleted ?', [ + $this->logger->warning(self::class . ' could not retrieve event from ms graph. Already deleted ?', [ 'calendarId' => $calendar->getId(), 'remoteEventId' => $notification['resource'], ]); @@ -96,7 +96,7 @@ class CalendarSyncer ); if ($calendar->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) { - $this->logger->info(__CLASS__ . ' change key is equals. Source is probably a local update', [ + $this->logger->info(self::class . ' change key is equals. Source is probably a local update', [ 'calendarRangeId' => $calendar->getId(), 'remoteEventId' => $notification['resource'], ]); diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php index a35fffce0..83826bbcf 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php @@ -66,6 +66,6 @@ class BulkCalendarShortMessageSender $this->em->refresh($calendar); } - $this->logger->info(__CLASS__ . 'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]); + $this->logger->info(self::class . 'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]); } } diff --git a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php index c8c8ad4fc..2a03e90bb 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php +++ b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php @@ -192,9 +192,7 @@ class CreateFieldsOnGroupCommand extends Command foreach ($languages as $lang) { //todo replace with service to find lang when available - $names[] = (isset($cf->getName()[$lang])) ? - $cf->getName()[$lang] : - 'Not available in this language'; + $names[] = $cf->getName()[$lang] ?? 'Not available in this language'; } if ($this->validator->validate($cf)) { @@ -249,9 +247,7 @@ class CreateFieldsOnGroupCommand extends Command foreach ($languages as $lang) { //todo replace with service to find lang when available - $row[] = (isset($customFieldGroup->getName()[$lang])) ? - $customFieldGroup->getName()[$lang] : - 'Not available in this language'; + $row[] = $customFieldGroup->getName()[$lang] ?? 'Not available in this language'; } $rows[] = $row; } diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php index 7876dd026..781b2b233 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php @@ -294,7 +294,7 @@ class CustomFieldChoice extends AbstractCustomField public function render($value, CustomField $customField, $documentType = 'html') { //extract the data. They are under a _choice key if they are stored with allow_other - $data = (isset($value['_choices'])) ? $value['_choices'] : $value; + $data = $value['_choices'] ?? $value; $selected = (is_array($data)) ? $data : [$data]; $choices = $customField->getOptions()[self::CHOICES]; diff --git a/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php b/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php index 0edc2457a..5b2598ab7 100644 --- a/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php +++ b/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php @@ -104,7 +104,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface $manager->persist($parent); //Load children - $expected_nb_children = mt_rand(10, 50); + $expected_nb_children = random_int(10, 50); for ($i = 0; $i < $expected_nb_children; ++$i) { $companyName = $this->fakerFr->company; @@ -144,7 +144,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface $manager->persist($parent); //Load children - $expected_nb_children = mt_rand(10, 50); + $expected_nb_children = random_int(10, 50); for ($i = 0; $i < $expected_nb_children; ++$i) { $manager->persist($this->createChildOption($parent, [ diff --git a/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/Configuration.php index d0db269a2..e68fdd2c4 100644 --- a/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/Configuration.php @@ -25,7 +25,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_custom_fields'); - $rootNode = $treeBuilder->getRootNode('chill_custom_fields'); + $rootNode = $treeBuilder->getRootNode(); $classInfo = 'The class which may receive custom fields'; $nameInfo = 'The name which will appears in the user interface. May be translatable'; diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php index aa1d1b7e1..ea572759b 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php @@ -119,7 +119,7 @@ class CustomFieldType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\CustomFieldsBundle\Entity\CustomField', + 'data_class' => \Chill\CustomFieldsBundle\Entity\CustomField::class, ]); $resolver->setRequired(['type', 'group_widget']) diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php b/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php index 071363451..c50bd856e 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php @@ -38,7 +38,7 @@ class ChoicesListType extends AbstractType $formData = $form->getData(); if (null === $formData['slug']) { - $slug = uniqid(mt_rand(), true); + $slug = uniqid(random_int(0, mt_getrandmax()), true); $data['slug'] = $slug; $event->setData($data); diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php index 5b1d39529..67ea171e6 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php @@ -49,7 +49,7 @@ class CustomFieldType extends AbstractType { $resolver ->setRequired(['group']) - ->addAllowedTypes('group', ['Chill\CustomFieldsBundle\Entity\CustomFieldsGroup']); + ->addAllowedTypes('group', [\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class]); } public function getBlockPrefix() diff --git a/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php b/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php index 67afdec85..9ffd836e6 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php +++ b/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php @@ -49,7 +49,7 @@ class CustomFieldsHelper public function isEmptyValue(array $fields, CustomField $customField) { $slug = $customField->getSlug(); - $rawValue = (isset($fields[$slug])) ? $fields[$slug] : null; + $rawValue = $fields[$slug] ?? null; $customFieldType = $this->provider->getCustomFieldByType($customField->getType()); $deserializedValue = $customFieldType->deserialize($rawValue, $customField); @@ -71,7 +71,7 @@ class CustomFieldsHelper public function renderCustomField(array $fields, CustomField $customField, $documentType = 'html') { $slug = $customField->getSlug(); - $rawValue = (isset($fields[$slug])) ? $fields[$slug] : null; + $rawValue = $fields[$slug] ?? null; $customFieldType = $this->provider->getCustomFieldByType($customField->getType()); return $customFieldType->render($rawValue, $customField, $documentType); diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/Controller/CustomFieldsGroupControllerTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/Controller/CustomFieldsGroupControllerTest.php index 067fe7de6..7e0fe12d2 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/Controller/CustomFieldsGroupControllerTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/Controller/CustomFieldsGroupControllerTest.php @@ -52,7 +52,7 @@ final class CustomFieldsGroupControllerTest extends WebTestCase // Fill in the form and submit it $form = $crawler->selectButton('Créer')->form([ 'custom_fields_group[name][fr]' => 'Test', - 'custom_fields_group[entity]' => 'Chill\PersonBundle\Entity\Person', + 'custom_fields_group[entity]' => \Chill\PersonBundle\Entity\Person::class, ]); $crawler = $client->submit($form); diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFieldTestHelper.php b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFieldTestHelper.php index 35a9ee82b..79f547fe2 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFieldTestHelper.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFieldTestHelper.php @@ -34,12 +34,12 @@ trait CustomFieldTestHelper $kernel = static::$kernel; //check a kernel is accessible - $customFieldsGroup = $this->createMock('Chill\CustomFieldsBundle\Entity\CustomFieldsGroup'); + $customFieldsGroup = $this->createMock(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class); $customFieldsGroup->expects($this->once()) ->method('getActiveCustomFields') ->will($this->returnValue([$field])); - $request = $this->createMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->createMock(\Symfony\Component\HttpFoundation\Request::class); $request->expects($this->any()) ->method('getLocale') ->will($this->returnValue($locale)); diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsTextTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsTextTest.php index cc1b4db64..6bfe2663c 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsTextTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsTextTest.php @@ -41,11 +41,11 @@ final class CustomFieldsTextTest extends WebTestCase $customField = $this->customFieldProvider->getCustomFieldByType('text'); $this->assertInstanceOf( - 'Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface', + \Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface::class, $customField ); $this->assertInstanceOf( - 'Chill\CustomFieldsBundle\CustomFields\CustomFieldText', + \Chill\CustomFieldsBundle\CustomFields\CustomFieldText::class, $customField ); } diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldRenderingTwigTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldRenderingTwigTest.php index 420e79dff..2e29d988b 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldRenderingTwigTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldRenderingTwigTest.php @@ -46,7 +46,7 @@ final class CustomFieldRenderingTwigTest extends KernelTestCase // set locale to fr $prophet = new \Prophecy\Prophet(); $request = $prophet->prophesize(); - $request->willExtend('Symfony\Component\HttpFoundation\Request'); + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); $request->getLocale()->willReturn('fr'); self::$kernel->getContainer()->get('request_stack') ->push($request->reveal()); diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php index 7ffa31db5..f3b93c390 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php @@ -48,7 +48,7 @@ final class CustomFieldsGroupRenderingTwigTest extends KernelTestCase // set locale to fr $prophet = new \Prophecy\Prophet(); $request = $prophet->prophesize(); - $request->willExtend('Symfony\Component\HttpFoundation\Request'); + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); $request->getLocale()->willReturn('fr'); self::$kernel->getContainer()->get('request_stack') ->push($request->reveal()); diff --git a/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php index d2c56d8d1..466158783 100644 --- a/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_doc_store'); - $rootNode = $treeBuilder->getRootNode('chill_doc_store'); + $rootNode = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for diff --git a/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php b/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php index ed38faf01..71b07a123 100644 --- a/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php +++ b/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php @@ -43,7 +43,7 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa for ($i = 0; $i < $expectedNumber; ++$i) { $event = (new Event()) ->setDate($this->faker->dateTimeBetween('-2 years', '+6 months')) - ->setName($this->faker->words(mt_rand(2, 4), true)) + ->setName($this->faker->words(random_int(2, 4), true)) ->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)])) ->setCenter($center) ->setCircle( @@ -75,7 +75,7 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa /** @var \Chill\PersonBundle\Entity\Person $person */ foreach ($people as $person) { - $nb = mt_rand(0, 3); + $nb = random_int(0, 3); for ($i = 0; $i < $nb; ++$i) { $event = $events[array_rand($events)]; diff --git a/src/Bundle/ChillEventBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillEventBundle/DependencyInjection/Configuration.php index b36f7b6a9..fe42ad99a 100644 --- a/src/Bundle/ChillEventBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillEventBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_event'); - $rootNode = $treeBuilder->getRootNode('chill_event'); + $rootNode = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for diff --git a/src/Bundle/ChillEventBundle/Form/EventType.php b/src/Bundle/ChillEventBundle/Form/EventType.php index fec26c373..a72b90494 100644 --- a/src/Bundle/ChillEventBundle/Form/EventType.php +++ b/src/Bundle/ChillEventBundle/Form/EventType.php @@ -54,7 +54,7 @@ class EventType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\EventBundle\Entity\Event', + 'data_class' => \Chill\EventBundle\Entity\Event::class, ]); $resolver ->setRequired(['center', 'role']) diff --git a/src/Bundle/ChillEventBundle/Form/EventTypeType.php b/src/Bundle/ChillEventBundle/Form/EventTypeType.php index 9f971f55d..bab13c374 100644 --- a/src/Bundle/ChillEventBundle/Form/EventTypeType.php +++ b/src/Bundle/ChillEventBundle/Form/EventTypeType.php @@ -36,7 +36,7 @@ class EventTypeType extends AbstractType public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\EventBundle\Entity\EventType', + 'data_class' => \Chill\EventBundle\Entity\EventType::class, ]); } } diff --git a/src/Bundle/ChillEventBundle/Form/RoleType.php b/src/Bundle/ChillEventBundle/Form/RoleType.php index e4e55faca..9c56d17e6 100644 --- a/src/Bundle/ChillEventBundle/Form/RoleType.php +++ b/src/Bundle/ChillEventBundle/Form/RoleType.php @@ -55,7 +55,7 @@ class RoleType extends AbstractType public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\EventBundle\Entity\Role', + 'data_class' => \Chill\EventBundle\Entity\Role::class, ]); } } diff --git a/src/Bundle/ChillEventBundle/Form/StatusType.php b/src/Bundle/ChillEventBundle/Form/StatusType.php index e70011d22..5801f3264 100644 --- a/src/Bundle/ChillEventBundle/Form/StatusType.php +++ b/src/Bundle/ChillEventBundle/Form/StatusType.php @@ -38,7 +38,7 @@ class StatusType extends AbstractType public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\EventBundle\Entity\Status', + 'data_class' => \Chill\EventBundle\Entity\Status::class, ]); } } diff --git a/src/Bundle/ChillFamilyMembersBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillFamilyMembersBundle/DependencyInjection/Configuration.php index d2c09d7fa..98ea3125a 100644 --- a/src/Bundle/ChillFamilyMembersBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillFamilyMembersBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_amli_family_members'); - $rootNode = $treeBuilder->getRootNode('chill_amli_family_members'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index fd8a469d6..ea42fde78 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -102,11 +102,7 @@ class LoadPostalCodesCommand extends Command try { $this->addPostalCode($row, $output); ++$num; - } catch (ExistingPostalCodeException $ex) { - $output->writeln(' on line ' . $line . ' : ' . $ex->getMessage() . ''); - } catch (CountryCodeNotFoundException $ex) { - $output->writeln(' on line ' . $line . ' : ' . $ex->getMessage() . ''); - } catch (PostalCodeNotValidException $ex) { + } catch (ExistingPostalCodeException|CountryCodeNotFoundException|PostalCodeNotValidException $ex) { $output->writeln(' on line ' . $line . ' : ' . $ex->getMessage() . ''); } ++$line; diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index caeec8327..686b4cbce 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -164,7 +164,7 @@ class ExportController extends AbstractController { $this->denyAccessUnlessGranted(SavedExportVoter::GENERATE, $savedExport); - $key = md5(uniqid((string) mt_rand(), false)); + $key = md5(uniqid((string) random_int(0, mt_getrandmax()), false)); $this->redis->setEx($key, 3600, serialize($savedExport->getOptions())); @@ -481,7 +481,7 @@ class ExportController extends AbstractController 'alias' => $alias, ]; unset($parameters['_token']); - $key = md5(uniqid((string) mt_rand(), false)); + $key = md5(uniqid((string) random_int(0, mt_getrandmax()), false)); $this->redis->setEx($key, 3600, serialize($parameters)); diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php index 93aaf01b3..0fef33c2f 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php @@ -69,7 +69,7 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt $ar->setRefId($this->faker->numerify('ref-id-######')); $ar->setStreet($this->faker->streetName); - $ar->setStreetNumber((string) mt_rand(0, 199)); + $ar->setStreetNumber((string) random_int(0, 199)); $ar->setPoint($this->getRandomPoint()); $ar->setPostcode($this->getReference( LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)] @@ -89,8 +89,8 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt { $lonBrussels = 4.35243; $latBrussels = 50.84676; - $lon = $lonBrussels + 0.01 * mt_rand(-5, 5); - $lat = $latBrussels + 0.01 * mt_rand(-5, 5); + $lon = $lonBrussels + 0.01 * random_int(-5, 5); + $lat = $latBrussels + 0.01 * random_int(-5, 5); return Point::fromLonLat($lon, $lat); } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php index c41a32056..ae53f09df 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php @@ -38,11 +38,7 @@ class MenuCompilerPass implements CompilerPassInterface } usort($services, static function ($a, $b) { - if ($a['priority'] === $b['priority']) { - return 0; - } - - return ($a['priority'] < $b['priority']) ? -1 : 1; + return $a['priority'] <=> $b['priority']; }); foreach ($services as $service) { diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php index f75840c3a..f9fdb80d0 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php @@ -34,7 +34,7 @@ class ShortMessageCompilerPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { - $config = $container->resolveEnvPlaceholders($container->getParameter('chill_main.short_messages', null), true); + $config = $container->resolveEnvPlaceholders($container->getParameter('chill_main.short_messages'), true); // weird fix for special characters $config['dsn'] = str_replace(['%%'], ['%'], $config['dsn']); $dsn = parse_url($config['dsn']); @@ -43,7 +43,7 @@ class ShortMessageCompilerPass implements CompilerPassInterface if ('null' === $dsn['scheme'] || false === $config['enabled']) { $defaultTransporter = new Reference(NullShortMessageSender::class); } elseif ('ovh' === $dsn['scheme']) { - if (!class_exists('\Ovh\Api')) { + if (!class_exists('\\' . \Ovh\Api::class)) { throw new RuntimeException('Class \\Ovh\\Api not found'); } @@ -66,17 +66,17 @@ class ShortMessageCompilerPass implements CompilerPassInterface $ovh = new Definition(); $ovh - ->setClass('\Ovh\Api') + ->setClass('\\' . \Ovh\Api::class) ->setArgument(0, $dsn['user']) ->setArgument(1, $dsn['pass']) ->setArgument(2, $dsn['host']) ->setArgument(3, $dsn['queries']['consumer_key']); - $container->setDefinition('Ovh\Api', $ovh); + $container->setDefinition(\Ovh\Api::class, $ovh); $ovhSender = new Definition(); $ovhSender ->setClass(OvhShortMessageSender::class) - ->setArgument(0, new Reference('Ovh\Api')) + ->setArgument(0, new Reference(\Ovh\Api::class)) ->setArgument(1, $dsn['queries']['service_name']) ->setArgument(2, $dsn['queries']['sender']) ->setArgument(3, new Reference(LoggerInterface::class)) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index 9631900ab..4605f35ab 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -37,7 +37,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_main'); - $rootNode = $treeBuilder->getRootNode('chill_main'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php index 223a7b6cb..d5234bfbe 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php @@ -193,8 +193,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface /** @var WidgetFactoryInterface $factory */ $factory = $this->widgetServices[$alias]; // get the config (under the key which equals to widget_alias - $config = isset($param[$factory->getWidgetAlias()]) ? - $param[$factory->getWidgetAlias()] : []; + $config = $param[$factory->getWidgetAlias()] ?? []; // register the service into the container $serviceId = $this->registerServiceIntoContainer( $container, diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php index a6688fca2..ec603236e 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php @@ -139,7 +139,7 @@ trait AddWidgetConfigurationTrait protected function addWidgetsConfiguration(string $place, ContainerBuilder $containerBuilder) { $treeBuilder = new TreeBuilder($place); - $root = $treeBuilder->getRootNode($place) + $root = $treeBuilder->getRootNode() ->canBeUnset() ->info('register widgets on place "' . $place . '"'); @@ -170,7 +170,7 @@ trait AddWidgetConfigurationTrait // adding the possible config on each widget under the widget_alias foreach ($this->filterWidgetByPlace($place) as $factory) { $builder = new TreeBuilder($factory->getWidgetAlias()); - $widgetOptionsRoot = $builder->getRootNode($factory->getWidgetAlias()); + $widgetOptionsRoot = $builder->getRootNode(); $widgetOptionsRoot->canBeUnset() ->info(sprintf( 'the configuration for the widget "%s" (only required if this widget is set in widget_alias)', diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index 9a0f8b7b3..962050d6f 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -527,28 +527,20 @@ class Address /** * Set streetAddress1 (legacy function). - * - * @param string $streetAddress1 - * - * @return Address */ - public function setStreetAddress1($streetAddress1) + public function setStreetAddress1(?string $streetAddress1): self { - $this->street = null === $streetAddress1 ? '' : $streetAddress1; + $this->street = (string) $streetAddress1; return $this; } /** * Set streetAddress2 (legacy function). - * - * @param string $streetAddress2 - * - * @return Address */ - public function setStreetAddress2($streetAddress2) + public function setStreetAddress2(?string $streetAddress2): self { - $this->streetNumber = null === $streetAddress2 ? '' : $streetAddress2; + $this->streetNumber = (string) $streetAddress2; return $this; } diff --git a/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php b/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php index 560b0dd7f..44e53671d 100644 --- a/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php +++ b/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php @@ -45,7 +45,7 @@ class PrivateCommentEmbeddable public function merge(PrivateCommentEmbeddable $newComment): self { - $currentComments = null === $this->getComments() ? [] : $this->getComments(); + $currentComments = $this->getComments() ?? []; $mergedComments = $newComment->getComments() + $currentComments; diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php index 6b77e5b2b..66db056c4 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php @@ -435,7 +435,7 @@ class SpreadSheetFormatter implements FormatterInterface * Get the displayable result. * * @param string $key - * @param string $value + * @param mixed $value * * @return string */ @@ -445,7 +445,7 @@ class SpreadSheetFormatter implements FormatterInterface $this->initializeCache($key); } - $value = null === $value ? '' : $value; + $value = $value ?? ''; return call_user_func($this->cacheDisplayableResult[$key], $value); } diff --git a/src/Bundle/ChillMainBundle/Form/CenterType.php b/src/Bundle/ChillMainBundle/Form/CenterType.php index 6af579870..ff758ca49 100644 --- a/src/Bundle/ChillMainBundle/Form/CenterType.php +++ b/src/Bundle/ChillMainBundle/Form/CenterType.php @@ -30,7 +30,7 @@ class CenterType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\MainBundle\Entity\Center', + 'data_class' => \Chill\MainBundle\Entity\Center::class, ]); } diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index 8e6861029..5a6776daf 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -75,7 +75,7 @@ final class LocationFormType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\MainBundle\Entity\Location', + 'data_class' => \Chill\MainBundle\Entity\Location::class, ]); } diff --git a/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php b/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php index ad5f7243b..16aafeb41 100644 --- a/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php +++ b/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php @@ -60,7 +60,7 @@ class PermissionsGroupType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\MainBundle\Entity\PermissionsGroup', + 'data_class' => \Chill\MainBundle\Entity\PermissionsGroup::class, ]); } diff --git a/src/Bundle/ChillMainBundle/Form/ScopeType.php b/src/Bundle/ChillMainBundle/Form/ScopeType.php index 86335c554..c5a7657b0 100644 --- a/src/Bundle/ChillMainBundle/Form/ScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/ScopeType.php @@ -36,7 +36,7 @@ class ScopeType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\MainBundle\Entity\Scope', + 'data_class' => \Chill\MainBundle\Entity\Scope::class, ]); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php b/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php index 547aeb3ec..8eda0d9d9 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php +++ b/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php @@ -83,8 +83,8 @@ trait AppendScopeChoiceTypeTrait { $resolver ->setRequired(['center', 'role']) - ->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center') - ->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role'); + ->setAllowedTypes('center', \Chill\MainBundle\Entity\Center::class) + ->setAllowedTypes('role', 'string'); } /** diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php index d78cf813b..cfc838f5a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php @@ -23,12 +23,12 @@ class ComposedGroupCenterType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('permissionsgroup', EntityType::class, [ - 'class' => 'Chill\MainBundle\Entity\PermissionsGroup', + 'class' => \Chill\MainBundle\Entity\PermissionsGroup::class, 'choice_label' => static function (PermissionsGroup $group) { return $group->getName(); }, ])->add('center', EntityType::class, [ - 'class' => 'Chill\MainBundle\Entity\Center', + 'class' => \Chill\MainBundle\Entity\Center::class, 'choice_label' => static function (Center $center) { return $center->getName(); }, @@ -37,7 +37,7 @@ class ComposedGroupCenterType extends AbstractType public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefault('data_class', 'Chill\MainBundle\Entity\GroupCenter'); + $resolver->setDefault('data_class', \Chill\MainBundle\Entity\GroupCenter::class); } public function getBlockPrefix() diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php index 1d541cbd7..a09130c03 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php @@ -98,6 +98,6 @@ class ComposedRoleScopeType extends AbstractType public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefault('data_class', 'Chill\MainBundle\Entity\RoleScope'); + $resolver->setDefault('data_class', \Chill\MainBundle\Entity\RoleScope::class); } } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php index 5b4d49edd..bc4d7d3ef 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php @@ -77,7 +77,7 @@ class Select2CountryType extends AbstractType asort($choices, SORT_STRING | SORT_FLAG_CASE); $resolver->setDefaults([ - 'class' => 'Chill\MainBundle\Entity\Country', + 'class' => \Chill\MainBundle\Entity\Country::class, 'choices' => array_combine(array_values($choices), array_keys($choices)), 'preferred_choices' => array_combine(array_values($preferredChoices), array_keys($preferredChoices)), ]); diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php index 164a138d9..328f3c174 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php @@ -73,7 +73,7 @@ class Select2LanguageType extends AbstractType asort($choices, SORT_STRING | SORT_FLAG_CASE); $resolver->setDefaults([ - 'class' => 'Chill\MainBundle\Entity\Language', + 'class' => \Chill\MainBundle\Entity\Language::class, 'choices' => array_combine(array_values($choices), array_keys($choices)), 'preferred_choices' => array_combine(array_values($preferredChoices), array_keys($preferredChoices)), ]); diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index dc2140997..e2255a1ab 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -167,7 +167,7 @@ class UserType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\MainBundle\Entity\User', + 'data_class' => \Chill\MainBundle\Entity\User::class, ]); $resolver diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index 1b18b3ef8..cc7d70f74 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -196,7 +196,7 @@ class WorkflowStepType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver - ->setDefined('class', EntityWorkflowStep::class) + ->setDefined('class') ->setRequired('transition') ->setAllowedTypes('transition', 'bool') ->setRequired('entity_workflow') diff --git a/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php b/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php index e6e0863a2..7f06bf216 100644 --- a/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php +++ b/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php @@ -78,9 +78,8 @@ class PaginatorFactory $totalItems, $this->getCurrentItemsPerPage(), $this->getCurrentPageNumber(), - null === $route ? $this->getCurrentRoute() : $route, - null === $routeParameters ? $this->getCurrentRouteParameters() : - $routeParameters, + $route ?? $this->getCurrentRoute(), + $routeParameters ?? $this->getCurrentRouteParameters(), $this->router, self::DEFAULT_CURRENT_PAGE_KEY, self::DEFAULT_ITEM_PER_NUMBER_KEY diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index f63d3c04f..a629a45d2 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -91,11 +91,7 @@ class SearchProvider { //sort the array uasort($this->searchServices, static function (SearchInterface $a, SearchInterface $b) { - if ($a->getOrder() === $b->getOrder()) { - return 0; - } - - return ($a->getOrder() < $b->getOrder()) ? -1 : 1; + return $a->getOrder() <=> $b->getOrder(); }); return $this->searchServices; @@ -124,11 +120,7 @@ class SearchProvider { //sort the array uasort($this->hasAdvancedFormSearchServices, static function (SearchInterface $a, SearchInterface $b) { - if ($a->getOrder() === $b->getOrder()) { - return 0; - } - - return ($a->getOrder() < $b->getOrder()) ? -1 : 1; + return $a->getOrder() <=> $b->getOrder(); }); return $this->hasAdvancedFormSearchServices; diff --git a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php index 3c1ff0a75..9dbb38a3f 100644 --- a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php +++ b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php @@ -41,7 +41,7 @@ class RefreshAddressToGeographicalUnitMaterializedViewCronJob implements CronJob return $cronJobExecution->getLastStart() < $now->sub(new DateInterval('P1D')) // introduce a random component to ensure a roll when multiple instances are hosted on same machines - && mt_rand(0, 10) === 0; + && random_int(0, 10) === 0; } public function getKey(): string diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php index a6d9512c7..64acd072a 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php @@ -66,11 +66,11 @@ class PostalCodeBEFromBestAddress gzclose($uncompressedStream); unlink($tmpname); - $this->logger->info(__CLASS__ . ' list of postal code downloaded'); + $this->logger->info(self::class . ' list of postal code downloaded'); $this->baseImporter->finalize(); - $this->logger->info(__CLASS__ . ' postal code fetched', ['offset' => $offset ?? 0]); + $this->logger->info(self::class . ' postal code fetched', ['offset' => $offset ?? 0]); } private function getFileDownloadUrl(string $lang): string diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php index f6cc2bd99..4a63db490 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php @@ -73,7 +73,7 @@ class PostalCodeFRFromOpenData $this->baseImporter->finalize(); fclose($tmpfile); - $this->logger->info(__CLASS__ . ' postal code fetched', ['offset' => $offset ?? 0]); + $this->logger->info(self::class . ' postal code fetched', ['offset' => $offset ?? 0]); } private function handleRecord(array $record): void diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php index af0e3843a..99a75582f 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php @@ -243,7 +243,7 @@ abstract class AbstractAggregatorTest extends KernelTestCase $result = $results[0]; $this->assertTrue( - $result instanceof Traversable || is_array($result), + is_iterable($result), 'test that each row in the result is traversable or an array' ); diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php index 0e5b56ae0..23f6c4b84 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php @@ -230,7 +230,7 @@ abstract class AbstractExportTest extends WebTestCase $result = $results[0]; $this->assertTrue( - $result instanceof Traversable || is_array($result), + is_iterable($result), 'test that each row in the result is traversable or an array' ); diff --git a/src/Bundle/ChillMainBundle/Test/PrepareCenterTrait.php b/src/Bundle/ChillMainBundle/Test/PrepareCenterTrait.php index 343c41180..e43cc8fdb 100644 --- a/src/Bundle/ChillMainBundle/Test/PrepareCenterTrait.php +++ b/src/Bundle/ChillMainBundle/Test/PrepareCenterTrait.php @@ -38,7 +38,7 @@ trait PrepareCenterTrait } $center = $this->centerProphet->prophesize(); - $center->willExtend('\Chill\MainBundle\Entity\Center'); + $center->willExtend('\\' . \Chill\MainBundle\Entity\Center::class); $center->getId()->willReturn($id); $center->getName()->willReturn($name); diff --git a/src/Bundle/ChillMainBundle/Test/PrepareCircleTrait.php b/src/Bundle/ChillMainBundle/Test/PrepareCircleTrait.php index 4621fce04..8cbe9337c 100644 --- a/src/Bundle/ChillMainBundle/Test/PrepareCircleTrait.php +++ b/src/Bundle/ChillMainBundle/Test/PrepareCircleTrait.php @@ -38,7 +38,7 @@ trait PrepareCircleTrait } $scope = $this->circleProphet->prophesize(); - $scope->willExtend('\Chill\MainBundle\Entity\Scope'); + $scope->willExtend('\\' . \Chill\MainBundle\Entity\Scope::class); $scope->getId()->willReturn($id); $scope->getName()->willReturn($name); diff --git a/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php b/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php index 77f5aa1e1..f0a57e1b0 100644 --- a/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php @@ -198,10 +198,10 @@ final class ExportManagerTest extends KernelTestCase //create a formatter $formatterFoo = $this->prophet->prophesize(); - $formatterFoo->willImplement('Chill\MainBundle\Export\FormatterInterface'); + $formatterFoo->willImplement(\Chill\MainBundle\Export\FormatterInterface::class); $formatterFoo->getType()->willReturn('foo'); $formatterBar = $this->prophet->prophesize(); - $formatterBar->willImplement('Chill\MainBundle\Export\FormatterInterface'); + $formatterBar->willImplement(\Chill\MainBundle\Export\FormatterInterface::class); $formatterBar->getType()->willReturn('bar'); $exportManager->addFormatter($formatterFoo->reveal(), 'foo'); $exportManager->addFormatter($formatterBar->reveal(), 'bar'); @@ -380,12 +380,12 @@ final class ExportManagerTest extends KernelTestCase //create a filter and add it to ExportManager $agg = $this->prophet->prophesize(); - $agg->willImplement('Chill\MainBundle\Export\AggregatorInterface'); + $agg->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class); $exportManager->addAggregator($agg->reveal(), 'dummy'); $obtained = $exportManager->getAggregator('dummy'); - $this->assertInstanceof('Chill\MainBundle\Export\AggregatorInterface', $obtained); + $this->assertInstanceof(\Chill\MainBundle\Export\AggregatorInterface::class, $obtained); } public function testGetAggregatorNonExistant() @@ -403,11 +403,11 @@ final class ExportManagerTest extends KernelTestCase //create three filters and add them to ExportManager $aggFoo = $this->prophet->prophesize(); - $aggFoo->willImplement('Chill\MainBundle\Export\AggregatorInterface'); + $aggFoo->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class); $aggBar = $this->prophet->prophesize(); - $aggBar->willImplement('Chill\MainBundle\Export\AggregatorInterface'); + $aggBar->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class); $aggFooBar = $this->prophet->prophesize(); - $aggFooBar->willImplement('Chill\MainBundle\Export\AggregatorInterface'); + $aggFooBar->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class); $exportManager->addAggregator($aggFoo->reveal(), 'foo'); $exportManager->addAggregator($aggBar->reveal(), 'bar'); $exportManager->addAggregator($aggFooBar->reveal(), 'foobar'); @@ -477,12 +477,12 @@ final class ExportManagerTest extends KernelTestCase //create a filter and add it to ExportManager $filter = $this->prophet->prophesize(); - $filter->willImplement('Chill\MainBundle\Export\FilterInterface'); + $filter->willImplement(\Chill\MainBundle\Export\FilterInterface::class); $exportManager->addFilter($filter->reveal(), 'dummy'); $obtained = $exportManager->getFilter('dummy'); - $this->assertInstanceof('Chill\MainBundle\Export\FilterInterface', $obtained); + $this->assertInstanceof(\Chill\MainBundle\Export\FilterInterface::class, $obtained); } public function testGetFilterNonExistant() @@ -500,11 +500,11 @@ final class ExportManagerTest extends KernelTestCase //create three filters and add them to ExportManager $filterFoo = $this->prophet->prophesize(); - $filterFoo->willImplement('Chill\MainBundle\Export\FilterInterface'); + $filterFoo->willImplement(\Chill\MainBundle\Export\FilterInterface::class); $filterBar = $this->prophet->prophesize(); - $filterBar->willImplement('Chill\MainBundle\Export\FilterInterface'); + $filterBar->willImplement(\Chill\MainBundle\Export\FilterInterface::class); $filterFooBar = $this->prophet->prophesize(); - $filterFooBar->willImplement('Chill\MainBundle\Export\FilterInterface'); + $filterFooBar->willImplement(\Chill\MainBundle\Export\FilterInterface::class); $exportManager->addFilter($filterFoo->reveal(), 'foo'); $exportManager->addFilter($filterBar->reveal(), 'bar'); $exportManager->addFilter($filterFooBar->reveal(), 'foobar'); @@ -522,12 +522,12 @@ final class ExportManagerTest extends KernelTestCase //create a formatter $formatter = $this->prophet->prophesize(); - $formatter->willImplement('Chill\MainBundle\Export\FormatterInterface'); + $formatter->willImplement(\Chill\MainBundle\Export\FormatterInterface::class); $exportManager->addFormatter($formatter->reveal(), 'dummy'); $obtained = $exportManager->getFormatter('dummy'); - $this->assertInstanceOf('Chill\MainBundle\Export\FormatterInterface', $obtained); + $this->assertInstanceOf(\Chill\MainBundle\Export\FormatterInterface::class, $obtained); } public function testIsGrantedForElementWithExportAndUserIsGranted() @@ -536,7 +536,7 @@ final class ExportManagerTest extends KernelTestCase $user = $this->prepareUser([]); $authorizationChecker = $this->prophet->prophesize(); - $authorizationChecker->willImplement('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); + $authorizationChecker->willImplement(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class); $authorizationChecker->isGranted('CHILL_STAT_DUMMY', $center) ->willReturn(true); @@ -564,7 +564,7 @@ final class ExportManagerTest extends KernelTestCase $user = $this->prepareUser([]); $authorizationChecker = $this->prophet->prophesize(); - $authorizationChecker->willImplement('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); + $authorizationChecker->willImplement(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class); $authorizationChecker->isGranted('CHILL_STAT_DUMMY', $center) ->willReturn(true); $authorizationChecker->isGranted('CHILL_STAT_DUMMY', $centerB) diff --git a/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php b/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php index ad32ecee7..ffb7c6bed 100644 --- a/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php @@ -101,7 +101,7 @@ final class PickCenterTypeTest extends TypeTestCase $prophet = new \Prophecy\Prophet(); $prophecyCenter = $prophet->prophesize(); - $prophecyCenter->willExtend('\Chill\MainBundle\Entity\Center'); + $prophecyCenter->willExtend('\\' . \Chill\MainBundle\Entity\Center::class); $prophecyCenter->getId()->willReturn($id); $prophecyCenter->getName()->willReturn($name); @@ -122,18 +122,18 @@ final class PickCenterTypeTest extends TypeTestCase //create a center transformer $centerTransformerProphecy = $prophet->prophesize(); $centerTransformerProphecy - ->willExtend('Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer'); + ->willExtend(\Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer::class); $transformer = $centerTransformerProphecy->reveal(); $tokenProphecy = $prophet->prophesize(); $tokenProphecy - ->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + ->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class); $tokenProphecy->getUser()->willReturn($user); $token = $tokenProphecy->reveal(); $tokenStorageProphecy = $prophet->prophesize(); $tokenStorageProphecy - ->willExtend('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage'); + ->willExtend(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage::class); $tokenStorageProphecy->getToken()->willReturn($token); $tokenStorage = $tokenStorageProphecy->reveal(); diff --git a/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php b/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php index 497f91271..9348c6fe2 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php @@ -26,7 +26,7 @@ final class AbstractSearchTest extends \PHPUnit\Framework\TestCase protected function setUp(): void { - $this->stub = $this->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch'); + $this->stub = $this->getMockForAbstractClass(\Chill\MainBundle\Search\AbstractSearch::class); } public function testParseDateRegular() diff --git a/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php b/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php index 362787b84..f9dbcec51 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php @@ -245,7 +245,7 @@ final class SearchProviderTest extends TestCase private function createDefaultSearchService($result, $order) { $mock = $this - ->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch'); + ->getMockForAbstractClass(\Chill\MainBundle\Search\AbstractSearch::class); //set the mock as default $mock->expects($this->any()) @@ -267,7 +267,7 @@ final class SearchProviderTest extends TestCase private function createNonDefaultDomainSearchService($result, $order, $domain) { $mock = $this - ->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch'); + ->getMockForAbstractClass(\Chill\MainBundle\Search\AbstractSearch::class); //set the mock as default $mock->expects($this->any()) diff --git a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php index cc5a49096..8e3c27e99 100644 --- a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php @@ -279,8 +279,8 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); - $entity->willImplement('\Chill\MainBundle\Entity\HasScopeInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class); $entity->getCenter()->willReturn($center); $entity->getScope()->willReturn($scope); @@ -386,7 +386,7 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); $entity->getCenter()->willReturn($center); $this->assertTrue($helper->userHasAccess( @@ -410,7 +410,7 @@ final class AuthorizationHelperTest extends KernelTestCase $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); $entity->getCenter()->willReturn($center); $this->assertTrue($helper->userHasAccess( @@ -434,8 +434,8 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); - $entity->willImplement('\Chill\MainBundle\Entity\HasScopeInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class); $entity->getCenter()->willReturn($centerB); $entity->getScope()->willReturn($scope); @@ -455,7 +455,7 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); $entity->getCenter()->willReturn($center); $this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE')); @@ -474,8 +474,8 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); - $entity->willImplement('\Chill\MainBundle\Entity\HasScopeInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class); $entity->getCenter()->willReturn($center); $entity->getScope()->willReturn($scope); @@ -506,7 +506,7 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); $entity->getCenter()->willReturn($centerA); $this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE')); diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index bb03a6b33..4b1c10e0f 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -162,7 +162,7 @@ final class PersonController extends AbstractController $cFGroup = null; $cFDefaultGroup = $this->em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup::class) - ->findOneByEntity('Chill\\PersonBundle\\Entity\\Person'); + ->findOneByEntity(\Chill\PersonBundle\Entity\Person::class); if ($cFDefaultGroup) { $cFGroup = $cFDefaultGroup->getCustomFieldsGroup(); diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php index 14434be6e..87746842a 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php @@ -125,12 +125,12 @@ class LoadCustomFields extends AbstractFixture implements // select a set of people and add data foreach ($personIds as $id) { // add info on 1 person on 2 - if (mt_rand(0, 1) === 1) { + if (random_int(0, 1) === 1) { /** @var Person $person */ $person = $manager->getRepository(Person::class)->find($id); $person->setCFData([ 'remarques' => $this->createCustomFieldText() - ->serialize($faker->text(mt_rand(150, 250)), $this->customFieldText), + ->serialize($faker->text(random_int(150, 250)), $this->customFieldText), 'document-d-identite' => $this->createCustomFieldChoice() ->serialize([$choices[array_rand($choices)]], $this->customFieldChoice), ]); diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index d60e15e41..6a2dc924e 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -1006,7 +1006,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac 'property' => 'step', ], 'supports' => [ - 'Chill\PersonBundle\Entity\AccompanyingPeriod', + \Chill\PersonBundle\Entity\AccompanyingPeriod::class, ], 'initial_marking' => 'DRAFT', 'places' => [ @@ -1043,7 +1043,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $container->prependExtensionConfig( 'chill_custom_fields', ['customizables_entities' => [ - ['class' => 'Chill\PersonBundle\Entity\Person', 'name' => 'PersonEntity'], + ['class' => \Chill\PersonBundle\Entity\Person::class, 'name' => 'PersonEntity'], ], ] ); diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php index f9686c900..a591663ad 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php @@ -30,7 +30,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('cl_chill_person'); - $rootNode = $treeBuilder->getRootNode('cl_chill_person'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->canBeDisabled() @@ -137,7 +137,7 @@ class Configuration implements ConfigurationInterface private function addFieldNode($key) { $tree = new TreeBuilder($key, 'enum'); - $node = $tree->getRootNode($key); + $node = $tree->getRootNode(); switch ($key) { case 'accompanying_period': diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php index b463312c8..48e1ac1fc 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php @@ -200,7 +200,7 @@ class Household */ public function getCurrentAddress(?DateTime $at = null): ?Address { - $at = null === $at ? new DateTime('today') : $at; + $at = $at ?? new DateTime('today'); $addrs = $this->getAddresses()->filter(static function (Address $a) use ($at) { return $a->getValidFrom() <= $at && ( @@ -412,7 +412,7 @@ class Household { $criteria = new Criteria(); $expr = Criteria::expr(); - $date = null === $now ? (new DateTimeImmutable('today')) : $now; + $date = $now ?? new DateTimeImmutable('today'); $criteria ->where( @@ -634,7 +634,7 @@ class Household { $criteria = new Criteria(); $expr = Criteria::expr(); - $date = null === $now ? (new DateTimeImmutable('today')) : $now; + $date = $now ?? new DateTimeImmutable('today'); $criteria ->where($expr->orX( diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php index e5e5e4626..031279173 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php @@ -142,7 +142,7 @@ class HouseholdMember public function isCurrent(?DateTimeImmutable $at = null): bool { - $at = null === $at ? new DateTimeImmutable('now') : $at; + $at = $at ?? new DateTimeImmutable('now'); return $this->getStartDate() < $at && ( null === $this->getEndDate() || $this->getEndDate() > $at diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 27c34ba23..63bd6efba 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -1087,7 +1087,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI { $criteria = new Criteria(); $expr = Criteria::expr(); - $date = null === $at ? new DateTimeImmutable('today') : $at; + $date = $at ?? new DateTimeImmutable('today'); $datef = $date->format('Y-m-d'); if ( diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php index 0bf175ce4..c05f97ca8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php @@ -42,8 +42,8 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface { $where = $qb->getDQLPart('where'); - $min = null !== $data['min_age'] ? $data['min_age'] : 0; - $max = null !== $data['max_age'] ? $data['max_age'] : 150; + $min = $data['min_age'] ?? 0; + $max = $data['max_age'] ?? 150; $calc = $this->rollingDateConverter->convert($data['date_calc']); $minDate = $calc->sub(new DateInterval('P' . $max . 'Y')); diff --git a/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php b/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php index f6bf4962e..25d380562 100644 --- a/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php +++ b/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php @@ -98,7 +98,7 @@ class AccompanyingPeriodType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\PersonBundle\Entity\AccompanyingPeriod', + 'data_class' => \Chill\PersonBundle\Entity\AccompanyingPeriod::class, ]); $resolver diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 15888c015..42e62929d 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -250,7 +250,7 @@ class PersonType extends AbstractType $resolver->setAllowedTypes( 'cFGroup', - ['null', 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup'] + ['null', \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class] ); } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php index 0099e6367..f057bc1d1 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php @@ -40,13 +40,13 @@ class Select2MaritalStatusType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $transformer = new ObjectToIdTransformer($this->em, 'Chill\PersonBundle\Entity\MaritalStatus'); + $transformer = new ObjectToIdTransformer($this->em, \Chill\PersonBundle\Entity\MaritalStatus::class); $builder->addModelTransformer($transformer); } public function configureOptions(OptionsResolver $resolver) { - $maritalStatuses = $this->em->getRepository('Chill\PersonBundle\Entity\MaritalStatus')->findAll(); + $maritalStatuses = $this->em->getRepository(\Chill\PersonBundle\Entity\MaritalStatus::class)->findAll(); $choices = []; foreach ($maritalStatuses as $ms) { diff --git a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php index bdb7a8eca..2b2564091 100644 --- a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php +++ b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php @@ -168,7 +168,7 @@ class MembersEditor $criteria->where( $expr->andX( $expr->lt('startDate', $date), - $expr->isNull('endDate', $date) + $expr->isNull('endDate') ) ); diff --git a/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php index 424411a72..5f75d537b 100644 --- a/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php @@ -44,7 +44,7 @@ class ResidentialAddressRepository extends ServiceEntityRepository public function buildQueryFindCurrentResidentialAddresses(Person $person, ?DateTimeImmutable $at = null): QueryBuilder { - $date = null === $at ? new DateTimeImmutable('today') : $at; + $date = $at ?? new DateTimeImmutable('today'); $qb = $this->createQueryBuilder('ra'); $dateFilter = $qb->expr()->andX( diff --git a/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php b/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php index 2a608e4c1..a5663050a 100644 --- a/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php +++ b/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php @@ -34,7 +34,7 @@ class OldDraftAccompanyingPeriodRemover implements OldDraftAccompanyingPeriodRem public function remove(DateInterval $interval): void { - $this->logger->debug('[' . __CLASS__ . '] start to remove old periods', [ + $this->logger->debug('[' . self::class . '] start to remove old periods', [ 'interval' => $interval->format('%d days'), ]); @@ -96,7 +96,7 @@ class OldDraftAccompanyingPeriodRemover implements OldDraftAccompanyingPeriodRem ]; }); - $this->logger->info('[' . __CLASS__ . '] periods removed', array_merge($results, [ + $this->logger->info('[' . self::class . '] periods removed', array_merge($results, [ 'interval' => $interval->format('%d days'), ])); } diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php index e35766a75..4f9977b6d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php @@ -162,7 +162,7 @@ final class PersonMoveEventSubscriberTest extends KernelTestCase ->setNextMembership($nextMembership); $notificationPersister = $this->prophesize(NotificationPersisterInterface::class); - $notificationPersister->persist(Argument::type(Notification::class))->shouldBeCalled(1); + $notificationPersister->persist(Argument::type(Notification::class))->shouldBeCalled(); $eventSubscriber = $this->buildSubscriber(null, $notificationPersister->reveal(), null, null); $eventSubscriber->resetPeriodLocation($event); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php index fbba0bbc3..6f92c864b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php @@ -89,7 +89,7 @@ final class PersonControllerCreateTest extends WebTestCase $form = $crawler->selectButton('Ajouter la personne')->form(); $this->assertInstanceOf( - 'Symfony\Component\DomCrawler\Form', + \Symfony\Component\DomCrawler\Form::class, $form, 'The page contains a butto ' ); diff --git a/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php b/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php index d7f08a3a4..e6651028c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php @@ -158,7 +158,7 @@ final class PersonVoterTest extends KernelTestCase { $token = $this->prophet->prophesize(); $token - ->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + ->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class); if (null === $permissions) { $token->getUser()->willReturn(null); diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkDocGenNormalizerTest.php index e71e0bf51..ce226834b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkDocGenNormalizerTest.php @@ -88,7 +88,7 @@ final class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase $this->assertEqualsCanonicalizing(array_keys($expected), array_keys($actual)); foreach ($expected as $key => $item) { - if ('@ignored' === $item) { + if (0 === $item) { continue; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php index 44414cdba..17c6195b3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php @@ -187,8 +187,7 @@ final class PersonContextTest extends TestCase { $builder = $this->prophesize(FormBuilderInterface::class); - $builder->add('title', TextType::class, Argument::type('array')) - ->shouldBeCalled(1); + $builder->add('title', TextType::class, Argument::type('array'))->shouldBeCalled(); if ($withScope) { $builder->add('scope', ScopePickerType::class, Argument::type('array')) diff --git a/src/Bundle/ChillReportBundle/Controller/ReportController.php b/src/Bundle/ChillReportBundle/Controller/ReportController.php index 0a62a4b33..da39aedec 100644 --- a/src/Bundle/ChillReportBundle/Controller/ReportController.php +++ b/src/Bundle/ChillReportBundle/Controller/ReportController.php @@ -344,7 +344,7 @@ class ReportController extends AbstractController } $cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class) - ->findByEntity('Chill\ReportBundle\Entity\Report'); + ->findByEntity(\Chill\ReportBundle\Entity\Report::class); if (count($cFGroups) === 1) { return $this->redirect( @@ -403,7 +403,7 @@ class ReportController extends AbstractController $em = $this->getDoctrine()->getManager(); $cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class) - ->findByEntity('Chill\ReportBundle\Entity\Report'); + ->findByEntity(\Chill\ReportBundle\Entity\Report::class); if (count($cFGroups) === 1) { return $this->redirect( diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php index 5eebbaad1..a9b8edc30 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php @@ -68,15 +68,15 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface ]; for ($i = 0; 25 >= $i; ++$i) { - $cFType = $cFTypes[mt_rand(0, count($cFTypes) - 1)]; + $cFType = $cFTypes[random_int(0, count($cFTypes) - 1)]; $customField = (new CustomField()) ->setSlug("cf_report_{$i}") ->setType($cFType['type']) ->setOptions($cFType['options']) ->setName(['fr' => "CustomField {$i}"]) - ->setOrdering(mt_rand(0, 1000) / 1000) - ->setCustomFieldsGroup($this->getReference('cf_group_report_' . (mt_rand(0, 3)))); + ->setOrdering(random_int(0, 1000) / 1000) + ->setCustomFieldsGroup($this->getReference('cf_group_report_' . (random_int(0, 3)))); $manager->persist($customField); } diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomFieldsGroup.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomFieldsGroup.php index 47cc2511d..32bd5c346 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomFieldsGroup.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomFieldsGroup.php @@ -66,7 +66,7 @@ class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInt $cFGroup = (new CustomFieldsGroup()) ->setName($name) - ->setEntity('Chill\ReportBundle\Entity\Report') + ->setEntity(\Chill\ReportBundle\Entity\Report::class) ->setOptions($options); $manager->persist($cFGroup); diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php index 2148a370a..db4646eed 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php @@ -88,7 +88,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or $report = (new Report()) ->setPerson($person) ->setCFGroup( - mt_rand(0, 10) > 5 ? + random_int(0, 10) > 5 ? $this->getReference('cf_group_report_logement') : $this->getReference('cf_group_report_education') ) @@ -111,7 +111,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or //set date. 30% of the dates are 2015-05-01 $expectedDate = new DateTime('2015-01-05'); - if (mt_rand(0, 100) < 30) { + if (random_int(0, 100) < 30) { $report->setDate($expectedDate); } else { $report->setDate($this->faker->dateTimeBetween('-1 year', 'now') @@ -155,7 +155,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or $selectedPeople = []; foreach ($people as $person) { - if (mt_rand(0, 100) < $percentage) { + if (random_int(0, 100) < $percentage) { $selectedPeople[] = $person; } } @@ -183,7 +183,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or $picked = []; if ($multiple) { - $numberSelected = mt_rand(1, count($choices) - 1); + $numberSelected = random_int(1, count($choices) - 1); for ($i = 0; $i < $numberSelected; ++$i) { $picked[] = $this->pickChoice($choices); diff --git a/src/Bundle/ChillReportBundle/DependencyInjection/ChillReportExtension.php b/src/Bundle/ChillReportBundle/DependencyInjection/ChillReportExtension.php index 9d8bf8fbe..8f1c5d0d4 100644 --- a/src/Bundle/ChillReportBundle/DependencyInjection/ChillReportExtension.php +++ b/src/Bundle/ChillReportBundle/DependencyInjection/ChillReportExtension.php @@ -41,7 +41,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac 'chill_custom_fields', ['customizables_entities' => [ [ - 'class' => 'Chill\ReportBundle\Entity\Report', + 'class' => \Chill\ReportBundle\Entity\Report::class, 'name' => 'ReportEntity', 'options' => [ 'summary_fields' => [ diff --git a/src/Bundle/ChillReportBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillReportBundle/DependencyInjection/Configuration.php index 565ff08a7..70c9f532b 100644 --- a/src/Bundle/ChillReportBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillReportBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_report'); - $rootNode = $treeBuilder->getRootNode('chill_report'); + $rootNode = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for diff --git a/src/Bundle/ChillReportBundle/Form/ReportType.php b/src/Bundle/ChillReportBundle/Form/ReportType.php index 435d894d9..8d6551443 100644 --- a/src/Bundle/ChillReportBundle/Form/ReportType.php +++ b/src/Bundle/ChillReportBundle/Form/ReportType.php @@ -88,14 +88,14 @@ class ReportType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\ReportBundle\Entity\Report', + 'data_class' => \Chill\ReportBundle\Entity\Report::class, ]); $resolver->setRequired([ 'cFGroup', ]); - $resolver->setAllowedTypes('cFGroup', 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup'); + $resolver->setAllowedTypes('cFGroup', \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class); $this->appendScopeChoicesOptions($resolver); } diff --git a/src/Bundle/ChillReportBundle/Search/ReportSearch.php b/src/Bundle/ChillReportBundle/Search/ReportSearch.php index 55bbe9f66..e392c37f5 100644 --- a/src/Bundle/ChillReportBundle/Search/ReportSearch.php +++ b/src/Bundle/ChillReportBundle/Search/ReportSearch.php @@ -167,7 +167,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface ->orderBy('r.date', 'desc'); $reportQuery = $qb->getQuery(); - $reportQuery->setFetchMode('Chill\\ReportBundle\\Entity\\Report', 'person', \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER); + $reportQuery->setFetchMode(\Chill\ReportBundle\Entity\Report::class, 'person', \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER); return $reportQuery->getResult(); } diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php index ea30084ae..d299860bc 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php @@ -64,7 +64,7 @@ final class ReportControllerNextTest extends WebTestCase $customFieldsGroups = self::$kernel->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class) - ->findBy(['entity' => 'Chill\ReportBundle\Entity\Report']); + ->findBy(['entity' => \Chill\ReportBundle\Entity\Report::class]); //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php index 6a6ee99f1..1afe851b8 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php @@ -82,7 +82,7 @@ final class ReportControllerTest extends WebTestCase $customFieldsGroups = self::$kernel->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class) - ->findBy(['entity' => 'Chill\ReportBundle\Entity\Report']); + ->findBy(['entity' => \Chill\ReportBundle\Entity\Report::class]); //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, @@ -132,7 +132,7 @@ final class ReportControllerTest extends WebTestCase $form = $crawlerAddAReportPage->selectButton('Créer un nouveau rapport')->form(); $this->assertInstanceOf( - 'Symfony\Component\DomCrawler\Form', + \Symfony\Component\DomCrawler\Form::class, $form, 'I can see a form with a button "add a new report" ' ); @@ -251,7 +251,7 @@ final class ReportControllerTest extends WebTestCase $link = $crawlerPersonPage->selectLink("AJOUT D'UN RAPPORT")->link(); $this->assertInstanceOf( - 'Symfony\Component\DomCrawler\Link', + \Symfony\Component\DomCrawler\Link::class, $link, 'There is a "add a report" link in menu' ); @@ -278,7 +278,7 @@ final class ReportControllerTest extends WebTestCase ->form(); $this->assertInstanceOf( - 'Symfony\Component\DomCrawler\Form', + \Symfony\Component\DomCrawler\Form::class, $addForm, 'I have a report form' ); diff --git a/src/Bundle/ChillReportBundle/Tests/DependencyInjection/ChillReportExtensionTest.php b/src/Bundle/ChillReportBundle/Tests/DependencyInjection/ChillReportExtensionTest.php index 2b02159ca..e480ca960 100644 --- a/src/Bundle/ChillReportBundle/Tests/DependencyInjection/ChillReportExtensionTest.php +++ b/src/Bundle/ChillReportBundle/Tests/DependencyInjection/ChillReportExtensionTest.php @@ -32,7 +32,7 @@ final class ChillReportExtensionTest extends KernelTestCase $reportFounded = false; foreach ($customizablesEntities as $customizablesEntity) { - if ('Chill\ReportBundle\Entity\Report' === $customizablesEntity['class']) { + if (\Chill\ReportBundle\Entity\Report::class === $customizablesEntity['class']) { $reportFounded = true; } } diff --git a/src/Bundle/ChillReportBundle/Tests/Security/Authorization/ReportVoterTest.php b/src/Bundle/ChillReportBundle/Tests/Security/Authorization/ReportVoterTest.php index be32edc8d..4179df56d 100644 --- a/src/Bundle/ChillReportBundle/Tests/Security/Authorization/ReportVoterTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Security/Authorization/ReportVoterTest.php @@ -167,7 +167,7 @@ final class ReportVoterTest extends KernelTestCase { $token = $this->prophet->prophesize(); $token - ->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + ->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class); if (null === $user) { $token->getUser()->willReturn(null); diff --git a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php index 9f39fb87e..ecaabb495 100644 --- a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php @@ -191,6 +191,6 @@ final class TimelineProviderTest extends WebTestCase } } - return $groups[mt_rand(0, count($groups) - 1)]; + return $groups[random_int(0, count($groups) - 1)]; } } diff --git a/src/Bundle/ChillTaskBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillTaskBundle/DependencyInjection/Configuration.php index 8c57ef0f6..f01050684 100644 --- a/src/Bundle/ChillTaskBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillTaskBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_task'); - $rootNode = $treeBuilder->getRootNode('chill_task'); + $rootNode = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for diff --git a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php index 4933b063c..2ecd2f5de 100644 --- a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php @@ -71,7 +71,7 @@ class MenuBuilder implements LocalMenuBuilderInterface break; case 'section': - $menu->setExtras('icons', 'tasks'); + $menu->setExtras('icons'); break; diff --git a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php index e5414cac1..4d8ddd062 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php @@ -108,7 +108,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface { $workflow = $this->registry->get( $entity->getTask(), - (isset($entity->getData()['workflow'])) ? $entity->getData()['workflow'] : null + $entity->getData()['workflow'] ?? null ); // sf4 check: prevent error message: // `Notice: Undefined property: Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent::$getData` diff --git a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/Configuration.php index 3248f58d7..d4c2cd598 100644 --- a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_third_party'); - $rootNode = $treeBuilder->getRootNode('chill_third_party'); + $rootNode = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for From 4c5dae60a8d5f68a28879ca29ab56f60191862dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 29 Mar 2023 22:39:11 +0200 Subject: [PATCH 02/43] DX: apply rector rulesets up to PHP 73 --- .../Export/LinkedToPerson/ListActivity.php | 4 +- .../Export/Export/ListActivityHelper.php | 2 +- .../JsonCustomFieldToArrayTransformer.php | 2 +- .../GeneratorDriver/RelatorioDriver.php | 4 +- .../Form/StoredObjectType.php | 4 +- .../Controller/ExportController.php | 2 +- .../Controller/SearchController.php | 4 +- .../ChillMainBundle/Doctrine/Model/Point.php | 4 +- .../Export/Helper/AggregateStringHelper.php | 2 +- .../Export/Helper/ExportAddressHelper.php | 4 +- .../TranslatableStringExportLabelHelper.php | 4 +- .../Export/Helper/UserHelper.php | 2 +- .../EntityToJsonTransformer.php | 2 +- .../Phonenumber/PhonenumberHelper.php | 2 +- .../PermissionApiControllerTest.php | 4 +- .../PostalCodeApiControllerTest.php | 2 +- .../Controller/UserApiControllerTest.php | 2 +- .../GeographicalUnitBaseImporterTest.php | 4 +- .../migrations/Version20180709181423.php | 40 +++++++-------- .../ReassignAccompanyingPeriodController.php | 4 +- .../Export/Export/ListAccompanyingPeriod.php | 6 +-- .../Export/Export/ListPerson.php | 4 +- .../Export/Helper/LabelPersonHelper.php | 2 +- .../Export/Helper/ListPersonHelper.php | 2 +- .../AccompanyingPeriodConfidentialTest.php | 2 +- .../AccompanyingCourseApiControllerTest.php | 42 ++++++++-------- .../Controller/HouseholdApiControllerTest.php | 2 +- .../HouseholdMemberControllerTest.php | 4 +- .../Controller/PersonApiControllerTest.php | 2 +- .../RelationshipApiControllerTest.php | 2 +- .../SocialIssueApiControllerTest.php | 4 +- .../SocialWorkEvaluationApiControllerTest.php | 2 +- .../migrations/Version20160818113633.php | 2 +- .../migrations/Version20181023101621.php | 50 +++++++++---------- .../migrations/Version20200130213446.php | 28 +++++------ .../Export/Export/ReportList.php | 6 +-- .../Export/Helper/LabelThirdPartyHelper.php | 2 +- 37 files changed, 129 insertions(+), 131 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index 5d438d3a5..8b69216b6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -152,7 +152,7 @@ class ListActivity implements ListInterface, GroupedExportInterface return 'circle'; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; case 'type_name': @@ -161,7 +161,7 @@ class ListActivity implements ListInterface, GroupedExportInterface return 'activity type'; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; default: diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php index 0e8b28ab4..fae6ea6a6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php @@ -179,7 +179,7 @@ class ListActivityHelper } } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); return implode( '|', diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php index 6bd12a07a..bccf797e5 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php @@ -108,7 +108,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface //echo json_encode($customFieldsArrayRet); - return json_encode($customFieldsArrayRet); + return json_encode($customFieldsArrayRet, JSON_THROW_ON_ERROR); } public function transform($customFieldsJSON) diff --git a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php index 0f62931b4..c14b67df7 100644 --- a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php +++ b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php @@ -44,7 +44,7 @@ final class RelatorioDriver implements DriverInterface { $form = new FormDataPart( [ - 'variables' => json_encode($data), + 'variables' => json_encode($data, JSON_THROW_ON_ERROR), 'template' => new DataPart($template, $templateName ?? uniqid('template_'), $resourceType), ] ); @@ -61,7 +61,7 @@ final class RelatorioDriver implements DriverInterface $content = $e->getResponse()->getContent(false); if (400 === $e->getResponse()->getStatusCode()) { - $content = json_decode($content, true); + $content = json_decode($content, true, 512, JSON_THROW_ON_ERROR); $this->logger->error('relatorio: template error', [ 'error' => $content['message'] ?? '_not defined', ]); diff --git a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php index 664e7a2aa..4f3cd315f 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php @@ -95,7 +95,7 @@ class StoredObjectType extends AbstractType return null; } - return json_decode($value, true); + return json_decode($value, true, 512, JSON_THROW_ON_ERROR); } public function reverseTransformObject($object) @@ -120,7 +120,7 @@ class StoredObjectType extends AbstractType return null; } - return json_encode($object); + return json_encode($object, JSON_THROW_ON_ERROR); } public function transformObject($object = null) diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 686b4cbce..6c4ea0269 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -665,7 +665,7 @@ class ExportController extends AbstractController $this->logger->notice('[export] choices for an export unserialized', [ 'key' => $key, - 'rawData' => json_encode($rawData), + 'rawData' => json_encode($rawData, JSON_THROW_ON_ERROR), ]); return $rawData; diff --git a/src/Bundle/ChillMainBundle/Controller/SearchController.php b/src/Bundle/ChillMainBundle/Controller/SearchController.php index 8592dd2c3..7eec60324 100644 --- a/src/Bundle/ChillMainBundle/Controller/SearchController.php +++ b/src/Bundle/ChillMainBundle/Controller/SearchController.php @@ -109,10 +109,8 @@ class SearchController extends AbstractController ->getHasAdvancedFormSearchServices(); if (count($advancedSearchProviders) === 1) { - reset($advancedSearchProviders); - return $this->redirectToRoute('chill_main_advanced_search', [ - 'name' => key($advancedSearchProviders), + 'name' => array_key_first($advancedSearchProviders), ]); } diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php index c4c18d179..684030ee3 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php @@ -41,7 +41,7 @@ class Point implements JsonSerializable public static function fromGeoJson(string $geojson): self { - $a = json_decode($geojson); + $a = json_decode($geojson, null, 512, JSON_THROW_ON_ERROR); if (null === $a) { throw PointException::badJsonString($geojson); @@ -96,7 +96,7 @@ class Point implements JsonSerializable { $array = $this->toArrayGeoJson(); - return json_encode($array); + return json_encode($array, JSON_THROW_ON_ERROR); } public function toWKT(): string diff --git a/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php index 6266ce86f..3ee5f20d8 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php @@ -29,7 +29,7 @@ class AggregateStringHelper return implode( '|', - json_decode($value, true) + json_decode($value, true, 512, JSON_THROW_ON_ERROR) ); }; } diff --git a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php index 9077b501a..c9882f557 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php @@ -310,7 +310,7 @@ class ExportAddressHelper return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; case 'isNoAddress': @@ -369,7 +369,7 @@ class ExportAddressHelper return ''; } - $decodedValues = json_decode($value, true); + $decodedValues = json_decode($value, true, 512, JSON_THROW_ON_ERROR); switch (count($decodedValues)) { case 0: diff --git a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php index 44ce2b194..9b49d476b 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php @@ -39,7 +39,7 @@ class TranslatableStringExportLabelHelper return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; } @@ -54,7 +54,7 @@ class TranslatableStringExportLabelHelper return ''; } - $decoded = json_decode($value, true); + $decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR); return implode( '|', diff --git a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php index 0e770786d..2821bf1a6 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php @@ -54,7 +54,7 @@ class UserHelper return ''; } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); if (0 === count($decoded)) { return ''; diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index 46fa8799f..d4759a794 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -43,7 +43,7 @@ class EntityToJsonTransformer implements DataTransformerInterface public function reverseTransform($value) { - $denormalized = json_decode($value, true); + $denormalized = json_decode($value, true, 512, JSON_THROW_ON_ERROR); if ($this->multiple) { if (null === $denormalized) { diff --git a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php index 9ee013b1a..a92db39ce 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php @@ -224,7 +224,7 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface return null; } - $validation = json_decode($response->getBody()->getContents())->carrier->type; + $validation = json_decode($response->getBody()->getContents(), null, 512, JSON_THROW_ON_ERROR)->carrier->type; $item ->set($validation) diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php index 59adb374a..2b89ec3db 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php @@ -44,7 +44,7 @@ final class PermissionApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertFalse($data['roles']['FOO_ROLE']); } @@ -67,7 +67,7 @@ final class PermissionApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue($data['roles']['ROLE_USER']); $this->assertFalse($data['roles']['ROLE_ADMIN']); } diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php index 31bfab285..a777be44c 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php @@ -35,7 +35,7 @@ final class PostalCodeApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertEquals('Fontenay Le Comte', $data['results'][0]['name']); diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php index 57800c6cb..ef421020e 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php @@ -47,7 +47,7 @@ final class UserApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(array_key_exists('count', $data)); $this->assertGreaterThan(0, $data['count']); $this->assertTrue(array_key_exists('results', $data)); diff --git a/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php b/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php index 33198c500..b3bd856ff 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php @@ -64,7 +64,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase $this->assertEquals($results['unitrefid'], 'layer_one'); $this->assertEquals($results['unitname'], 'Layer one'); - $this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer']); + $this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer']); $this->assertEquals($results['layerrefid'], 'test'); $this->assertEquals($results['geom'], 'MULTIPOLYGON(((30 20,45 40,10 40,30 20)),((15 5,40 10,10 20,5 10,15 5)))'); @@ -93,7 +93,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase $this->assertEquals($results['unitrefid'], 'layer_one'); $this->assertEquals($results['unitname'], 'Layer one fixed'); - $this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer fixed']); + $this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer fixed']); $this->assertEquals($results['layerrefid'], 'test'); $this->assertEquals($results['geom'], 'MULTIPOLYGON(((130 120,45 40,10 40,130 120)),((0 0,15 5,40 10,10 20,0 0)))'); } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php b/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php index 5da4509bf..1c410970b 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php @@ -49,18 +49,18 @@ final class Version20180709181423 extends AbstractMigration $this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E9885281E ON users (emailCanonical)'); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS - $BODY$ - BEGIN - IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN - UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; - END IF; + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS + $BODY$ + BEGIN + IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN + UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; + END IF; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL - SQL + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL +SQL_WRAP ); $this->addSql( @@ -74,16 +74,16 @@ final class Version20180709181423 extends AbstractMigration ); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS - $BODY$ - BEGIN - UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS + $BODY$ + BEGIN + UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); $this->addSql( diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 5b2de9f65..bafc4b1cb 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -120,7 +120,7 @@ class ReassignAccompanyingPeriodController extends AbstractController $assignForm->handleRequest($request); if ($assignForm->isSubmitted() && $assignForm->isValid()) { - $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true); + $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true, 512, JSON_THROW_ON_ERROR); $userTo = $assignForm->get('userTo')->getData(); $userFrom = $assignForm->get('userFrom')->getData(); @@ -179,7 +179,7 @@ class ReassignAccompanyingPeriodController extends AbstractController { $defaultData = [ 'userFrom' => $userFrom, - 'periods' => json_encode($periodIds), + 'periods' => json_encode($periodIds, JSON_THROW_ON_ERROR), ]; $builder = $this->formFactory->createNamedBuilder('reassign', FormType::class, $defaultData); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 8c96906fc..cacdf2ee1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -182,7 +182,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; case 'locationPersonName': @@ -226,7 +226,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface '|', array_map( fn ($s) => $this->translatableStringHelper->localize($s), - json_decode($value, true) + json_decode($value, true, 512, JSON_THROW_ON_ERROR) ) ); }; @@ -245,7 +245,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface '|', array_map( fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []), - json_decode($value, true) + json_decode($value, true, 512, JSON_THROW_ON_ERROR) ) ); }; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index acaeb498c..21675a86a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -334,7 +334,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou return $this->customFieldProvider ->getCustomFieldByType($cf->getType()) - ->render(json_decode($value, true), $cf, 'csv'); + ->render(json_decode($value, true, 512, JSON_THROW_ON_ERROR), $cf, 'csv'); }; if ($cfType instanceof CustomFieldChoice && $cfType->isMultiple($cf)) { @@ -344,7 +344,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou if (null === $value) { return ''; } - $decoded = json_decode($value, true); + $decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR); if ('_header' === $value) { $label = $cfType->getChoices($cf)[$slugChoice]; diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php index 2cfc8d3cf..fc196dd50 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php @@ -39,7 +39,7 @@ class LabelPersonHelper return ''; } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); if (0 === count($decoded)) { return ''; diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php index de8870674..77a1d9c86 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php @@ -361,7 +361,7 @@ class ListPersonHelper return ''; } - $ids = json_decode($value); + $ids = json_decode($value, null, 512, JSON_THROW_ON_ERROR); return implode( diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php index 1d1711ce4..dc5c5c2ce 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php @@ -110,7 +110,7 @@ final class AccompanyingPeriodConfidentialTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'accompanying_period', 'user' => $user]) + json_encode(['type' => 'accompanying_period', 'user' => $user], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index 154dbd884..596e0a870 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -313,10 +313,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'person', 'id' => $personId]) + json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -338,7 +338,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase } $response = $this->client->getResponse(); - $data = json_decode($response->getContent()); + $data = json_decode($response->getContent(), null, 512, JSON_THROW_ON_ERROR); // check that the person id is contained $participationsPersonsIds = array_map( @@ -357,10 +357,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'person', 'id' => $personId]) + json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -387,7 +387,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], - json_encode(['type' => 'social_issue', 'id' => $si->getId()]) + json_encode(['type' => 'social_issue', 'id' => $si->getId()], JSON_THROW_ON_ERROR) ); $this->assertTrue(in_array($this->client->getResponse()->getStatusCode(), [200, 422], true)); @@ -396,7 +396,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase $this->markTestSkipped('the next tests should appears only on valid accompanying period'); } - $data = json_decode($this->client->getResponse()->getContent(), true); + $data = json_decode($this->client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('id', $data); $this->assertArrayHasKey('type', $data); $this->assertEquals('social_issue', $data['type']); @@ -407,7 +407,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], - json_encode(['type' => 'social_issue', 'id' => $si->getId()]) + json_encode(['type' => 'social_issue', 'id' => $si->getId()], JSON_THROW_ON_ERROR) ); $this->assertTrue(in_array($this->client->getResponse()->getStatusCode(), [200, 422], true)); @@ -427,7 +427,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase $this->markTestSkipped('the next tests should appears only on valid accompanying period'); } - $data = json_decode($response->getContent()); + $data = json_decode($response->getContent(), null, 512, JSON_THROW_ON_ERROR); $this->assertEquals( $data->id, $periodId, @@ -453,7 +453,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'accompanying_period', 'emergency' => !$initialValueEmergency]) + json_encode(['type' => 'accompanying_period', 'emergency' => !$initialValueEmergency], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); @@ -492,7 +492,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_comment', 'content' => 'this is a text']) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -508,10 +508,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'accompanying_period_comment', 'id' => $data['id']]) + json_encode(['type' => 'accompanying_period_comment', 'id' => $data['id']], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); } @@ -568,10 +568,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'person', 'id' => $personId]) + json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -595,10 +595,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'thirdparty', 'id' => $thirdPartyId]) + json_encode(['type' => 'thirdparty', 'id' => $thirdPartyId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -655,7 +655,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_resource', 'resource' => ['type' => 'person', 'id' => $personId]]) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -680,7 +680,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], //server - json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()]) + json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -699,7 +699,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_resource', 'resource' => ['type' => 'thirdparty', 'id' => $thirdPartyId]]) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -724,7 +724,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], //server - json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()]) + json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php index 8686172ee..710c5fc6b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -157,7 +157,7 @@ final class HouseholdApiControllerTest extends WebTestCase ); $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('count', $data); $this->assertArrayHasKey('results', $data); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php index 34c7e3113..56000c3e0 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php @@ -179,7 +179,7 @@ final class HouseholdMemberControllerTest extends WebTestCase $client->getResponse()->getStatusCode() ); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertEquals(null, $data); } @@ -284,7 +284,7 @@ final class HouseholdMemberControllerTest extends WebTestCase $client->getResponse()->getStatusCode() ); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertIsArray($data); $this->assertArrayHasKey('members', $data); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php index f5a886fa6..0de312d84 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php @@ -112,7 +112,7 @@ final class PersonApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('type', $data); $this->assertArrayHasKey('id', $data); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php index 67b45acd5..d6fb7a8da 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php @@ -136,7 +136,7 @@ final class RelationshipApiControllerTest extends WebTestCase 'toPerson' => ['id' => $toPersonId, 'type' => 'person'], 'relation' => ['id' => $relationId, 'type' => 'relation'], 'reverse' => $isReverse, - ]) + ], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php index a0dcae59a..ba19fc56e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php @@ -47,7 +47,7 @@ final class SocialIssueApiControllerTest extends WebTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('id', $data); $this->assertArrayHasKey('type', $data); @@ -60,7 +60,7 @@ final class SocialIssueApiControllerTest extends WebTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertGreaterThan(0, $data['count']); $this->assertGreaterThan(0, count($data['results'])); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php index aa98fdcd3..9ed62e4b3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php @@ -77,7 +77,7 @@ final class SocialWorkEvaluationApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $content = json_decode($client->getResponse()->getContent(), true); + $content = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $ids = array_map(static fn (array $item) => $item['id'], $content['results']); diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php b/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php index 0e06fccab..6b11a1d63 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php @@ -45,7 +45,7 @@ class Version20160818113633 extends AbstractMigration foreach ($personIdAndCFData as $person) { $personId = $person['id']; $cFDataArray = unserialize($person['cfdata']); - $cFDataJson = json_encode($cFDataArray); + $cFDataJson = json_encode($cFDataArray, JSON_THROW_ON_ERROR); $this->addSql( 'UPDATE person set cfdata = :cfdatajson WHERE id = :id', ['cfdatajson' => $cFDataJson, 'id' => $personId] diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php b/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php index 4f7765000..d3adb3401 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php @@ -40,20 +40,20 @@ final class Version20181023101621 extends AbstractMigration $this->addSql('CREATE INDEX fullnameCanonical_trgm_idx ON chill_person_person USING GIN (fullnameCanonical gin_trgm_ops)'); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS - $BODY$ - BEGIN - IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname - THEN - UPDATE chill_person_person - SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) - WHERE id=NEW.id; - END IF; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS + $BODY$ + BEGIN + IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname + THEN + UPDATE chill_person_person + SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) + WHERE id=NEW.id; + END IF; + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); $this->addSql( <<<'SQL' @@ -67,17 +67,17 @@ final class Version20181023101621 extends AbstractMigration ); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_fullname_on_insert() RETURNS TRIGGER AS - $BODY$ - BEGIN - UPDATE chill_person_person - SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) - WHERE id=NEW.id; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_fullname_on_insert() RETURNS TRIGGER AS + $BODY$ + BEGIN + UPDATE chill_person_person + SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) + WHERE id=NEW.id; + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); $this->addSql( <<<'SQL' diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php b/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php index 947d26357..7d48b5f53 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php @@ -130,20 +130,20 @@ final class Version20200130213446 extends AbstractMigration $this->addSql('DROP TRIGGER canonicalize_fullname_on_alt_name_delete ON chill_person_alt_name;'); $this->addSql('DROP FUNCTION canonicalize_fullname_on_alt_name_alter();'); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS - $BODY$ - BEGIN - IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname - THEN - UPDATE chill_person_person - SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) - WHERE id=NEW.id; - END IF; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS + $BODY$ + BEGIN + IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname + THEN + UPDATE chill_person_person + SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) + WHERE id=NEW.id; + END IF; + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); } diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 21606d807..16ae19daa 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -276,7 +276,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; default: @@ -526,13 +526,13 @@ class ReportList implements ExportElementValidatedInterface, ListInterface return $this->customFieldProvider ->getCustomFieldByType($cf->getType()) - ->render(json_decode($value, true), $cf, 'csv'); + ->render(json_decode($value, true, 512, JSON_THROW_ON_ERROR), $cf, 'csv'); }; if ($cfType instanceof CustomFieldChoice && $cfType->isMultiple($cf)) { return function ($value) use ($cf, $cfType, $key) { $slugChoice = $this->extractInfosFromSlug($key)['additionnalInfos']['choiceSlug']; - $decoded = json_decode($value, true); + $decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR); if ('_header' === $value) { $label = $cfType->getChoices($cf)[$slugChoice]; diff --git a/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php index f87fe41b4..2e7a20840 100644 --- a/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php +++ b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php @@ -54,7 +54,7 @@ class LabelThirdPartyHelper return ''; } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); if (0 === count($decoded)) { return ''; From e84a93bd0c7f0c236145f7794ee70eba7ea081c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 30 Mar 2023 11:49:04 +0200 Subject: [PATCH 03/43] wip prepare rector config for up to PHP74 ruleset --- rector.php | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/rector.php b/rector.php index 2c5b08bec..ec9a0c684 100644 --- a/rector.php +++ b/rector.php @@ -12,14 +12,49 @@ return static function (RectorConfig $rectorConfig): void { __DIR__ . '/src', ]); - $rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\FileCacheStorage::class); - $rectorConfig->cacheDirectory(__DIR__.'/.cache/rector'); + //$rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\FileCacheStorage::class); + //$rectorConfig->cacheDirectory(__DIR__ . '/.cache/rector'); // register a single rule $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); + $rectorConfig->disableParallel(); - // define sets of rules - // $rectorConfig->sets([ - // LevelSetList::UP_TO_PHP_74 - // ]); + //define sets of rules + $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_74 + ]); + + // skip some path... + $rectorConfig->skip([ + // make rector stuck for some files + \Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector::class, + + // we need to discuss this: are we going to have FALSE in tests instead of an error ? + \Rector\Php71\Rector\FuncCall\CountOnNullRector::class, + + // must merge MR500 and review a typing of "ArrayCollection" in entities + \Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector::class, + + // remove all PHP80 rules, in order to activate them one by one + \Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector::class, + \Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, + \Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class, + \Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class, + \Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector::class, + \Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class, + \Rector\Php80\Rector\Class_\DoctrineAnnotationClassToAttributeRector::class, + \Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class, + \Rector\Php80\Rector\Ternary\GetDebugTypeRector::class, + \Rector\Php80\Rector\FunctionLike\MixedTypeRector::class, + \Rector\Php80\Rector\Property\NestedAnnotationToAttributeRector::class, + \Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class, + \Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class, + \Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class, + \Rector\Php80\Rector\NotIdentical\StrContainsRector::class, + \Rector\Php80\Rector\Identical\StrEndsWithRector::class, + \Rector\Php80\Rector\Identical\StrStartsWithRector::class, + \Rector\Php80\Rector\Class_\StringableForToStringRector::class, + \Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class, + \Rector\Php80\Rector\FunctionLike\UnionTypesRector::class + ]); }; From 4c2e78ada7fe57c1d5da67a2b9974ebe8011b71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:02:39 +0200 Subject: [PATCH 04/43] DX: set rector back to php73 --- rector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rector.php b/rector.php index ec9a0c684..23494ad88 100644 --- a/rector.php +++ b/rector.php @@ -21,7 +21,7 @@ return static function (RectorConfig $rectorConfig): void { //define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_74 + LevelSetList::UP_TO_PHP_73 ]); // skip some path... From 459b91001f642d12bb62bb8e71374b8a7d7b5889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:08:04 +0200 Subject: [PATCH 05/43] fix rector issues --- .../Controller/AddressToReferenceMatcherControllerTest.php | 4 ++-- .../Controller/GeographicalUnitByAddressApiControllerTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/AddressToReferenceMatcherControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/AddressToReferenceMatcherControllerTest.php index 7bcbe9889..4a65883e2 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/AddressToReferenceMatcherControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/AddressToReferenceMatcherControllerTest.php @@ -84,7 +84,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase /** @var Address $address */ $address = $em->createQuery('SELECT a FROM '.Address::class.' a') - ->setFirstResult(rand(0, $nb)) + ->setFirstResult(random_int(0, $nb)) ->setMaxResults(1) ->getSingleResult(); @@ -108,7 +108,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase $ref = $em->createQuery('SELECT a FROM '.AddressReference::class.' a') ->setMaxResults(1) - ->setFirstResult(rand(0, $nb)) + ->setFirstResult(random_int(0, $nb)) ->getSingleResult(); $address = Address::createFromAddressReference($ref); diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/GeographicalUnitByAddressApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/GeographicalUnitByAddressApiControllerTest.php index a320bb073..60273a8c9 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/GeographicalUnitByAddressApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/GeographicalUnitByAddressApiControllerTest.php @@ -44,7 +44,7 @@ class GeographicalUnitByAddressApiControllerTest extends WebTestCase $nb = $em->createQuery('SELECT COUNT(a) FROM '.Address::class.' a')->getSingleScalarResult(); /** @var \Chill\MainBundle\Entity\Address $random */ $random = $em->createQuery('SELECT a FROM '.Address::class.' a') - ->setFirstResult(rand(0, $nb)) + ->setFirstResult(random_int(0, $nb)) ->setMaxResults(1) ->getSingleResult(); From a68190f0c65d26f193b7ce7c327a9aaa6f877104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:19:57 +0200 Subject: [PATCH 06/43] DX: set rector config: rules up to PHP74 --- rector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 23494ad88..ec9a0c684 100644 --- a/rector.php +++ b/rector.php @@ -21,7 +21,7 @@ return static function (RectorConfig $rectorConfig): void { //define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_73 + LevelSetList::UP_TO_PHP_74 ]); // skip some path... From 858ade467ca40693daccf91575b4bfb3624a75da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:20:19 +0200 Subject: [PATCH 07/43] DX: rector rules upt to PHP 74 --- .../DependencyInjection/Configuration.php | 4 +- .../ChillActivityBundle/Entity/Activity.php | 2 +- .../Entity/ActivityPresence.php | 2 +- .../Entity/ActivityType.php | 2 +- .../LinkedToACP/AvgActivityDuration.php | 4 +- .../LinkedToACP/AvgActivityVisitDuration.php | 4 +- .../Export/LinkedToACP/CountActivity.php | 4 +- .../Export/LinkedToACP/ListActivity.php | 4 +- .../LinkedToACP/SumActivityDuration.php | 4 +- .../LinkedToACP/SumActivityVisitDuration.php | 4 +- .../Export/LinkedToPerson/ListActivity.php | 16 +++--- .../Filter/ACPFilters/ActivityTypeFilter.php | 9 ++-- .../Filter/ACPFilters/UserScopeFilter.php | 8 ++- .../Export/Filter/ActivityTypeFilter.php | 9 ++-- .../ChillActivityBundle/Form/ActivityType.php | 14 ++--- .../Form/ActivityTypeType.php | 4 +- .../Form/Type/PickActivityReasonType.php | 4 +- ...TranslatableActivityReasonCategoryType.php | 6 +-- .../Form/Type/TranslatableActivityType.php | 4 +- .../Repository/ActivityACLAwareRepository.php | 4 +- .../Service/DocGenerator/ActivityContext.php | 4 +- ...tActivitiesByAccompanyingPeriodContext.php | 8 +-- .../Controller/ActivityControllerTest.php | 8 +-- .../Tests/Form/ActivityTypeTest.php | 4 +- .../Type/TranslatableActivityReasonTest.php | 4 +- .../src/DependencyInjection/Configuration.php | 4 +- .../src/Entity/AsideActivity.php | 2 +- .../src/Export/Export/CountAsideActivity.php | 4 +- .../Entity/AbstractElement.php | 4 +- .../ChillBudgetBundle/Form/ChargeType.php | 4 +- .../ChillBudgetBundle/Form/ResourceType.php | 4 +- .../Service/Summary/SummaryBudget.php | 12 ++--- .../Service/Summary/SummaryBudgetTest.php | 12 ++--- .../ChillCalendarBundle/Entity/Calendar.php | 8 +-- .../Entity/CalendarRange.php | 2 +- .../Export/Export/CountCalendars.php | 8 +-- .../Export/Export/StatCalendarAvgDuration.php | 4 +- .../Export/Export/StatCalendarSumDuration.php | 4 +- .../Export/Filter/AgentFilter.php | 4 +- .../Export/Filter/JobFilter.php | 8 ++- .../Export/Filter/ScopeFilter.php | 8 ++- .../Handler/CalendarToRemoteHandler.php | 8 +-- .../Messenger/Message/CalendarMessage.php | 14 +++-- .../MSGraph/RemoteEventConverter.php | 8 +-- .../MSGraphRemoteCalendarConnector.php | 16 ++---- .../Tests/Form/CalendarTypeTest.php | 36 ++++--------- .../MSGraph/AddressConverterTest.php | 4 +- .../CalendarForShortMessageProviderTest.php | 16 ++---- .../CustomFields/CustomFieldLongChoice.php | 4 +- .../OptionRepository.php | 4 +- .../Form/CustomFieldType.php | 4 +- .../JsonCustomFieldToArrayTransformer.php | 4 +- .../Form/DocGeneratorTemplateType.php | 8 +-- .../Generator/ObjectReadyException.php | 2 +- .../RelatedEntityNotFoundException.php | 2 +- .../Entity/StoredObject.php | 4 +- .../Form/AccompanyingCourseDocumentType.php | 12 ++--- .../Form/PersonDocumentType.php | 12 ++--- ...ompanyingCourseDocumentWorkflowHandler.php | 4 +- .../Controller/ParticipationController.php | 17 ++---- src/Bundle/ChillEventBundle/Entity/Event.php | 4 +- .../Form/ChoiceLoader/EventChoiceLoader.php | 4 +- src/Bundle/ChillEventBundle/Form/RoleType.php | 4 +- .../Form/Type/PickEventType.php | 20 +++---- .../Form/Type/PickEventTypeType.php | 14 ++--- .../Form/Type/PickRoleType.php | 22 +++----- .../Form/Type/PickStatusType.php | 22 +++----- .../ParticipationControllerTest.php | 16 ++---- .../Timeline/TimelineEventProvider.php | 4 +- .../CRUD/Controller/CRUDController.php | 2 +- .../CRUD/Routing/CRUDRoutesLoader.php | 4 +- .../Controller/NotificationController.php | 4 +- .../Controller/PermissionsGroupController.php | 16 ++---- .../Controller/UserController.php | 4 +- .../Controller/WorkflowController.php | 10 ++-- .../CompilerPass/MenuCompilerPass.php | 4 +- .../ChillMainBundle/Doctrine/DQL/Greatest.php | 4 +- .../ChillMainBundle/Doctrine/DQL/Least.php | 4 +- src/Bundle/ChillMainBundle/Entity/Address.php | 2 +- .../Entity/AddressReference.php | 4 +- .../Entity/GeographicalUnit.php | 2 +- .../ChillMainBundle/Entity/Notification.php | 4 +- .../Entity/PermissionsGroup.php | 4 +- .../Entity/Workflow/EntityWorkflowStep.php | 4 +- .../Export/Formatter/CSVListFormatter.php | 4 +- .../Formatter/CSVPivotedListFormatter.php | 4 +- .../Export/Formatter/SpreadSheetFormatter.php | 2 +- .../Export/Helper/ExportAddressHelper.php | 6 +-- .../ChoiceLoader/PostalCodeChoiceLoader.php | 4 +- .../DataMapper/ExportPickCenterDataMapper.php | 4 +- .../IdToEntityDataTransformer.php | 4 +- .../ChillMainBundle/Form/LocationFormType.php | 14 ++--- .../Form/Type/ComposedGroupCenterType.php | 8 +-- .../Form/Type/ComposedRoleScopeType.php | 8 +-- .../EntityToJsonTransformer.php | 4 +- .../Form/Type/Export/PickCenterType.php | 8 +-- .../Form/Type/PickCenterType.php | 4 +- .../Form/Type/PickCivilityType.php | 12 ++--- .../Form/Type/PickLocationTypeType.php | 4 +- .../Form/Type/PickUserLocationType.php | 8 ++- .../Form/Type/PostalCodeType.php | 6 +-- .../Form/Type/ScopePickerType.php | 8 +-- .../Form/Type/UserPickerType.php | 4 +- src/Bundle/ChillMainBundle/Form/UserType.php | 12 ++--- .../ChillMainBundle/Form/WorkflowStepType.php | 16 ++---- .../Routing/MenuBuilder/UserMenuBuilder.php | 8 +-- .../ChillMainBundle/Search/SearchProvider.php | 8 +-- .../AddressReferenceBEFromBestAddress.php | 4 +- .../Import/PostalCodeBEFromBestAddress.php | 4 +- .../Service/Mailer/ChillMailer.php | 4 +- .../Tests/Entity/NotificationTest.php | 4 +- .../Tests/Form/Type/ScopePickerTypeTest.php | 4 +- .../Utils/ExtractDateFromPatternTest.php | 4 +- .../Authorization/AuthorizationHelperTest.php | 4 +- ...ntityWorkflowTransitionEventSubscriber.php | 4 +- .../NotificationOnTransition.php | 4 +- .../EntityWorkflowCreationValidator.php | 4 +- .../AccompanyingCourseApiController.php | 4 +- .../AccompanyingPeriodController.php | 12 ++--- ...mpanyingPeriodRegulationListController.php | 16 ++---- .../HouseholdCompositionController.php | 4 +- .../Controller/HouseholdController.php | 4 +- .../Controller/PersonApiController.php | 8 +-- .../SocialWorkSocialActionApiController.php | 4 +- .../DataFixtures/ORM/LoadCustomFields.php | 4 +- .../Entity/AccompanyingPeriod.php | 8 +-- .../Entity/AccompanyingPeriod/Comment.php | 12 ++--- .../Entity/Household/Household.php | 22 +++----- .../Entity/Household/HouseholdMember.php | 2 +- .../ChillPersonBundle/Entity/Person.php | 8 +-- .../Entity/Person/PersonCurrentAddress.php | 2 +- .../Entity/Person/PersonResource.php | 2 +- .../ChillPersonBundle/Entity/PersonPhone.php | 4 +- .../Entity/SocialWork/Result.php | 2 +- .../GeographicalUnitStatAggregator.php | 4 +- .../CountryOfBirthAggregator.php | 4 +- .../GeographicalUnitAggregator.php | 4 +- .../NationalityAggregator.php | 4 +- .../Export/Export/CountAccompanyingCourse.php | 8 +-- .../Export/CountAccompanyingPeriodWork.php | 8 +-- .../Export/Export/CountEvaluation.php | 8 +-- .../Export/Export/CountHousehold.php | 4 +- .../Export/Export/CountPerson.php | 8 +-- .../CountPersonWithAccompanyingCourse.php | 8 +-- .../Export/Export/ListAccompanyingPeriod.php | 4 +- .../Export/ListAccompanyingPeriodWork.php | 4 +- .../Export/Export/ListEvaluation.php | 4 +- .../Export/Export/ListHouseholdInPeriod.php | 4 +- .../Export/Export/ListPerson.php | 4 +- .../ListPersonWithAccompanyingPeriod.php | 4 +- .../Export/StatAccompanyingCourseDuration.php | 4 +- .../ClosingMotiveFilter.php | 4 +- .../CreatorJobFilter.php | 8 ++- .../EvaluationFilter.php | 4 +- .../GeographicalUnitStatFilter.php | 8 +-- .../OriginFilter.php | 4 +- .../EvaluationTypeFilter.php | 4 +- .../HouseholdFilters/CompositionFilter.php | 8 ++- .../PersonFilters/AddressRefStatusFilter.php | 8 +-- .../Filter/PersonFilters/GenderFilter.php | 4 +- .../PersonFilters/GeographicalUnitFilter.php | 8 +-- .../PersonFilters/MaritalStatusFilter.php | 8 ++- .../PersonFilters/NationalityFilter.php | 4 +- .../ResidentialAddressAtThirdpartyFilter.php | 4 +- .../Filter/SocialWorkFilters/JobFilter.php | 8 ++- .../Filter/SocialWorkFilters/ScopeFilter.php | 8 ++- .../SocialWorkTypeFilter.php | 2 +- .../Form/ChoiceLoader/PersonChoiceLoader.php | 4 +- .../Form/HouseholdCompositionType.php | 4 +- .../ChillPersonBundle/Form/PersonType.php | 12 ++--- .../Form/SocialWork/GoalType.php | 4 +- .../Form/SocialWork/SocialActionType.php | 20 ++----- .../Form/Type/ClosingMotivePickerType.php | 10 ++-- .../Form/Type/PickPersonType.php | 20 +++---- .../Form/Type/PickSocialActionType.php | 4 +- .../Form/Type/PickSocialIssueType.php | 4 +- .../Privacy/PrivacyEventSubscriber.php | 8 +-- .../Repository/PersonACLAwareRepository.php | 4 +- .../Security/Authorization/HouseholdVoter.php | 4 +- .../AccompanyingPeriodDocGenNormalizer.php | 8 +-- ...mpanyingPeriodWorkEvaluationNormalizer.php | 4 +- .../Normalizer/PersonDocGenNormalizer.php | 8 +-- .../Normalizer/PersonJsonNormalizer.php | 10 ++-- .../Normalizer/SocialIssueNormalizer.php | 4 +- .../AccompanyingPeriodContext.php | 20 +++---- ...ccompanyingPeriodWorkEvaluationContext.php | 12 ++--- .../Service/DocGenerator/PersonContext.php | 12 ++--- .../AccompanyingCourseApiControllerTest.php | 4 +- .../Controller/HouseholdApiControllerTest.php | 4 +- .../Controller/PersonControllerUpdateTest.php | 52 +++++-------------- ...onControllerUpdateWithHiddenFieldsTest.php | 24 +++------ .../Tests/Entity/AccompanyingPeriodTest.php | 4 +- .../Tests/Household/MembersEditorTest.php | 24 +++------ .../Normalizer/PersonDocGenNormalizerTest.php | 4 +- .../RelationshipDocGenNormalizerTest.php | 8 +-- .../DocGenerator/PersonContextTest.php | 4 +- .../PersonContextWithThirdPartyTest.php | 4 +- .../AccompanyingPeriodValidityValidator.php | 4 +- .../Export/Export/ReportList.php | 10 ++-- .../ChillReportBundle/Search/ReportSearch.php | 4 +- .../Controller/ReportControllerNextTest.php | 4 +- .../Tests/Controller/ReportControllerTest.php | 4 +- .../Tests/Timeline/TimelineProviderTest.php | 4 +- .../Timeline/TimelineReportProvider.php | 2 +- .../Controller/TaskController.php | 4 +- .../Form/SingleTaskListType.php | 8 +-- .../Controller/SingleTaskControllerTest.php | 4 +- ...TaskTaskLifeCycleEventTimelineProvider.php | 4 +- .../TaskLifeCycleEventTimelineProvider.php | 4 +- .../DataFixtures/ORM/LoadThirdParty.php | 4 +- .../Entity/ThirdParty.php | 6 +-- .../Form/Type/PickThirdPartyType.php | 14 ++--- .../Type/PickThirdPartyTypeCategoryType.php | 4 +- 213 files changed, 433 insertions(+), 1052 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php index c6b3189cc..35388464b 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php @@ -59,9 +59,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(static function ($data) { - return !is_int($data); - })->thenInvalid('The value %s is not a valid integer') + ->ifTrue(static fn($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') ->end() ->end() ->scalarNode('label') diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 9adfa057f..32ceb2e74 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -195,7 +195,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @Groups({"docgen:read"}) */ - private ?User $user; + private ?User $user = null; /** * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User") diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php index 95b3c95d2..b0154e509 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php @@ -34,7 +34,7 @@ class ActivityPresence * @ORM\GeneratedValue(strategy="AUTO") * @Serializer\Groups({"docgen:read"}) */ - private ?int $id; + private ?int $id = null; /** * @ORM\Column(type="json") diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index a6e0fc694..ed8260a4d 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -122,7 +122,7 @@ class ActivityType * @ORM\GeneratedValue(strategy="AUTO") * @Groups({"docgen:read"}) */ - private ?int $id; + private ?int $id = null; /** * @ORM\Column(type="string", nullable=false, options={"default": ""}) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 2b6919340..0de7f420c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -86,9 +86,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index 359593059..d9382d857 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -87,9 +87,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 2dc844aa2..fe6de3e24 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -86,9 +86,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 6d25b4e22..616f4d848 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -109,9 +109,7 @@ class ListActivity implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index 1cf20dc5f..d4aa65f22 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -87,9 +87,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index 2c160f3cf..859c3e6b5 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -87,9 +87,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index 8b69216b6..d9b1eb212 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -137,13 +137,11 @@ class ListActivity implements ListInterface, GroupedExportInterface $activity = $activityRepository->find($value); - return implode(', ', array_map(function (ActivityReason $r) { - return '"' . - $this->translatableStringHelper->localize($r->getCategory()->getName()) - . ' > ' . - $this->translatableStringHelper->localize($r->getName()) - . '"'; - }, $activity->getReasons()->toArray())); + return implode(', ', array_map(fn(ActivityReason $r) => '"' . + $this->translatableStringHelper->localize($r->getCategory()->getName()) + . ' > ' . + $this->translatableStringHelper->localize($r->getName()) + . '"', $activity->getReasons()->toArray())); }; case 'circle_name': @@ -197,9 +195,7 @@ class ListActivity implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index a793f21de..346eab316 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -61,12 +61,9 @@ class ActivityTypeFilter implements FilterInterface $builder->add('accepted_activitytypes', EntityType::class, [ 'class' => ActivityType::class, 'choices' => $this->activityTypeRepository->findAllActive(), - 'choice_label' => function (ActivityType $aty) { - return - ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') - . - $this->translatableStringHelper->localize($aty->getName()); - }, + 'choice_label' => fn(ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + . + $this->translatableStringHelper->localize($aty->getName()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index 1906db75e..4254137ba 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -64,11 +64,9 @@ class UserScopeFilter implements FilterInterface { $builder->add('accepted_userscope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => function (Scope $s) { - return $this->translatableStringHelper->localize( - $s->getName() - ); - }, + 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + $s->getName() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index d1758039a..725223fdd 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -61,12 +61,9 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter $builder->add('types', EntityType::class, [ 'choices' => $this->activityTypeRepository->findAllActive(), 'class' => ActivityType::class, - 'choice_label' => function (ActivityType $aty) { - return - ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') - . - $this->translatableStringHelper->localize($aty->getName()); - }, + 'choice_label' => fn(ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + . + $this->translatableStringHelper->localize($aty->getName()), 'group_by' => function (ActivityType $type) { if (!$type->hasCategory()) { return null; diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 50d1a66c7..dad4c3137 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -211,13 +211,9 @@ class ActivityType extends AbstractType 'required' => $activityType->isRequired('attendee'), 'expanded' => true, 'class' => ActivityPresence::class, - 'choice_label' => function (ActivityPresence $activityPresence) { - return $this->translatableStringHelper->localize($activityPresence->getName()); - }, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('a') - ->where('a.active = true'); - }, + 'choice_label' => fn(ActivityPresence $activityPresence) => $this->translatableStringHelper->localize($activityPresence->getName()), + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('a') + ->where('a.active = true'), ]); } @@ -357,9 +353,7 @@ class ActivityType extends AbstractType return (string) $location->getId(); }, - function (?string $id): ?Location { - return $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id]); - } + fn(?string $id): ?Location => $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id]) )); } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index b27fa883e..42353cda7 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -45,9 +45,7 @@ class ActivityTypeType extends AbstractType ]) ->add('category', EntityType::class, [ 'class' => ActivityTypeCategory::class, - 'choice_label' => function (ActivityTypeCategory $activityTypeCategory) { - return $this->translatableStringHelper->localize($activityTypeCategory->getName()); - }, + 'choice_label' => fn(ActivityTypeCategory $activityTypeCategory) => $this->translatableStringHelper->localize($activityTypeCategory->getName()), ]) ->add('ordering', NumberType::class, [ 'required' => true, diff --git a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php index a951ef940..0b63de112 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php @@ -45,9 +45,7 @@ class PickActivityReasonType extends AbstractType $resolver->setDefaults( [ 'class' => ActivityReason::class, - 'choice_label' => function (ActivityReason $choice) { - return $this->reasonRender->renderString($choice, []); - }, + 'choice_label' => fn(ActivityReason $choice) => $this->reasonRender->renderString($choice, []), 'group_by' => function (ActivityReason $choice): ?string { if (null !== $category = $choice->getCategory()) { return $this->translatableStringHelper->localize($category->getName()); diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php index 96dabe008..83dcb43f0 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php @@ -38,10 +38,8 @@ class TranslatableActivityReasonCategoryType extends AbstractType $resolver->setDefaults( [ 'class' => ActivityReasonCategory::class, - 'choice_label' => function (ActivityReasonCategory $category) { - return $this->translatableStringHelper->localize($category->getName()) - . (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : ''); - }, + 'choice_label' => fn(ActivityReasonCategory $category) => $this->translatableStringHelper->localize($category->getName()) + . (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : ''), ] ); } diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php index 4a1d4bfa7..065f80c9b 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php @@ -39,9 +39,7 @@ class TranslatableActivityType extends AbstractType 'class' => ActivityType::class, 'active_only' => true, 'choices' => $this->activityTypeRepository->findAllActive(), - 'choice_label' => function (ActivityType $type) { - return $this->translatableStringHelper->localize($type->getName()); - }, + 'choice_label' => fn(ActivityType $type) => $this->translatableStringHelper->localize($type->getName()), ] ); } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php index 185e008eb..3e5ff813b 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php @@ -254,9 +254,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte $reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), ActivityVoter::SEE, $center); // we get the ids for those scopes $reachablesScopesId = array_map( - static function (Scope $scope) { - return $scope->getId(); - }, + static fn(Scope $scope) => $scope->getId(), $reachableScopes ); diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php index ad570a8a4..241526b03 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php @@ -134,9 +134,7 @@ class ActivityContext implements $builder->add($key, EntityType::class, [ 'class' => Person::class, 'choices' => $persons, - 'choice_label' => function (Person $p) { - return $this->personRender->renderString($p, []); - }, + 'choice_label' => fn(Person $p) => $this->personRender->renderString($p, []), 'multiple' => false, 'required' => false, 'expanded' => true, diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php index 266fadfee..9f9e03669 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php @@ -146,9 +146,7 @@ class ListActivitiesByAccompanyingPeriodContext implements return array_filter( $activities, function ($activity) use ($user) { - $activityUsernames = array_map(static function ($user) { - return $user['username']; - }, $activity['users'] ?? []); + $activityUsernames = array_map(static fn($user) => $user['username'], $activity['users'] ?? []); return in_array($user->getUsername(), $activityUsernames, true); } ); @@ -159,9 +157,7 @@ class ListActivitiesByAccompanyingPeriodContext implements return array_filter( $works, function ($work) use ($user) { - $workUsernames = array_map(static function ($user) { - return $user['username']; - }, $work['referrers'] ?? []); + $workUsernames = array_map(static fn($user) => $user['username'], $work['referrers'] ?? []); return in_array($user->getUsername(), $workUsernames, true); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php index 8e2c219f0..d01821e6e 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php @@ -369,12 +369,8 @@ final class ActivityControllerTest extends WebTestCase $center ); $reachableScopesId = array_intersect( - array_map(static function ($s) { - return $s->getId(); - }, $reachableScopesDelete), - array_map(static function ($s) { - return $s->getId(); - }, $reachableScopesUpdate) + array_map(static fn($s) => $s->getId(), $reachableScopesDelete), + array_map(static fn($s) => $s->getId(), $reachableScopesUpdate) ); if (count($reachableScopesId) === 0) { diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php index df0a602a4..cd73b259a 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php @@ -188,9 +188,7 @@ final class ActivityTypeTest extends KernelTestCase // map all the values in an array $values = array_map( - static function ($choice) { - return $choice->value; - }, + static fn($choice) => $choice->value, $view['activity']['durationTime']->vars['choices'] ); diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php index 881e5a607..aefa0d115 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php @@ -83,9 +83,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase $request->getLocale()->willReturn($fallbackLocale); $requestStack->willExtend(\Symfony\Component\HttpFoundation\RequestStack::class); - $requestStack->getCurrentRequest()->will(static function () use ($request) { - return $request; - }); + $requestStack->getCurrentRequest()->will(static fn() => $request); $translator->willExtend(\Symfony\Component\Translation\Translator::class); $translator->getFallbackLocales()->willReturn($locale); diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php index 8341e0240..85d76227d 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php @@ -132,9 +132,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(static function ($data) { - return !is_int($data); - })->thenInvalid('The value %s is not a valid integer') + ->ifTrue(static fn($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') ->end() ->end() ->scalarNode('label') diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php index 598988cfb..3dc205f09 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php @@ -57,7 +57,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface * @ORM\GeneratedValue * @ORM\Column(type="integer") */ - private ?int $id; + private ?int $id = null; /** * @ORM\Column(type="string", length=100, nullable=true) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php index 87aad1659..8eb8d1b64 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php @@ -59,9 +59,7 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php index f12ba3d72..619a6cdd7 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php +++ b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php @@ -41,7 +41,7 @@ abstract class AbstractElement /** * @ORM\Column(name="comment", type="text", nullable=true) */ - private ?string $comment; + private ?string $comment = null; /** * @ORM\Column(name="endDate", type="datetime_immutable", nullable=true) @@ -50,7 +50,7 @@ abstract class AbstractElement * message="The budget element's end date must be after the start date" * ) */ - private ?DateTimeImmutable $endDate; + private ?DateTimeImmutable $endDate = null; /** * @ORM\ManyToOne( diff --git a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php index 3356057cf..de8317ab3 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php @@ -52,9 +52,7 @@ class ChargeType extends AbstractType 'label' => 'Charge type', 'required' => true, 'placeholder' => $this->translator->trans('admin.form.Choose the type of charge'), - 'choice_label' => function (ChargeKind $resource) { - return $this->translatableStringHelper->localize($resource->getName()); - }, + 'choice_label' => fn(ChargeKind $resource) => $this->translatableStringHelper->localize($resource->getName()), 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) diff --git a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php index fd859217a..3b14e9a05 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php @@ -51,9 +51,7 @@ class ResourceType extends AbstractType 'label' => 'Resource type', 'required' => true, 'placeholder' => $this->translator->trans('admin.form.Choose the type of resource'), - 'choice_label' => function (ResourceKind $resource) { - return $this->translatableStringHelper->localize($resource->getName()); - }, + 'choice_label' => fn(ResourceKind $resource) => $this->translatableStringHelper->localize($resource->getName()), 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) diff --git a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php index ad2a014ed..3e0ee2cec 100644 --- a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php +++ b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php @@ -66,9 +66,7 @@ final class SummaryBudget implements SummaryBudgetInterface ]; } - $personIds = $household->getCurrentPersons()->map(static function (Person $p) { - return $p->getId(); - }); + $personIds = $household->getCurrentPersons()->map(static fn(Person $p) => $p->getId()); $ids = implode(', ', array_fill(0, count($personIds), '?')); $parameters = [...$personIds, $household->getId()]; @@ -127,18 +125,14 @@ final class SummaryBudget implements SummaryBudgetInterface { $keys = array_map(static fn (ChargeKind $kind) => $kind->getKind(), $this->chargeKindRepository->findAll()); - return array_combine($keys, array_map(function ($kind) { - return ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => '']; - }, $keys)); + return array_combine($keys, array_map(fn($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); } private function getEmptyResourceArray(): array { $keys = array_map(static fn (ResourceKind $kind) => $kind->getKind(), $this->resourceKindRepository->findAll()); - return array_combine($keys, array_map(function ($kind) { - return ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => '']; - }, $keys)); + return array_combine($keys, array_map(fn($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); } private function rowToArray(array $rows, string $kind): array diff --git a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php index 7fcda6b11..194c23672 100644 --- a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php +++ b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php @@ -50,9 +50,7 @@ final class SummaryBudgetTest extends TestCase ], ]); $queryCharges->setParameters(Argument::type('array')) - ->will(static function ($args, $query) { - return $query; - }); + ->will(static fn($args, $query) => $query); $queryResources = $this->prophesize(AbstractQuery::class); $queryResources->getResult()->willReturn([ @@ -63,9 +61,7 @@ final class SummaryBudgetTest extends TestCase ], ]); $queryResources->setParameters(Argument::type('array')) - ->will(static function ($args, $query) { - return $query; - }); + ->will(static fn($args, $query) => $query); $em = $this->prophesize(EntityManagerInterface::class); $em->createNativeQuery(Argument::type('string'), Argument::type(Query\ResultSetMapping::class)) @@ -100,9 +96,7 @@ final class SummaryBudgetTest extends TestCase $resourceRepository->findOneByKind('misc')->willReturn($misc); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); - $translatableStringHelper->localize(Argument::type('array'))->will(static function ($arg) { - return $arg[0]['fr']; - }); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn($arg) => $arg[0]['fr']); $person = new Person(); $personReflection = new ReflectionClass($person); diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index d7f38adf0..418bfcea2 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -514,9 +514,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente */ public function getUsers(): ReadableCollection { - return $this->getInvites()->map(static function (Invite $i) { - return $i->getUser(); - }); + return $this->getInvites()->map(static fn(Invite $i) => $i->getUser()); } public function hasCalendarRange(): bool @@ -601,9 +599,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente } $invite = $this->invites - ->filter(static function (Invite $invite) use ($user) { - return $invite->getUser() === $user; - }) + ->filter(static fn(Invite $invite) => $invite->getUser() === $user) ->first(); $this->removeInvite($invite); diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php index 14cfad98b..5dbc4286f 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php @@ -63,7 +63,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface * @Groups({"read", "write", "calendar:read"}) * @Assert\NotNull */ - private ?Location $location; + private ?Location $location = null; /** * @ORM\Column(type="datetime_immutable", nullable=false) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index f3bf79547..c21b4a4d6 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -61,9 +61,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -91,9 +89,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->calendarRepository->createQueryBuilder('cal'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index ddecba415..78be10834 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -61,9 +61,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index d99e73a2e..5dd9dca44 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -61,9 +61,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index 18a4b0f4b..058251004 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -58,9 +58,7 @@ class AgentFilter implements FilterInterface { $builder->add('accepted_agents', EntityType::class, [ 'class' => User::class, - 'choice_label' => function (User $u) { - return $this->userRender->renderString($u, []); - }, + 'choice_label' => fn(User $u) => $this->userRender->renderString($u, []), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 0f0f42adc..04f6ba02b 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -69,11 +69,9 @@ class JobFilter implements FilterInterface { $builder->add('job', EntityType::class, [ 'class' => UserJob::class, - 'choice_label' => function (UserJob $j) { - return $this->translatableStringHelper->localize( - $j->getLabel() - ); - }, + 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + $j->getLabel() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index 4d84543a3..ce6c90de2 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -69,11 +69,9 @@ class ScopeFilter implements FilterInterface { $builder->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => function (Scope $s) { - return $this->translatableStringHelper->localize( - $s->getName() - ); - }, + 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + $s->getName() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php index 9bcc0c434..1ec257cad 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php @@ -89,14 +89,10 @@ class CalendarToRemoteHandler implements MessageHandlerInterface $newInvites = array_filter( array_map( - function ($id) { - return $this->inviteRepository->find($id); - }, + fn($id) => $this->inviteRepository->find($id), $calendarMessage->getNewInvitesIds(), ), - static function (?Invite $invite) { - return null !== $invite; - } + static fn(?Invite $invite) => null !== $invite ); $this->calendarConnector->syncCalendar( diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php index ec5977ad3..6232ca06c 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php @@ -58,14 +58,12 @@ class CalendarMessage $this->previousMainUserId = null !== $calendar->previousMainUser ? $calendar->previousMainUser->getId() : null; $this->newInvitesIds = array_map(static fn (Invite $i) => $i->getId(), $calendar->newInvites); - $this->oldInvites = array_map(static function (Invite $i) { - return [ - 'inviteId' => $i->getId(), - 'userId' => $i->getUser()->getId(), - 'userEmail' => $i->getUser()->getEmail(), - 'userLabel' => $i->getUser()->getLabel(), - ]; - }, $calendar->oldInvites); + $this->oldInvites = array_map(static fn(Invite $i) => [ + 'inviteId' => $i->getId(), + 'userId' => $i->getUser()->getId(), + 'userEmail' => $i->getUser()->getEmail(), + 'userLabel' => $i->getUser()->getLabel(), + ], $calendar->oldInvites); } public function getAction(): string diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php index ac1de552a..b7a1c2df6 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php @@ -121,9 +121,7 @@ class RemoteEventConverter 'subject' => '[Chill] ' . implode( ', ', - $calendar->getPersons()->map(function (Person $p) { - return $this->personRender->renderString($p, []); - })->toArray() + $calendar->getPersons()->map(fn(Person $p) => $this->personRender->renderString($p, []))->toArray() ), 'start' => [ 'dateTime' => $calendar->getStartDate()->setTimezone($this->remoteDateTimeZone) @@ -161,9 +159,7 @@ class RemoteEventConverter { return [ 'attendees' => $calendar->getInvites()->map( - function (Invite $i) { - return $this->buildInviteToAttendee($i); - } + fn(Invite $i) => $this->buildInviteToAttendee($i) )->toArray(), ]; } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php index 0454bae69..75995948e 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php @@ -190,23 +190,17 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface ] )->toArray(); - $ids = array_map(static function ($item) { - return $item['id']; - }, $bareEvents['value']); + $ids = array_map(static fn($item) => $item['id'], $bareEvents['value']); $existingIdsInRange = $this->calendarRangeRepository->findRemoteIdsPresent($ids); $existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids); return array_values( array_map( - function ($item) { - return $this->remoteEventConverter->convertToRemote($item); - }, + fn($item) => $this->remoteEventConverter->convertToRemote($item), // filter all event to keep only the one not in range array_filter( $bareEvents['value'], - static function ($item) use ($existingIdsInRange, $existingIdsInCalendar) { - return ((!$existingIdsInRange[$item['id']]) ?? true) && ((!$existingIdsInCalendar[$item['id']]) ?? true); - } + static fn($item) => ((!$existingIdsInRange[$item['id']]) ?? true) && ((!$existingIdsInCalendar[$item['id']]) ?? true) ) ) ); @@ -601,9 +595,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface } $this->cacheScheduleTimeForUser[$userId] = array_map( - function ($item) { - return $this->remoteEventConverter->convertAvailabilityToRemoteEvent($item); - }, + fn($item) => $this->remoteEventConverter->convertAvailabilityToRemoteEvent($item), $response['value'][0]['scheduleItems'] ); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php index 80b2f8c45..f7a3509f4 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php @@ -114,12 +114,8 @@ final class CalendarTypeTest extends TypeTestCase $this->assertEquals(8, $calendar->getCalendarRange()->getId()); $this->assertEquals(9, $calendar->getLocation()->getId()); $this->assertEquals(true, $calendar->getSendSMS()); - $this->assertContains(2, $calendar->getUsers()->map(static function (User $u) { - return $u->getId(); - })); - $this->assertContains(3, $calendar->getUsers()->map(static function (User $u) { - return $u->getId(); - })); + $this->assertContains(2, $calendar->getUsers()->map(static fn(User $u) => $u->getId())); + $this->assertContains(3, $calendar->getUsers()->map(static fn(User $u) => $u->getId())); } protected function getExtensions() @@ -148,25 +144,17 @@ final class CalendarTypeTest extends TypeTestCase ) { $transformer = $this->prophesize($classTransformer); $transformer->transform(Argument::type('array')) - ->will(static function ($args) { - return implode( - ',', - array_map(static function ($p) { - return $p->getId(); - }, $args[0]) - ); - }); + ->will(static fn($args) => implode( + ',', + array_map(static fn($p) => $p->getId(), $args[0]) + )); $transformer->transform(Argument::exact(null)) ->willReturn([]); $transformer->transform(Argument::type(Collection::class)) - ->will(static function ($args) { - return implode( - ',', - array_map(static function ($p) { - return $p->getId(); - }, $args[0]->toArray()) - ); - }); + ->will(static fn($args) => implode( + ',', + array_map(static fn($p) => $p->getId(), $args[0]->toArray()) + )); $transformer->reverseTransform(Argument::type('string')) ->will(static function ($args) use ($objClass) { if (null === $args[0]) { @@ -195,9 +183,7 @@ final class CalendarTypeTest extends TypeTestCase ) { $transformer = $this->prophesize($classTransformer); $transformer->transform(Argument::type('object')) - ->will(static function ($args) { - return (string) $args[0]->getId(); - }); + ->will(static fn($args) => (string) $args[0]->getId()); $transformer->transform(Argument::exact(null)) ->willReturn(''); $transformer->reverseTransform(Argument::type('string')) diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php index 485146939..35c067eb7 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php @@ -63,9 +63,7 @@ final class AddressConverterTest extends TestCase { $engine = $this->prophesize(EngineInterface::class); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); - $translatableStringHelper->localize(Argument::type('array'))->will(static function ($args): string { - return ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided'; - }); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn($args): string => ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided'); $addressRender = new AddressRender($engine->reveal(), $translatableStringHelper->reveal()); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php index f3e35ef93..9ee2ac82b 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php @@ -72,17 +72,13 @@ final class CalendarForShortMessageProviderTest extends TestCase Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::exact(0) - )->will(static function ($args) { - return array_fill(0, $args[2], new Calendar()); - })->shouldBeCalledTimes(1); + )->will(static fn($args) => array_fill(0, $args[2], new Calendar()))->shouldBeCalledTimes(1); $calendarRepository->findByNotificationAvailable( Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::not(0) - )->will(static function ($args) { - return array_fill(0, $args[2] - 1, new Calendar()); - })->shouldBeCalledTimes(1); + )->will(static fn($args) => array_fill(0, $args[2] - 1, new Calendar()))->shouldBeCalledTimes(1); $em = $this->prophesize(EntityManagerInterface::class); $em->clear()->shouldBeCalled(); @@ -108,17 +104,13 @@ final class CalendarForShortMessageProviderTest extends TestCase Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::exact(0) - )->will(static function ($args) { - return array_fill(0, 1, new Calendar()); - })->shouldBeCalledTimes(1); + )->will(static fn($args) => array_fill(0, 1, new Calendar()))->shouldBeCalledTimes(1); $calendarRepository->findByNotificationAvailable( Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::not(0) - )->will(static function ($args) { - return []; - })->shouldBeCalledTimes(1); + )->will(static fn($args) => [])->shouldBeCalledTimes(1); $em = $this->prophesize(EntityManagerInterface::class); $em->clear()->shouldBeCalled(); diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php index 41c8b4694..c60d947dd 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php @@ -58,9 +58,7 @@ class CustomFieldLongChoice extends AbstractCustomField $translatableStringHelper = $this->translatableStringHelper; $builder->add($customField->getSlug(), Select2ChoiceType::class, [ 'choices' => $entries, - 'choice_label' => static function (Option $option) use ($translatableStringHelper) { - return $translatableStringHelper->localize($option->getText()); - }, + 'choice_label' => static fn(Option $option) => $translatableStringHelper->localize($option->getText()), 'choice_value' => static fn (Option $key): ?int => null === $key ? null : $key->getId(), 'multiple' => false, 'expanded' => false, diff --git a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php index 328eda36a..e1ed1d363 100644 --- a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php +++ b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php @@ -57,8 +57,6 @@ class OptionRepository extends EntityRepository ->getQuery() ->getScalarResult(); - return array_map(static function ($r) { - return $r['key']; - }, $keys); + return array_map(static fn($r) => $r['key'], $keys); } } diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php index ea572759b..f9a9f2509 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php @@ -70,9 +70,7 @@ class CustomFieldType extends AbstractType if ('entity' === $options['group_widget']) { $builder->add('customFieldsGroup', EntityType::class, [ 'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup', - 'choice_label' => function ($g) { - return $this->translatableStringHelper->localize($g->getName()); - }, + 'choice_label' => fn($g) => $this->translatableStringHelper->localize($g->getName()), ]); } elseif ('hidden' === $options['group_widget']) { $builder->add('customFieldsGroup', HiddenType::class); diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php index bccf797e5..ab67ca581 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php @@ -38,9 +38,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface // @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here? $customFieldsLablels = array_map( - static function ($e) { - return $e->getLabel(); - }, + static fn($e) => $e->getLabel(), $customFields ); diff --git a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php index b5bd10d16..0b1fbec9d 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php +++ b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php @@ -61,12 +61,8 @@ class DocGeneratorTemplateType extends AbstractType $sub = $builder ->create('options', null, ['compound' => true]) ->addModelTransformer(new CallbackTransformer( - static function (array $data) use ($context) { - return $context->adminFormTransform($data); - }, - static function (array $data) use ($context) { - return $context->adminFormReverseTransform($data); - } + static fn(array $data) => $context->adminFormTransform($data), + static fn(array $data) => $context->adminFormReverseTransform($data) )); $context->buildAdminForm($sub); $builder->add($sub); diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php index 37540a2f8..15db2eed4 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php @@ -17,6 +17,6 @@ class ObjectReadyException extends RuntimeException { public function __construct() { - parent::__construct('object is already ready', 6698856); + parent::__construct('object is already ready', 6_698_856); } } diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php index 9cca0bcda..0453975b2 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php @@ -19,7 +19,7 @@ class RelatedEntityNotFoundException extends RuntimeException { parent::__construct( sprintf('Related entity not found: %s, %s', $relatedEntityClass, $relatedEntityId), - 99876652, + 99_876_652, $previous ); } diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index e83d3b3fc..0583e26b2 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -58,7 +58,7 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa * @ORM\Column(type="integer") * @Serializer\Groups({"read", "write"}) */ - private ?int $id; + private ?int $id = null; /** * @var int[] @@ -94,7 +94,7 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa /** * @ORM\ManyToOne(targetEntity=DocGeneratorTemplate::class) */ - private ?DocGeneratorTemplate $template; + private ?DocGeneratorTemplate $template = null; /** * @ORM\Column(type="text", options={"default": "ready"}) diff --git a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php index f77083390..255ca5dc5 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php @@ -72,14 +72,10 @@ class AccompanyingCourseDocumentType extends AbstractType ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('c') - ->where('c.documentClass = :docClass') - ->setParameter('docClass', AccompanyingCourseDocument::class); - }, - 'choice_label' => function ($entity = null) { - return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + ->where('c.documentClass = :docClass') + ->setParameter('docClass', AccompanyingCourseDocument::class), + 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); } diff --git a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php index c87cc4e73..c7cf31534 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php @@ -67,14 +67,10 @@ class PersonDocumentType extends AbstractType ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('c') - ->where('c.documentClass = :docClass') - ->setParameter('docClass', PersonDocument::class); - }, - 'choice_label' => function ($entity = null) { - return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + ->where('c.documentClass = :docClass') + ->setParameter('docClass', PersonDocument::class), + 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) { diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index c538bd107..b819ae8c3 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -51,9 +51,7 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler $persons = []; if (null !== $course) { - $persons = $course->getCurrentParticipations()->map(static function (AccompanyingPeriodParticipation $participation) { - return $participation->getPerson(); - })->toArray(); + $persons = $course->getCurrentParticipations()->map(static fn(AccompanyingPeriodParticipation $participation) => $participation->getPerson())->toArray(); } return [ diff --git a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php index dafbc8b8a..51ba3634d 100644 --- a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php +++ b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php @@ -113,9 +113,7 @@ class ParticipationController extends AbstractController [ 'event_id' => current($participations)->getEvent()->getId(), 'persons_ids' => implode(',', array_map( - static function (Participation $p) { - return $p->getPerson()->getId(); - }, + static fn(Participation $p) => $p->getPerson()->getId(), $participations )), ] @@ -649,19 +647,14 @@ class ParticipationController extends AbstractController // create a collection of person's id participating to the event /** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */ - $peopleParticipating = $peopleParticipating ?? - $participation->getEvent()->getParticipations()->map( - static function (Participation $p) { - return $p->getPerson()->getId(); - } - ); + $peopleParticipating ??= $participation->getEvent()->getParticipations()->map( + static fn(Participation $p) => $p->getPerson()->getId() + ); // check that the user is not already in the event if ($peopleParticipating->contains($participation->getPerson()->getId())) { $ignoredParticipations[] = $participation ->getEvent()->getParticipations()->filter( - static function (Participation $p) use ($participation) { - return $p->getPerson()->getId() === $participation->getPerson()->getId(); - } + static fn(Participation $p) => $p->getPerson()->getId() === $participation->getPerson()->getId() )->first(); } else { $newParticipations[] = $participation; diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index 6ac9c1508..669cb02db 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -176,9 +176,7 @@ class Event implements HasCenterInterface, HasScopeInterface { $iterator = $this->participations->getIterator(); - $iterator->uasort(static function ($first, $second) { - return strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName()); - }); + $iterator->uasort(static fn($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName())); return $iterator; } diff --git a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php index 30a00ebb9..de1c42cf8 100644 --- a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php +++ b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php @@ -62,9 +62,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedEvents, - static function (Event $p) use ($value) { - return call_user_func($value, $p); - } + static fn(Event $p) => call_user_func($value, $p) ); } diff --git a/src/Bundle/ChillEventBundle/Form/RoleType.php b/src/Bundle/ChillEventBundle/Form/RoleType.php index 9c56d17e6..2a0b6765a 100644 --- a/src/Bundle/ChillEventBundle/Form/RoleType.php +++ b/src/Bundle/ChillEventBundle/Form/RoleType.php @@ -38,9 +38,7 @@ class RoleType extends AbstractType ->add('active') ->add('type', EntityType::class, [ 'class' => EventType::class, - 'choice_label' => function (EventType $e) { - return $this->translatableStringHelper->localize($e->getName()); - }, + 'choice_label' => fn(EventType $e) => $this->translatableStringHelper->localize($e->getName()), ]); } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php index 4e8179f10..1ec088ba6 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php @@ -109,16 +109,12 @@ class PickEventType extends AbstractType // add the default options $resolver->setDefaults([ 'class' => Event::class, - 'choice_label' => static function (Event $e) { - return $e->getDate()->format('d/m/Y, H:i') . ' → ' . - // $e->getType()->getName()['fr'] . ': ' . // display the type of event - $e->getName(); - }, + 'choice_label' => static fn(Event $e) => $e->getDate()->format('d/m/Y, H:i') . ' → ' . + // $e->getType()->getName()['fr'] . ': ' . // display the type of event + $e->getName(), 'placeholder' => 'Pick an event', 'attr' => ['class' => 'select2 '], - 'choice_attr' => static function (Event $e) { - return ['data-center' => $e->getCenter()->getId()]; - }, + 'choice_attr' => static fn(Event $e) => ['data-center' => $e->getCenter()->getId()], 'choiceloader' => function (Options $options) { $centers = $this->filterCenters($options); @@ -143,9 +139,7 @@ class PickEventType extends AbstractType // option role if (null === $options['role']) { $centers = array_map( - static function (GroupCenter $g) { - return $g->getCenter(); - }, + static fn(GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray() ); } else { @@ -173,9 +167,7 @@ class PickEventType extends AbstractType if ( !in_array($c->getId(), array_map( - static function (Center $c) { - return $c->getId(); - }, + static fn(Center $c) => $c->getId(), $centers ), true) ) { diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php index eacdc78f1..2ecdb27d7 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php @@ -39,16 +39,10 @@ class PickEventTypeType extends AbstractType $resolver->setDefaults( [ 'class' => EventType::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('et') - ->where('et.active = true'); - }, - 'choice_label' => static function (EventType $t) use ($helper) { - return $helper->localize($t->getName()); - }, - 'choice_attrs' => static function (EventType $t) { - return ['data-link-category' => $t->getId()]; - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('et') + ->where('et.active = true'), + 'choice_label' => static fn(EventType $t) => $helper->localize($t->getName()), + 'choice_attrs' => static fn(EventType $t) => ['data-link-category' => $t->getId()], ] ); } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php b/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php index 95864056a..ca6425dc8 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php @@ -80,9 +80,7 @@ class PickRoleType extends AbstractType $options = $config->getOptions(); $form->getParent()->add($name, $type, array_replace($options, [ - 'group_by' => function (Role $r) { - return $this->translatableStringHelper->localize($r->getType()->getName()); - }, + 'group_by' => fn(Role $r) => $this->translatableStringHelper->localize($r->getType()->getName()), ])); } } @@ -111,17 +109,13 @@ class PickRoleType extends AbstractType 'class' => Role::class, 'query_builder' => $qb, 'group_by' => null, - 'choice_attr' => static function (Role $r) { - return [ - 'data-event-type' => $r->getType()->getId(), - 'data-link-category' => $r->getType()->getId(), - ]; - }, - 'choice_label' => static function (Role $r) use ($translatableStringHelper, $translator) { - return $translatableStringHelper->localize($r->getName()) . - ($r->getActive() === true ? '' : - ' (' . $translator->trans('unactive') . ')'); - }, + 'choice_attr' => static fn(Role $r) => [ + 'data-event-type' => $r->getType()->getId(), + 'data-link-category' => $r->getType()->getId(), + ], + 'choice_label' => static fn(Role $r) => $translatableStringHelper->localize($r->getName()) . + ($r->getActive() === true ? '' : + ' (' . $translator->trans('unactive') . ')'), ]); } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php b/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php index 4d96ed95d..b1078ab61 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php @@ -82,9 +82,7 @@ class PickStatusType extends AbstractType $type = $config->getType()->getName(); $options = $config->getOptions(); $form->getParent()->add($name, $type, array_replace($options, [ - 'group_by' => function (Status $s) { - return $this->translatableStringHelper->localize($s->getType()->getName()); - }, + 'group_by' => fn(Status $s) => $this->translatableStringHelper->localize($s->getType()->getName()), ])); } ); @@ -112,17 +110,13 @@ class PickStatusType extends AbstractType 'class' => Status::class, 'query_builder' => $qb, 'group_by' => null, - 'choice_attr' => static function (Status $s) { - return [ - 'data-event-type' => $s->getType()->getId(), - 'data-link-category' => $s->getType()->getId(), - ]; - }, - 'choice_label' => static function (Status $s) use ($translatableStringHelper, $translator) { - return $translatableStringHelper->localize($s->getName()) . - ($s->getActive() === true ? '' : - ' (' . $translator->trans('unactive') . ')'); - }, + 'choice_attr' => static fn(Status $s) => [ + 'data-event-type' => $s->getType()->getId(), + 'data-link-category' => $s->getType()->getId(), + ], + 'choice_label' => static fn(Status $s) => $translatableStringHelper->localize($s->getName()) . + ($s->getActive() === true ? '' : + ' (' . $translator->trans('unactive') . ')'), ]); } diff --git a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php index fa1ecabbe..7c79e52e3 100644 --- a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php @@ -239,9 +239,7 @@ final class ParticipationControllerTest extends WebTestCase $this->personsIdsCache = array_merge( $this->personsIdsCache, $event->getParticipations()->map( - static function ($p) { - return $p->getPerson()->getId(); - } + static fn($p) => $p->getPerson()->getId() ) ->toArray() ); @@ -305,9 +303,7 @@ final class ParticipationControllerTest extends WebTestCase $event = $this->getRandomEventWithMultipleParticipations(); $persons_id = implode(',', $event->getParticipations()->map( - static function ($p) { - return $p->getPerson()->getId(); - } + static fn($p) => $p->getPerson()->getId() )->toArray()); $crawler = $this->client->request( @@ -333,9 +329,7 @@ final class ParticipationControllerTest extends WebTestCase $nbParticipations = $event->getParticipations()->count(); // get the persons_id participating on this event $persons_id = $event->getParticipations()->map( - static function ($p) { - return $p->getPerson()->getId(); - } + static fn($p) => $p->getPerson()->getId() )->toArray(); // exclude the existing persons_ids from the new person $this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id); @@ -464,9 +458,7 @@ final class ParticipationControllerTest extends WebTestCase $circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(); - array_filter($circles, static function ($circle) use ($circleName) { - return in_array($circleName, $circle->getName(), true); - }); + array_filter($circles, static fn($circle) => in_array($circleName, $circle->getName(), true)); $circle = $circles[0]; $events = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class) diff --git a/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php b/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php index c1ae84b95..a7bf08741 100644 --- a/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php +++ b/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php @@ -208,9 +208,7 @@ class TimelineEventProvider implements TimelineProviderInterface foreach ($reachableCenters as $center) { $reachableCircleId = array_map( - static function (Scope $scope) { - return $scope->getId(); - }, + static fn(Scope $scope) => $scope->getId(), $this->helper->getReachableCircles($this->user, $role, $person->getCenter()) ); $centerAndScopeLines[] = sprintf( diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index 9e6555025..730ac32c1 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -230,7 +230,7 @@ class CRUDController extends AbstractController */ protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface { - $formClass = $formClass ?? $this->getFormClassFor($action); + $formClass ??= $this->getFormClassFor($action); $form = $this->createForm($formClass, $entity, $formOptions); diff --git a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php index 76da401a3..01f80d1b8 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php +++ b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php @@ -141,9 +141,7 @@ class CRUDRoutesLoader extends Loader $methods = array_keys(array_filter( $action['methods'], - static function ($value, $key) { - return $value; - }, + static fn($value, $key) => $value, ARRAY_FILTER_USE_BOTH )); diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index a6e876b6d..29ec6e7f0 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -282,9 +282,7 @@ class NotificationController extends AbstractController if ($request->query->has('edit')) { $commentId = $request->query->getInt('edit'); - $editedComment = $notification->getComments()->filter(static function (NotificationComment $c) use ($commentId) { - return $c->getId() === $commentId; - })->first(); + $editedComment = $notification->getComments()->filter(static fn(NotificationComment $c) => $c->getId() === $commentId)->first(); if (false === $editedComment) { throw $this->createNotFoundException("Comment with id {$commentId} does not exists nor belong to this notification"); diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index 372d0d7d1..3292b3540 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -158,9 +158,7 @@ class PermissionsGroupController extends AbstractController 'edit_form' => $editForm->createView(), 'role_scopes_sorted' => $roleScopesSorted, 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static function ($form) { - return $form->createView(); - }, $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -305,9 +303,7 @@ class PermissionsGroupController extends AbstractController 'role_scopes_sorted' => $roleScopesSorted, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static function ($form) { - return $form->createView(); - }, $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -449,9 +445,7 @@ class PermissionsGroupController extends AbstractController 'role_scopes_sorted' => $roleScopesSorted, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static function ($form) { - return $form->createView(); - }, $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -573,9 +567,7 @@ class PermissionsGroupController extends AbstractController if (!array_key_exists($roleScope->getRole(), $expandedRoles)) { $expandedRoles[$roleScope->getRole()] = array_map( - static function (Role $role) { - return $role->getRole(); - }, + static fn(Role $role) => $role->getRole(), $this->roleHierarchy ->getReachableRoles( [new Role($roleScope->getRole())] diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 9d3941411..64cef168d 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -337,9 +337,7 @@ class UserController extends CRUDController [ 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(), 'delete_groupcenter_form' => array_map( - static function (Form $form) { - return $form->createView(); - }, + static fn(Form $form) => $form->createView(), iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true) ), ] diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index ee09cc1a6..af4974bbe 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -345,12 +345,10 @@ class WorkflowController extends AbstractController if ($transitionForm->isSubmitted() && $transitionForm->isValid()) { if (!$workflow->can($entityWorkflow, $transition = $transitionForm['transition']->getData()->getName())) { $blockers = $workflow->buildTransitionBlockerList($entityWorkflow, $transition); - $msgs = array_map(function (TransitionBlocker $tb) { - return $this->translator->trans( - $tb->getMessage(), - $tb->getParameters() - ); - }, iterator_to_array($blockers)); + $msgs = array_map(fn(TransitionBlocker $tb) => $this->translator->trans( + $tb->getMessage(), + $tb->getParameters() + ), iterator_to_array($blockers)); throw $this->createAccessDeniedException( sprintf( diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php index ae53f09df..da2cbff1f 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php @@ -37,9 +37,7 @@ class MenuCompilerPass implements CompilerPassInterface ]; } - usort($services, static function ($a, $b) { - return $a['priority'] <=> $b['priority']; - }); + usort($services, static fn($a, $b) => $a['priority'] <=> $b['priority']); foreach ($services as $service) { $class = $container->getDefinition($service['id'])->getClass(); diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php index b9ca9c4b6..a56bcb50c 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php @@ -33,9 +33,7 @@ class Greatest extends FunctionNode public function getSql(SqlWalker $sqlWalker) { - return 'GREATEST(' . implode(', ', array_map(static function (Node $expr) use ($sqlWalker) { - return $expr->dispatch($sqlWalker); - }, $this->exprs)) . ')'; + return 'GREATEST(' . implode(', ', array_map(static fn(Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; } public function parse(Parser $parser) diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php index 0c8a1b17d..e31d31456 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php @@ -33,9 +33,7 @@ class Least extends FunctionNode public function getSql(SqlWalker $sqlWalker) { - return 'LEAST(' . implode(', ', array_map(static function (Node $expr) use ($sqlWalker) { - return $expr->dispatch($sqlWalker); - }, $this->exprs)) . ')'; + return 'LEAST(' . implode(', ', array_map(static fn(Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; } public function parse(Parser $parser) diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index 8bf4d1be5..1bd1a453a 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -149,7 +149,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface * @Groups({"write"}) * @ORM\JoinColumn(nullable=true, onDelete="SET NULL") */ - private ?ThirdParty $linkedToThirdParty; + private ?ThirdParty $linkedToThirdParty = null; /** * A geospatial field storing the coordinates of the Address. diff --git a/src/Bundle/ChillMainBundle/Entity/AddressReference.php b/src/Bundle/ChillMainBundle/Entity/AddressReference.php index 57421749f..e75402c5f 100644 --- a/src/Bundle/ChillMainBundle/Entity/AddressReference.php +++ b/src/Bundle/ChillMainBundle/Entity/AddressReference.php @@ -55,7 +55,7 @@ class AddressReference * @ORM\Column(type="integer") * @groups({"read"}) */ - private ?int $id; + private ?int $id = null; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) @@ -79,7 +79,7 @@ class AddressReference * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode") * @groups({"read"}) */ - private ?PostalCode $postcode; + private ?PostalCode $postcode = null; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) diff --git a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php index 37735bbc2..ea017f053 100644 --- a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php +++ b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php @@ -36,7 +36,7 @@ class GeographicalUnit /** * @ORM\ManyToOne(targetEntity=GeographicalUnitLayer::class, inversedBy="units") */ - private ?GeographicalUnitLayer $layer; + private ?GeographicalUnitLayer $layer = null; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) diff --git a/src/Bundle/ChillMainBundle/Entity/Notification.php b/src/Bundle/ChillMainBundle/Entity/Notification.php index b8586b2e6..dc81b1b54 100644 --- a/src/Bundle/ChillMainBundle/Entity/Notification.php +++ b/src/Bundle/ChillMainBundle/Entity/Notification.php @@ -120,12 +120,12 @@ class Notification implements TrackUpdateInterface /** * @ORM\Column(type="datetime_immutable") */ - private ?DateTimeImmutable $updatedAt; + private ?DateTimeImmutable $updatedAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) */ - private ?User $updatedBy; + private ?User $updatedBy = null; public function __construct() { diff --git a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php index fa505e550..34e22d3e1 100644 --- a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php +++ b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php @@ -121,9 +121,7 @@ class PermissionsGroup public function isRoleScopePresentOnce(ExecutionContextInterface $context) { $roleScopesId = array_map( - static function (RoleScope $roleScope) { - return $roleScope->getId(); - }, + static fn(RoleScope $roleScope) => $roleScope->getId(), $this->getRoleScopes()->toArray() ); $countedIds = array_count_values($roleScopesId); diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index e43d524a4..f94a154db 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -291,9 +291,7 @@ class EntityWorkflowStep public function removeDestEmail(string $email): self { - $this->destEmail = array_filter($this->destEmail, static function (string $existing) use ($email) { - return $email !== $existing; - }); + $this->destEmail = array_filter($this->destEmail, static fn(string $existing) => $email !== $existing); return $this; } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php index 7dc6f120f..a6b7094e4 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php @@ -199,9 +199,7 @@ class CSVListFormatter implements FormatterInterface foreach ($keys as $key) { // get an array with all values for this key if possible - $values = array_map(static function ($v) use ($key) { - return $v[$key]; - }, $this->result); + $values = array_map(static fn($v) => $v[$key], $this->result); // store the label in the labelsCache property $this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData); } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php index b062a9c3c..87814eb47 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php @@ -187,9 +187,7 @@ class CSVPivotedListFormatter implements FormatterInterface foreach ($keys as $key) { // get an array with all values for this key if possible - $values = array_map(static function ($v) use ($key) { - return $v[$key]; - }, $this->result); + $values = array_map(static fn($v) => $v[$key], $this->result); // store the label in the labelsCache property $this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData); } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php index 66db056c4..dc09c55a1 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php @@ -445,7 +445,7 @@ class SpreadSheetFormatter implements FormatterInterface $this->initializeCache($key); } - $value = $value ?? ''; + $value ??= ''; return call_user_func($this->cacheDisplayableResult[$key], $value); } diff --git a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php index c9882f557..99f78fe80 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php @@ -249,7 +249,7 @@ class ExportAddressHelper if (($params & $bitmask) === $bitmask) { if ('geographical_units' === $key) { // geographical unit generate keys dynamically, depending on layers - $prefixes = array_merge($prefixes, array_keys($this->generateKeysForUnitsNames($prefix)), array_keys($this->generateKeysForUnitsRefs($prefix))); + $prefixes = [...$prefixes, ...array_keys($this->generateKeysForUnitsNames($prefix)), ...array_keys($this->generateKeysForUnitsRefs($prefix))]; continue; } @@ -257,9 +257,7 @@ class ExportAddressHelper $prefixes = array_merge( $prefixes, array_map( - static function ($item) use ($prefix) { - return $prefix . $item; - }, + static fn($item) => $prefix . $item, self::COLUMN_MAPPING[$key] ) ); diff --git a/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php b/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php index bb9b180f5..99fb54514 100644 --- a/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php +++ b/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php @@ -48,9 +48,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedPostalCodes, - static function (?PostalCode $pc = null) use ($value) { - return call_user_func($value, $pc); - } + static fn(?PostalCode $pc = null) => call_user_func($value, $pc) ); } diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php index 52e053795..90c919f1d 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php @@ -37,9 +37,7 @@ class ExportPickCenterDataMapper implements DataMapperInterface foreach ($this->regroupmentRepository->findAll() as $regroupment) { /** @phpstan-ignore-next-line */ - [$contained, $notContained] = $regroupment->getCenters()->partition(static function (Center $center): bool { - return false; - }); + [$contained, $notContained] = $regroupment->getCenters()->partition(static fn(Center $center): bool => false); if (0 === count($notContained)) { $pickedRegroupment[] = $regroupment; diff --git a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php index cc215e7aa..4d89f7851 100644 --- a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php @@ -42,9 +42,7 @@ class IdToEntityDataTransformer implements DataTransformerInterface { $this->repository = $repository; $this->multiple = $multiple; - $this->getId = $getId ?? static function (object $o) { - return $o->getId(); - }; + $this->getId = $getId ?? static fn(object $o) => $o->getId(); } /** diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index 5a6776daf..3cf599a52 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -36,15 +36,11 @@ final class LocationFormType extends AbstractType $builder ->add('locationType', EntityType::class, [ 'class' => EntityLocationType::class, - 'choice_attr' => static function (EntityLocationType $entity) { - return [ - 'data-address' => $entity->getAddressRequired(), - 'data-contact' => $entity->getContactData(), - ]; - }, - 'choice_label' => function (EntityLocationType $entity) { - return $this->translatableStringHelper->localize($entity->getTitle()); - }, + 'choice_attr' => static fn(EntityLocationType $entity) => [ + 'data-address' => $entity->getAddressRequired(), + 'data-contact' => $entity->getContactData(), + ], + 'choice_label' => fn(EntityLocationType $entity) => $this->translatableStringHelper->localize($entity->getTitle()), ]) ->add('name', TextType::class) ->add('phonenumber1', ChillPhoneNumberType::class, ['required' => false]) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php index cfc838f5a..fdd24eb3f 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php @@ -24,14 +24,10 @@ class ComposedGroupCenterType extends AbstractType { $builder->add('permissionsgroup', EntityType::class, [ 'class' => \Chill\MainBundle\Entity\PermissionsGroup::class, - 'choice_label' => static function (PermissionsGroup $group) { - return $group->getName(); - }, + 'choice_label' => static fn(PermissionsGroup $group) => $group->getName(), ])->add('center', EntityType::class, [ 'class' => \Chill\MainBundle\Entity\Center::class, - 'choice_label' => static function (Center $center) { - return $center->getName(); - }, + 'choice_label' => static fn(Center $center) => $center->getName(), ]); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php index a09130c03..4424cccf3 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php @@ -82,15 +82,11 @@ class ComposedRoleScopeType extends AbstractType return ['data-has-scope' => '1']; }, - 'group_by' => function ($role, $key, $index) { - return $this->roleProvider->getRoleTitle($role); - }, + 'group_by' => fn($role, $key, $index) => $this->roleProvider->getRoleTitle($role), ]) ->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => static function (Scope $scope) use ($translatableStringHelper) { - return $translatableStringHelper->localize($scope->getName()); - }, + 'choice_label' => static fn(Scope $scope) => $translatableStringHelper->localize($scope->getName()), 'required' => false, 'data' => null, ]); diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index d4759a794..24e3ffc5b 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -51,9 +51,7 @@ class EntityToJsonTransformer implements DataTransformerInterface } return array_map( - function ($item) { - return $this->denormalizeOne($item); - }, + fn($item) => $this->denormalizeOne($item), $denormalized ); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index 8287a8814..7a1ebcaf5 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -67,9 +67,7 @@ final class PickCenterType extends AbstractType 'choices' => $centers, 'multiple' => true, 'expanded' => true, - 'choice_label' => static function (Center $c) { - return $c->getName(); - }, + 'choice_label' => static fn(Center $c) => $c->getName(), 'data' => $centers, ]); @@ -80,9 +78,7 @@ final class PickCenterType extends AbstractType 'multiple' => true, 'expanded' => true, 'choices' => $this->regroupmentRepository->findAllActive(), - 'choice_label' => static function (Regroupment $r) { - return $r->getName(); - }, + 'choice_label' => static fn(Regroupment $r) => $r->getName(), ]); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php index 0f6dd44bc..b977dd102 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php @@ -90,9 +90,7 @@ class PickCenterType extends AbstractType return ['center' => $data]; }, - static function ($data) { - return $data['center']; - } + static fn($data) => $data['center'] )); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php index 84342dfc3..c5e0f7d80 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php @@ -34,17 +34,13 @@ class PickCivilityType extends AbstractType ->setDefault('label', 'Civility') ->setDefault( 'choice_label', - function (Civility $civility): string { - return $this->translatableStringHelper->localize($civility->getName()); - } + fn(Civility $civility): string => $this->translatableStringHelper->localize($civility->getName()) ) ->setDefault( 'query_builder', - static function (EntityRepository $er): QueryBuilder { - return $er->createQueryBuilder('c') - ->where('c.active = true') - ->orderBy('c.order'); - }, + static fn(EntityRepository $er): QueryBuilder => $er->createQueryBuilder('c') + ->where('c.active = true') + ->orderBy('c.order'), ) ->setDefault('placeholder', 'choose civility') ->setDefault('class', Civility::class); diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php index 6774e0941..0763e485e 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php @@ -31,9 +31,7 @@ class PickLocationTypeType extends AbstractType $resolver ->setDefaults([ 'class' => LocationType::class, - 'choice_label' => function (LocationType $type) { - return $this->translatableStringHelper->localize($type->getTitle()); - }, + 'choice_label' => fn(LocationType $type) => $this->translatableStringHelper->localize($type->getTitle()), 'placeholder' => 'Pick a location type', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php index 792daa39e..bd19e5f29 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php @@ -36,11 +36,9 @@ class PickUserLocationType extends AbstractType ->setDefaults([ 'class' => Location::class, 'choices' => $this->locationRepository->findByPublicLocations(), - 'choice_label' => function (Location $entity) { - return $entity->getName() ? - $entity->getName() . ' (' . $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ')' : - $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()); - }, + 'choice_label' => fn(Location $entity) => $entity->getName() ? + $entity->getName() . ' (' . $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ')' : + $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()), 'placeholder' => 'Pick a location', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php b/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php index 60fefddfa..a611f3da9 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php @@ -77,10 +77,8 @@ class PostalCodeType extends AbstractType $helper = $this->translatableStringHelper; $resolver ->setDefault('class', PostalCode::class) - ->setDefault('choice_label', static function (PostalCode $code) use ($helper) { - return $code->getCode() . ' ' . $code->getName() . ' [' . - $helper->localize($code->getCountry()->getName()) . ']'; - }) + ->setDefault('choice_label', static fn(PostalCode $code) => $code->getCode() . ' ' . $code->getName() . ' [' . + $helper->localize($code->getCountry()->getName()) . ']') ->setDefault('choice_loader', $this->choiceLoader) ->setDefault('placeholder', 'Select a postal code'); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index 79ed6df40..77bf84cca 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -66,9 +66,7 @@ class ScopePickerType extends AbstractType $options['role'] instanceof Role ? $options['role']->getRole() : $options['role'], $options['center'] ), - static function (Scope $s) { - return $s->isActive(); - } + static fn(Scope $s) => $s->isActive() ); if (0 === count($items)) { @@ -79,9 +77,7 @@ class ScopePickerType extends AbstractType $builder->add('scope', EntityType::class, [ 'class' => Scope::class, 'placeholder' => 'Choose the circle', - 'choice_label' => function (Scope $c) { - return $this->translatableStringHelper->localize($c->getName()); - }, + 'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()), 'choices' => $items, ]); $builder->setDataMapper(new ScopePickerDataMapper()); diff --git a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php index 6b1bb357a..974ef4566 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php @@ -79,9 +79,7 @@ class UserPickerType extends AbstractType ->setAllowedTypes('having_permissions_group_flag', ['string', 'null']) ->setDefault('class', User::class) ->setDefault('placeholder', 'Choose an user') - ->setDefault('choice_label', function (User $u) { - return $this->userRender->renderString($u, []); - }) + ->setDefault('choice_label', fn(User $u) => $this->userRender->renderString($u, [])) ->setDefault('scope', null) ->setAllowedTypes('scope', [Scope::class, 'array', 'null']) ->setNormalizer('choices', function (Options $options) { diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index e2255a1ab..e343b0fc4 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -77,18 +77,14 @@ class UserType extends AbstractType 'required' => false, 'placeholder' => 'Choose a main scope', 'class' => Scope::class, - 'choice_label' => function (Scope $c) { - return $this->translatableStringHelper->localize($c->getName()); - }, + 'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()), ]) ->add('userJob', EntityType::class, [ 'label' => 'user job', 'required' => false, 'placeholder' => 'choose a job', 'class' => UserJob::class, - 'choice_label' => function (UserJob $c) { - return $this->translatableStringHelper->localize($c->getLabel()); - }, + 'choice_label' => fn(UserJob $c) => $this->translatableStringHelper->localize($c->getLabel()), 'query_builder' => static function (EntityRepository $er) { $qb = $er->createQueryBuilder('uj'); $qb->where('uj.active = TRUE'); @@ -101,9 +97,7 @@ class UserType extends AbstractType 'required' => false, 'placeholder' => 'choose a location', 'class' => Location::class, - 'choice_label' => function (Location $l) { - return $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName(); - }, + 'choice_label' => fn(Location $l) => $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName(), 'query_builder' => static function (EntityRepository $er) { $qb = $er->createQueryBuilder('l'); $qb->orderBy('l.locationType'); diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index 328917ac7..0e6e12b3e 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -69,9 +69,7 @@ class WorkflowStepType extends AbstractType $choices = array_combine( array_map( - static function (Transition $transition) { - return $transition->getName(); - }, + static fn(Transition $transition) => $transition->getName(), $transitions ), $transitions @@ -88,14 +86,10 @@ class WorkflowStepType extends AbstractType 'backward' => 'backward', 'neutral' => 'neutral', ], - 'choice_label' => function (string $key) use ($inputLabels) { - return $this->translatableStringHelper->localize($inputLabels[$key]); - }, - 'choice_attr' => static function (string $key) { - return [ - $key => $key, - ]; - }, + 'choice_label' => fn(string $key) => $this->translatableStringHelper->localize($inputLabels[$key]), + 'choice_attr' => static fn(string $key) => [ + $key => $key, + ], 'mapped' => false, 'expanded' => true, 'data' => 'forward', diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php index ea5ed2062..e4ee3b062 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php @@ -72,7 +72,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface ] ) ->setExtras([ - 'order' => -9999999, + 'order' => -9_999_999, 'icon' => 'map-marker', ]); @@ -84,7 +84,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface 'route' => 'chill_main_user_absence_index', ]) ->setExtras([ - 'order' => -8888888, + 'order' => -8_888_888, ]); $menu @@ -116,7 +116,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface ['route' => 'change_my_password'] ) ->setExtras([ - 'order' => 99999999998, + 'order' => 99_999_999_998, ]); } } @@ -129,7 +129,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface ] ) ->setExtras([ - 'order' => 99999999999, + 'order' => 99_999_999_999, 'icon' => 'power-off', ]); } diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index a629a45d2..9010c8548 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -90,9 +90,7 @@ class SearchProvider public function getByOrder() { //sort the array - uasort($this->searchServices, static function (SearchInterface $a, SearchInterface $b) { - return $a->getOrder() <=> $b->getOrder(); - }); + uasort($this->searchServices, static fn(SearchInterface $a, SearchInterface $b) => $a->getOrder() <=> $b->getOrder()); return $this->searchServices; } @@ -119,9 +117,7 @@ class SearchProvider public function getHasAdvancedFormSearchServices() { //sort the array - uasort($this->hasAdvancedFormSearchServices, static function (SearchInterface $a, SearchInterface $b) { - return $a->getOrder() <=> $b->getOrder(); - }); + uasort($this->hasAdvancedFormSearchServices, static fn(SearchInterface $a, SearchInterface $b) => $a->getOrder() <=> $b->getOrder()); return $this->hasAdvancedFormSearchServices; } diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php index 88a9cb4c5..a52379faa 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php @@ -54,9 +54,7 @@ class AddressReferenceBEFromBestAddress throw new RuntimeException('could not get the release definition', 0, $e); } - $asset = array_filter($release['assets'], static function (array $item) use ($lang, $list) { - return 'addresses-' . $list . '.' . $lang . '.csv.gz' === $item['name']; - }); + $asset = array_filter($release['assets'], static fn(array $item) => 'addresses-' . $list . '.' . $lang . '.csv.gz' === $item['name']); return array_values($asset)[0]['browser_download_url']; } diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php index 64acd072a..4bca126a6 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php @@ -82,9 +82,7 @@ class PostalCodeBEFromBestAddress throw new RuntimeException('could not get the release definition', 0, $e); } - $postals = array_filter($release['assets'], static function (array $item) use ($lang) { - return 'postals.' . $lang . '.csv.gz' === $item['name']; - }); + $postals = array_filter($release['assets'], static fn(array $item) => 'postals.' . $lang . '.csv.gz' === $item['name']); return array_values($postals)[0]['browser_download_url']; } diff --git a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php index 4658d7e3b..c6246213f 100644 --- a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php +++ b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php @@ -39,9 +39,7 @@ class ChillMailer implements MailerInterface } $this->chillLogger->info('chill email sent', [ - 'to' => array_map(static function (Address $address) { - return $address->getAddress(); - }, $message->getTo()), + 'to' => array_map(static fn(Address $address) => $address->getAddress(), $message->getTo()), 'subject' => $message->getSubject(), ]); diff --git a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php index 9246cf1e6..051d04591 100644 --- a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php @@ -134,9 +134,7 @@ final class NotificationTest extends KernelTestCase $this->assertEquals($senderId, $notification->getSender()->getId()); $this->assertCount(count($addressesIds), $notification->getUnreadBy()); - $unreadIds = $notification->getUnreadBy()->map(static function (User $u) { - return $u->getId(); - }); + $unreadIds = $notification->getUnreadBy()->map(static fn(User $u) => $u->getId()); foreach ($addressesIds as $addresseeId) { $this->assertContains($addresseeId, $unreadIds); diff --git a/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php b/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php index ce41c9a21..42f6d71d8 100644 --- a/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php @@ -96,9 +96,7 @@ final class ScopePickerTypeTest extends TypeTestCase $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); $translatableStringHelper->localize(Argument::type('array'))->will( - static function ($args) { - return $args[0]['fr']; - } + static fn($args) => $args[0]['fr'] ); $type = new ScopePickerType( diff --git a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php index 392e9a4ff..5f79494a3 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php @@ -52,9 +52,7 @@ final class ExtractDateFromPatternTest extends TestCase $this->assertContainsOnlyInstancesOf(DateTimeImmutable::class, $result->getFound()); $dates = array_map( - static function (DateTimeImmutable $d) { - return $d->format('Y-m-d'); - }, + static fn(DateTimeImmutable $d) => $d->format('Y-m-d'), $result->getFound() ); diff --git a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php index 8e3c27e99..657e37e36 100644 --- a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php @@ -211,9 +211,7 @@ final class AuthorizationHelperTest extends KernelTestCase $centerA ); - $usernames = array_map(static function (User $u) { - return $u->getUsername(); - }, $users); + $usernames = array_map(static fn(User $u) => $u->getUsername(), $users); $this->assertContains('center a_social', $usernames); } diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php index 192ca0712..dfe47ecc8 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php @@ -105,9 +105,7 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac [ '%users%' => implode( ', ', - $entityWorkflow->getCurrentStep()->getAllDestUser()->map(function (User $u) { - return $this->userRender->renderString($u, []); - })->toArray() + $entityWorkflow->getCurrentStep()->getAllDestUser()->map(fn(User $u) => $this->userRender->renderString($u, []))->toArray() ), ] )); diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php index f02341ff7..dc9657e3c 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php @@ -109,9 +109,7 @@ class NotificationOnTransition implements EventSubscriberInterface 'dest' => $subscriber, 'place' => $place, 'workflow' => $workflow, - 'is_dest' => in_array($subscriber->getId(), array_map(static function (User $u) { - return $u->getId(); - }, $entityWorkflow->futureDestUsers), true), + 'is_dest' => in_array($subscriber->getId(), array_map(static fn(User $u) => $u->getId(), $entityWorkflow->futureDestUsers), true), ]; $notification = new Notification(); diff --git a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php index 0c8d1c72f..6ab44f625 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php +++ b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php @@ -59,9 +59,7 @@ class EntityWorkflowCreationValidator extends \Symfony\Component\Validator\Const $workflows = $this->entityWorkflowManager->getSupportedWorkflows($value); - $matched = array_filter($workflows, static function (WorkflowInterface $workflow) use ($value) { - return $workflow->getName() === $value->getWorkflowName(); - }); + $matched = array_filter($workflows, static fn(WorkflowInterface $workflow) => $workflow->getName() === $value->getWorkflowName()); if (0 === count($matched)) { $this->context->buildViolation($constraint->messageWorkflowNotAvailable) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index 70ea1d3c5..d7289c68a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -169,9 +169,7 @@ final class AccompanyingCourseApiController extends ApiController $accompanyingPeriods = $person->getCurrentAccompanyingPeriods(); $accompanyingPeriodsChecked = array_filter( $accompanyingPeriods, - function (AccompanyingPeriod $period) { - return $this->isGranted(AccompanyingPeriodVoter::SEE, $period); - } + fn(AccompanyingPeriod $period) => $this->isGranted(AccompanyingPeriodVoter::SEE, $period) ); return $this->json(array_values($accompanyingPeriodsChecked), Response::HTTP_OK, [], ['groups' => ['read']]); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php index e9e27f9c9..18098a129 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php @@ -222,14 +222,10 @@ class AccompanyingPeriodController extends AbstractController $accompanyingPeriodsRaw = $this->accompanyingPeriodACLAwareRepository ->findByPerson($person, AccompanyingPeriodVoter::SEE); - usort($accompanyingPeriodsRaw, static function ($a, $b) { - return $b->getOpeningDate() > $a->getOpeningDate(); - }); + usort($accompanyingPeriodsRaw, static fn($a, $b) => $b->getOpeningDate() > $a->getOpeningDate()); // filter visible or not visible - $accompanyingPeriods = array_filter($accompanyingPeriodsRaw, function (AccompanyingPeriod $ap) { - return $this->isGranted(AccompanyingPeriodVoter::SEE, $ap); - }); + $accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn(AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap)); return $this->render('@ChillPerson/AccompanyingPeriod/list.html.twig', [ 'accompanying_periods' => $accompanyingPeriods, @@ -331,9 +327,7 @@ class AccompanyingPeriodController extends AbstractController /** @var AccompanyingPeriod $period */ $period = array_filter( $person->getAccompanyingPeriods(), - static function (AccompanyingPeriod $p) use ($period_id) { - return $p->getId() === ($period_id); - } + static fn(AccompanyingPeriod $p) => $p->getId() === ($period_id) )[0] ?? null; if (null === $period) { diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php index a91b0f5ff..ced5ccd9d 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php @@ -105,12 +105,8 @@ class AccompanyingPeriodRegulationListController $builder ->add('services', EntityType::class, [ 'class' => Scope::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('s'); - }, - 'choice_label' => function (Scope $s) { - return $this->translatableStringHelper->localize($s->getName()); - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('s'), + 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize($s->getName()), 'multiple' => true, 'label' => 'Service', 'required' => false, @@ -123,9 +119,7 @@ class AccompanyingPeriodRegulationListController return $qb; }, - 'choice_label' => function (UserJob $j) { - return $this->translatableStringHelper->localize($j->getLabel()); - }, + 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()), 'multiple' => true, 'label' => 'Métier', 'required' => false, @@ -147,9 +141,7 @@ class AccompanyingPeriodRegulationListController return $qb; }, - 'choice_label' => static function (Location $l) { - return $l->getName(); - }, + 'choice_label' => static fn(Location $l) => $l->getName(), 'multiple' => true, 'group_by' => function (Location $l) { if (null === $type = $l->getLocationType()) { diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php index 43d35934b..98fa0ebfe 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php @@ -164,9 +164,7 @@ class HouseholdCompositionController extends AbstractController $isEdit = $request->query->has('edit'); if ($isEdit) { - $householdCompositions = $household->getCompositions()->filter(static function (HouseholdComposition $composition) use ($request) { - return $composition->getId() === $request->query->getInt('edit'); - }); + $householdCompositions = $household->getCompositions()->filter(static fn(HouseholdComposition $composition) => $composition->getId() === $request->query->getInt('edit')); if ($householdCompositions->count() !== 1) { throw new BadRequestHttpException('could not find the composition with this id associated to the household'); diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php index 7b9eb0084..68f32c886 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php @@ -81,9 +81,7 @@ class HouseholdController extends AbstractController } } - usort($accompanyingPeriods, static function ($a, $b) { - return $b->getOpeningDate() <=> $a->getOpeningDate(); - }); + usort($accompanyingPeriods, static fn($a, $b) => $b->getOpeningDate() <=> $a->getOpeningDate()); $oldMembers = $household->getNonCurrentMembers(); $accompanyingPeriodsOld = []; diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index bf0d998ff..35256ce56 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -108,14 +108,10 @@ class PersonApiController extends ApiController $addresses = $person ->getAccompanyingPeriodParticipations() ->filter( - static function (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool { - return null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation(); - } + static fn(AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool => null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() ) ->map( - static function (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address { - return $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation(); - } + static fn(AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address => $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() ) ->filter( // We remove potential null addresses. diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php index 3ae5c5b7c..75293fd7b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php @@ -44,9 +44,7 @@ class SocialWorkSocialActionApiController extends ApiController $socialActions = $socialIssue->getRecursiveSocialActions()->toArray(); - usort($socialActions, static function (SocialAction $sa, SocialAction $sb) { - return $sa->getOrdering() <=> $sb->getOrdering(); - }); + usort($socialActions, static fn(SocialAction $sa, SocialAction $sb) => $sa->getOrdering() <=> $sb->getOrdering()); $pagination = $this->paginator->create(count($socialActions)); // max one page diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php index 87746842a..fb5ae6e4e 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php @@ -115,9 +115,7 @@ class LoadCustomFields extends AbstractFixture implements // get possible values for cfGroup $choices = array_map( - static function ($a) { - return $a['slug']; - }, + static fn($a) => $a['slug'], $this->customFieldChoice->getOptions()['choices'] ); // create faker diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 510e1c327..364cb41d5 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -828,9 +828,7 @@ class AccompanyingPeriod implements $collection = $this ->getParticipationsContainsPerson($person) ->filter( - static function (AccompanyingPeriodParticipation $participation): bool { - return null === $participation->getEndDate(); - } + static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() ); return $collection->count() > 0 ? $collection->first() : null; @@ -844,9 +842,7 @@ class AccompanyingPeriod implements return $this ->getParticipations() ->filter( - static function (AccompanyingPeriodParticipation $participation): bool { - return null === $participation->getEndDate(); - } + static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() ); } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php index 592c833d3..1652a45e9 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php @@ -44,20 +44,20 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface * @Assert\NotBlank * @Assert\NotNull */ - private ?string $content; + private ?string $content = null; /** * @ORM\Column(type="datetime") * @Groups({"read", "docgen:read"}) */ - private ?DateTimeInterface $createdAt; + private ?DateTimeInterface $createdAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * @ORM\JoinColumn(nullable=false) * @Groups({"read", "docgen:read"}) */ - private ?User $creator; + private ?User $creator = null; /** * @ORM\Id @@ -65,20 +65,20 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface * @ORM\Column(type="integer") * @Groups({"read", "docgen:read"}) */ - private ?int $id; + private ?int $id = null; /** * @ORM\Column(type="datetime") * @Groups({"read"}) */ - private ?DateTimeInterface $updatedAt; + private ?DateTimeInterface $updatedAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * @ORM\JoinColumn(nullable=false) * @Groups({"read"}) */ - private ?User $updatedBy; + private ?User $updatedBy = null; public function getAccompanyingPeriod(): ?AccompanyingPeriod { diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php index 48e1ac1fc..2fa1df203 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php @@ -200,13 +200,11 @@ class Household */ public function getCurrentAddress(?DateTime $at = null): ?Address { - $at = $at ?? new DateTime('today'); + $at ??= new DateTime('today'); - $addrs = $this->getAddresses()->filter(static function (Address $a) use ($at) { - return $a->getValidFrom() <= $at && ( - null === $a->getValidTo() || $a->getValidTo() > $at - ); - }); + $addrs = $this->getAddresses()->filter(static fn(Address $a) => $a->getValidFrom() <= $at && ( + null === $a->getValidTo() || $a->getValidTo() > $at + )); if ($addrs->count() > 0) { return $addrs->first(); @@ -338,9 +336,7 @@ class Household public function getCurrentPersons(?DateTimeImmutable $now = null): ReadableCollection { return $this->getCurrentMembers($now) - ->map(static function (HouseholdMember $m) { - return $m->getPerson(); - }); + ->map(static fn(HouseholdMember $m) => $m->getPerson()); } public function getId(): ?int @@ -367,9 +363,7 @@ class Household $membership->getStartDate(), $membership->getEndDate() )->filter( - static function (HouseholdMember $m) use ($membership) { - return $m->getPerson() !== $membership->getPerson(); - } + static fn(HouseholdMember $m) => $m->getPerson() !== $membership->getPerson() ); } @@ -508,9 +502,7 @@ class Household usort( $compositionOrdered, - static function (HouseholdComposition $a, HouseholdComposition $b) { - return $a->getStartDate() <=> $b->getStartDate(); - } + static fn(HouseholdComposition $a, HouseholdComposition $b) => $a->getStartDate() <=> $b->getStartDate() ); $iterator = new ArrayIterator($compositionOrdered); diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php index 031279173..fad3b213a 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php @@ -142,7 +142,7 @@ class HouseholdMember public function isCurrent(?DateTimeImmutable $at = null): bool { - $at = $at ?? new DateTimeImmutable('now'); + $at ??= new DateTimeImmutable('now'); return $this->getStartDate() < $at && ( null === $this->getEndDate() || $this->getEndDate() > $at diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 63bd6efba..1507bafd7 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -775,9 +775,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI ): int { // TODO should be optimized to avoid loading accompanying period ? return $this->getAccompanyingPeriodInvolved($asParticipantOpen, $asRequestor) - ->filter(function (AccompanyingPeriod $p) { - return $p->getStep() !== AccompanyingPeriod::STEP_DRAFT; - }) + ->filter(fn(AccompanyingPeriod $p) => $p->getStep() !== AccompanyingPeriod::STEP_DRAFT) ->count(); } @@ -1341,9 +1339,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this->getAccompanyingPeriodParticipations() ->matching($criteria) - ->filter(static function (AccompanyingPeriodParticipation $app) { - return AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep(); - }); + ->filter(static fn(AccompanyingPeriodParticipation $app) => AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep()); } public function getOtherPhoneNumbers(): Collection diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCurrentAddress.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCurrentAddress.php index d95f4c7c8..52d6a34af 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCurrentAddress.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCurrentAddress.php @@ -50,7 +50,7 @@ class PersonCurrentAddress /** * @ORM\Column(name="valid_to", type="date_immutable") */ - protected ?DateTimeImmutable $validTo; + protected ?DateTimeImmutable $validTo = null; public function getAddress(): Address { diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php index 576380476..a4b6cf085 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php @@ -55,7 +55,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface * @ORM\Column(type="integer") * @Groups({"read", "docgen:read"}) */ - private ?int $id; + private ?int $id = null; /** * @ORM\ManyToOne(targetEntity=PersonResourceKind::class, inversedBy="personResources") diff --git a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php index 5013ac9b7..068260b45 100644 --- a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php +++ b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php @@ -41,7 +41,7 @@ class PersonPhone * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ - private ?int $id; + private ?int $id = null; /** * @ORM\ManyToOne( @@ -59,7 +59,7 @@ class PersonPhone /** * @ORM\Column(type="text", length=40, nullable=true) */ - private ?string $type; + private ?string $type = null; public function __construct() { diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php index 823f31426..f65192a04 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php @@ -45,7 +45,7 @@ class Result /** * @ORM\Column(type="datetime", nullable=true) */ - private ?DateTime $desactivationDate; + private ?DateTime $desactivationDate = null; /** * @ORM\ManyToMany(targetEntity=Goal::class, mappedBy="results") diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index 80781b823..c018eb95f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -128,9 +128,7 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface 'placeholder' => 'Select a geographical layer', 'class' => GeographicalUnitLayer::class, 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), - 'choice_label' => function (GeographicalUnitLayer $item) { - return $this->translatableStringHelper->localize($item->getName()); - }, + 'choice_label' => fn(GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php index 395070a8a..c2923c9e9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php @@ -147,9 +147,7 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme ]; } - return static function (string $value) use ($labels): string { - return $labels[$value]; - }; + return static fn(string $value): string => $labels[$value]; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php index 6193f3c61..1ab9f1b78 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php @@ -100,9 +100,7 @@ class GeographicalUnitAggregator implements AggregatorInterface 'placeholder' => 'Select a geographical layer', 'class' => GeographicalUnitLayer::class, 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), - 'choice_label' => function (GeographicalUnitLayer $item) { - return $this->translatableStringHelper->localize($item->getName()); - }, + 'choice_label' => fn(GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php index 1eced58d3..b91a90000 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php @@ -141,9 +141,7 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ]; } - return static function ($value) use ($labels): string { - return $labels[$value]; - }; + return static fn($value): string => $labels[$value]; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index a9f794888..7cb2e623f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -64,9 +64,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -91,9 +89,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php index 40253ea0b..412890241 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php @@ -63,9 +63,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -90,9 +88,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->em->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 578cc1452..4efd7e246 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -62,9 +62,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -89,9 +87,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index f1eaeb4cb..2b782d1ed 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -113,9 +113,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php index 07a307563..528be42c8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php @@ -62,9 +62,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data) @@ -94,9 +92,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->personRepository->createQueryBuilder('person'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index 7acbd09cf..e58439112 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -64,9 +64,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -91,9 +89,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index cacdf2ee1..1bfd1870f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -290,9 +290,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php index d0c1863c3..17c2c4f99 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php @@ -263,9 +263,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index 010618733..0f63d41ca 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -241,9 +241,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php index fc72de77b..d176f7bb8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php @@ -146,9 +146,7 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index 21675a86a..322917b02 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -191,9 +191,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php index bab67fb39..35bb8a6c1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php @@ -159,9 +159,7 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index c124f0227..0c2fb63f5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -112,9 +112,7 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php index 07e61b42e..05c883309 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php @@ -59,9 +59,7 @@ class ClosingMotiveFilter implements FilterInterface { $builder->add('accepted_closingmotives', EntityType::class, [ 'class' => ClosingMotive::class, - 'choice_label' => function (ClosingMotive $cm) { - return $this->translatableStringHelper->localize($cm->getName()); - }, + 'choice_label' => fn(ClosingMotive $cm) => $this->translatableStringHelper->localize($cm->getName()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index 62cf49d6d..497068c39 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -61,11 +61,9 @@ class CreatorJobFilter implements FilterInterface $builder->add('creator_job', EntityType::class, [ 'class' => UserJob::class, 'choices' => $this->userJobRepository->findAllActive(), - 'choice_label' => function (UserJob $j) { - return $this->translatableStringHelper->localize( - $j->getLabel() - ); - }, + 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + $j->getLabel() + ), 'multiple' => true, 'expanded' => true, 'label' => 'Job', diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index 1839268e1..7f409c022 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -69,9 +69,7 @@ class EvaluationFilter implements FilterInterface $builder->add('accepted_evaluations', EntityType::class, [ 'class' => Evaluation::class, 'choices' => $this->evaluationRepository->findAllActive(), - 'choice_label' => function (Evaluation $ev) { - return $this->translatableStringHelper->localize($ev->getTitle()); - }, + 'choice_label' => fn(Evaluation $ev) => $this->translatableStringHelper->localize($ev->getTitle()), 'multiple' => true, 'expanded' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index 5bbb22e53..719029d38 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -107,9 +107,7 @@ class GeographicalUnitStatFilter implements FilterInterface 'placeholder' => 'Select a geographical unit', 'choices' => $this->geographicalUnitRepository->findAll(), 'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id, - 'choice_label' => function (SimpleGeographicalUnitDTO $item) { - return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName; - }, + 'choice_label' => fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, 'attr' => [ 'class' => 'select2', ], @@ -124,9 +122,7 @@ class GeographicalUnitStatFilter implements FilterInterface '%units' => implode( ', ', array_map( - function (SimpleGeographicalUnitDTO $item) { - return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName; - }, + fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, $data['units'] ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php index 445535734..bde641b2d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php @@ -59,9 +59,7 @@ class OriginFilter implements FilterInterface { $builder->add('accepted_origins', EntityType::class, [ 'class' => Origin::class, - 'choice_label' => function (Origin $o) { - return $this->translatableStringHelper->localize($o->getLabel()); - }, + 'choice_label' => fn(Origin $o) => $this->translatableStringHelper->localize($o->getLabel()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php index 65e38f41e..15be1a52b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php @@ -59,9 +59,7 @@ final class EvaluationTypeFilter implements FilterInterface { $builder->add('accepted_evaluationtype', EntityType::class, [ 'class' => Evaluation::class, - 'choice_label' => function (Evaluation $ev): string { - return $this->translatableStringHelper->localize($ev->getTitle()); - }, + 'choice_label' => fn(Evaluation $ev): string => $this->translatableStringHelper->localize($ev->getTitle()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index 922702418..7eb00fc2b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -78,11 +78,9 @@ class CompositionFilter implements FilterInterface $builder ->add('accepted_composition', EntityType::class, [ 'class' => HouseholdCompositionType::class, - 'choice_label' => function (HouseholdCompositionType $type) { - return $this->translatableStringHelper->localize( - $type->getLabel() - ); - }, + 'choice_label' => fn(HouseholdCompositionType $type) => $this->translatableStringHelper->localize( + $type->getLabel() + ), 'multiple' => true, 'expanded' => true, ]) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php index 0fe1973e9..5ecdc1fda 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php @@ -81,9 +81,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface ->add('ref_statuses', ChoiceType::class, [ 'label' => 'export.filter.person.by_address_ref_status.Status', 'choices' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW, Address::ADDR_REFERENCE_STATUS_REVIEWED, Address::ADDR_REFERENCE_STATUS_MATCH], - 'choice_label' => function (string $item) { - return 'export.filter.person.by_address_ref_status.'.$item; - }, + 'choice_label' => fn(string $item) => 'export.filter.person.by_address_ref_status.'.$item, 'multiple' => true, 'expanded' => true, 'data' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW] @@ -99,9 +97,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface '%statuses%' => implode( ', ', array_map( - function (string $item) { - return 'export.filter.person.by_address_ref_status.'.$item; - }, + fn(string $item) => 'export.filter.person.by_address_ref_status.'.$item, $data['ref_statuses'] ?? RollingDate::T_TODAY ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php index 228749c34..92b8ad08b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php @@ -67,9 +67,7 @@ class GenderFilter implements $qb->add('where', $where); $qb->setParameter('person_gender', array_filter( $data['accepted_genders'], - static function ($el) { - return 'null' !== $el; - } + static fn($el) => 'null' !== $el )); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php index 9bdb3f2d4..15882b705 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php @@ -98,9 +98,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface 'placeholder' => 'Select a geographical unit', 'choices' => $this->geographicalUnitRepository->findAll(), 'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id, - 'choice_label' => function (SimpleGeographicalUnitDTO $item) { - return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName; - }, + 'choice_label' => fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, 'attr' => [ 'class' => 'select2', ], @@ -117,9 +115,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface '%units%' => implode( ', ', array_map( - function (SimpleGeographicalUnitDTO $item) { - return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName; - }, + fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, $data['units'] ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php index aad98a394..62b6a34d7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -49,11 +49,9 @@ class MaritalStatusFilter implements FilterInterface { $builder->add('maritalStatus', EntityType::class, [ 'class' => MaritalStatus::class, - 'choice_label' => function (MaritalStatus $ms) { - return $this->translatableStringHelper->localize( - $ms->getName() - ); - }, + 'choice_label' => fn(MaritalStatus $ms) => $this->translatableStringHelper->localize( + $ms->getName() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php index 1156527cc..19e5f999c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php @@ -72,9 +72,7 @@ class NationalityFilter implements { $countries = $data['nationalities']; - $names = array_map(function (Country $c) { - return $this->translatableStringHelper->localize($c->getName()); - }, [$countries]); + $names = array_map(fn(Country $c) => $this->translatableStringHelper->localize($c->getName()), [$countries]); return [ 'Filtered by nationality : %nationalities%', diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index 90003c6bf..32dc2a2fb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -100,9 +100,7 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface $builder->add('thirdparty_cat', EntityType::class, [ 'class' => ThirdPartyCategory::class, 'label' => 'Category', - 'choice_label' => function (ThirdPartyCategory $tpc) { - return $this->translatableStringHelper->localize($tpc->getName()); - }, + 'choice_label' => fn(ThirdPartyCategory $tpc) => $this->translatableStringHelper->localize($tpc->getName()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index a69e1ac76..1c38a030e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -69,11 +69,9 @@ class JobFilter implements FilterInterface { $builder->add('job', EntityType::class, [ 'class' => UserJob::class, - 'choice_label' => function (UserJob $j) { - return $this->translatableStringHelper->localize( - $j->getLabel() - ); - }, + 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + $j->getLabel() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index 8cb2f6421..5d8e20832 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -69,11 +69,9 @@ class ScopeFilter implements FilterInterface { $builder->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => function (Scope $s) { - return $this->translatableStringHelper->localize( - $s->getName() - ); - }, + 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + $s->getName() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index 853d50744..11fd0ed9d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -136,7 +136,7 @@ class SocialWorkTypeFilter implements FilterInterface } return ['Filtered actions by type, goals and results: %selected%', [ - '%selected%' => implode(', ', array_merge($actionTypes, $goals, $results)), + '%selected%' => implode(', ', [...$actionTypes, ...$goals, ...$results]), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php index 0e63fe580..fe9a3490f 100644 --- a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php +++ b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php @@ -55,9 +55,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedPersons, - static function (Person $p) use ($value) { - return call_user_func($value, $p); - } + static fn(Person $p) => call_user_func($value, $p) ); } diff --git a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php index d6919cc5d..6e4877b63 100644 --- a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php +++ b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php @@ -40,9 +40,7 @@ class HouseholdCompositionType extends AbstractType ->add('householdCompositionType', EntityType::class, [ 'class' => \Chill\PersonBundle\Entity\Household\HouseholdCompositionType::class, 'choices' => $types, - 'choice_label' => function (\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) { - return $this->translatableStringHelper->localize($type->getLabel()); - }, + 'choice_label' => fn(\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) => $this->translatableStringHelper->localize($type->getLabel()), 'label' => 'household_composition.Household composition', ]) ->add('startDate', ChillDateType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 42e62929d..4752fb628 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -118,12 +118,8 @@ class PersonType extends AbstractType ]); $builder->get('placeOfBirth')->addModelTransformer(new CallbackTransformer( - static function ($string) { - return strtoupper((string) $string); - }, - static function ($string) { - return strtoupper((string) $string); - } + static fn($string) => strtoupper((string) $string), + static fn($string) => strtoupper((string) $string) )); } @@ -167,9 +163,7 @@ class PersonType extends AbstractType 'allow_delete' => true, 'by_reference' => false, 'label' => false, - 'delete_empty' => static function (?PersonPhone $pp = null) { - return null === $pp || $pp->isEmpty(); - }, + 'delete_empty' => static fn(?PersonPhone $pp = null) => null === $pp || $pp->isEmpty(), 'error_bubbling' => false, 'empty_collection_explain' => 'No additional phone numbers', ]); diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php index 6d07bf64f..7a6a7484d 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php @@ -46,9 +46,7 @@ class GoalType extends AbstractType 'class' => Result::class, 'required' => false, 'multiple' => true, - 'choice_label' => function (Result $r) { - return $this->translatableStringHelper->localize($r->getTitle()); - }, + 'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()), 'attr' => ['class' => 'select2 '], ]) ->add('desactivationDate', ChillDateType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php index 5a6095f7b..7f5b434dd 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php @@ -50,16 +50,12 @@ class SocialActionType extends AbstractType ->add('issue', EntityType::class, [ 'class' => SocialIssue::class, 'label' => 'socialAction.socialIssue', - 'choice_label' => function (SocialIssue $issue) { - return $this->translatableStringHelper->localize($issue->getTitle()); - }, + 'choice_label' => fn(SocialIssue $issue) => $this->translatableStringHelper->localize($issue->getTitle()), ]) ->add('parent', EntityType::class, [ 'class' => SocialAction::class, 'required' => false, - 'choice_label' => function (SocialAction $issue) { - return $this->translatableStringHelper->localize($issue->getTitle()); - }, + 'choice_label' => fn(SocialAction $issue) => $this->translatableStringHelper->localize($issue->getTitle()), ]) ->add('ordering', NumberType::class, [ 'required' => true, @@ -70,9 +66,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => function (Result $r) { - return $this->translatableStringHelper->localize($r->getTitle()); - }, + 'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()), ]) ->add('goals', EntityType::class, [ @@ -80,9 +74,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => function (Goal $g) { - return $this->translatableStringHelper->localize($g->getTitle()); - }, + 'choice_label' => fn(Goal $g) => $this->translatableStringHelper->localize($g->getTitle()), ]) ->add('evaluations', EntityType::class, [ @@ -90,9 +82,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => function (Evaluation $e) { - return $this->translatableStringHelper->localize($e->getTitle()); - }, + 'choice_label' => fn(Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), ]) ->add('defaultNotificationDelay', DateIntervalType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php b/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php index 2f96d4966..2b4613376 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php @@ -60,18 +60,14 @@ class ClosingMotivePickerType extends AbstractType 'class' => ClosingMotive::class, 'empty_data' => null, 'placeholder' => 'Choose a motive', - 'choice_label' => function (ClosingMotive $cm) { - return $this->entityRenderExtension->renderString($cm); - }, + 'choice_label' => fn(ClosingMotive $cm) => $this->entityRenderExtension->renderString($cm), 'only_leaf' => true, ]); $resolver ->setAllowedTypes('only_leaf', 'bool') - ->setNormalizer('choices', function (Options $options) { - return $this->repository - ->getActiveClosingMotive($options['only_leaf']); - }); + ->setNormalizer('choices', fn(Options $options) => $this->repository + ->getActiveClosingMotive($options['only_leaf'])); } /** diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php index 501af5b9d..3c0a1d5af 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php @@ -113,15 +113,11 @@ class PickPersonType extends AbstractType // add the default options $resolver->setDefaults([ 'class' => Person::class, - 'choice_label' => static function (Person $p) { - return $p->getFirstname() . ' ' . $p->getLastname(); - }, + 'choice_label' => static fn(Person $p) => $p->getFirstname() . ' ' . $p->getLastname(), 'placeholder' => 'Pick a person', - 'choice_attr' => static function (Person $p) { - return [ - 'data-center' => $p->getCenter()->getId(), - ]; - }, + 'choice_attr' => static fn(Person $p) => [ + 'data-center' => $p->getCenter()->getId(), + ], 'attr' => ['class' => 'select2 '], 'choice_loader' => function (Options $options) { $centers = $this->filterCentersfom($options); @@ -139,9 +135,7 @@ class PickPersonType extends AbstractType protected function filterCentersfom(Options $options) { if (null === $options['role']) { - $centers = array_map(static function (GroupCenter $g) { - return $g->getCenter(); - }, $this->user->getGroupCenters()->toArray()); + $centers = array_map(static fn(GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray()); } else { $centers = $this->authorizationHelper ->getReachableCenters($this->user, $options['role']->getRole()); @@ -164,9 +158,7 @@ class PickPersonType extends AbstractType if ( !in_array($c->getId(), array_map( - static function (Center $c) { - return $c->getId(); - }, + static fn(Center $c) => $c->getId(), $centers ), true) ) { diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php index 7c0da43b1..695d3aa12 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php @@ -38,9 +38,7 @@ class PickSocialActionType extends AbstractType ->setDefaults([ 'class' => SocialAction::class, 'choices' => $this->actionRepository->findAllActive(), - 'choice_label' => function (SocialAction $sa) { - return $this->actionRender->renderString($sa, []); - }, + 'choice_label' => fn(SocialAction $sa) => $this->actionRender->renderString($sa, []), 'placeholder' => 'Pick a social action', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php index e79c17191..9c02a7905 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php @@ -38,9 +38,7 @@ class PickSocialIssueType extends AbstractType ->setDefaults([ 'class' => SocialIssue::class, 'choices' => $this->issueRepository->findAllActive(), - 'choice_label' => function (SocialIssue $si) { - return $this->issueRender->renderString($si, []); - }, + 'choice_label' => fn(SocialIssue $si) => $this->issueRender->renderString($si, []), 'placeholder' => 'Pick a social issue', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php index 0b67537cb..f83d6faf4 100644 --- a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php @@ -76,9 +76,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface $involved = $this->getInvolved(); $involved['period_id'] = $event->getPeriod()->getId(); $involved['persons'] = $event->getPeriod()->getPersons() - ->map(static function (Person $p) { - return $p->getId(); - }) + ->map(static fn(Person $p) => $p->getId()) ->toArray(); $this->logger->notice( @@ -102,9 +100,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface if ($event->hasPersons()) { $involved['persons'] = array_map( - static function (Person $p) { - return $p->getId(); - }, + static fn(Person $p) => $p->getId(), $event->getPersons() ); } diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php index cc9e7b145..bbe6eed32 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php @@ -322,9 +322,7 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac ), ] ), - array_map(static function (Center $c) { - return $c->getId(); - }, $authorizedCenters) + array_map(static fn(Center $c) => $c->getId(), $authorizedCenters) ); } } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php index 47a15db54..3e2308089 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php @@ -97,9 +97,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi private function checkAssociatedMembersRole(Household $household, string $attribute): bool { - foreach ($household->getCurrentMembers()->map(static function (HouseholdMember $member) { - return $member->getPerson(); - }) as $person) { + foreach ($household->getCurrentMembers()->map(static fn(HouseholdMember $member) => $member->getPerson()) as $person) { if ($this->security->isGranted($attribute, $person)) { return true; } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php index 0e1c81592..bbd068fc9 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php @@ -150,12 +150,8 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf $this->closingMotiveRender->renderString($period->getClosingMotive(), []) : '', 'ref' => $this->normalizer->normalize($period->getUser(), $format, $userContext), 'hasRef' => $period->getUser() !== null, - 'socialIssuesText' => implode(', ', array_map(function (SocialIssue $s) { - return $this->socialIssueRender->renderString($s, []); - }, $period->getSocialIssues()->toArray())), - 'scopesText' => implode(', ', array_map(function (Scope $s) { - return $this->translatableStringHelper->localize($s->getName()); - }, $scopes)), + 'socialIssuesText' => implode(', ', array_map(fn(SocialIssue $s) => $this->socialIssueRender->renderString($s, []), $period->getSocialIssues()->toArray())), + 'scopesText' => implode(', ', array_map(fn(Scope $s) => $this->translatableStringHelper->localize($s->getName()), $scopes)), 'hasRequestor' => $period->getRequestor() !== null, 'requestorKind' => $period->getRequestorKind(), 'hasLocation' => $period->getLocation() !== null, diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php index 8cd917961..a6b13af4e 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php @@ -48,9 +48,7 @@ class AccompanyingPeriodWorkEvaluationNormalizer implements ContextAwareNormaliz $initial = $this->normalizer->normalize($object, $format, array_merge( $context, [self::IGNORE_EVALUATION => spl_object_hash($object)], - [AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => static function ($object, $format, $context) { - return $object->getId(); - }] + [AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => static fn($object, $format, $context) => $object->getId()] )); // due to bug: https://api-platform.com/docs/core/serialization/#collection-relation diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php index 74ca55398..308fe3ba1 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php @@ -94,9 +94,7 @@ class PersonDocGenNormalizer implements // we simplify the list of attributes for the embedded persons AbstractNormalizer::GROUPS => ['docgen:read'], // when a person reference the same person... take care of circular references - AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => function ($object, $format, $context) { - return $this->normalizer->normalize(null, $format, $context); - }, + AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => fn($object, $format, $context) => $this->normalizer->normalize(null, $format, $context), ]); if (null === $person) { @@ -117,9 +115,7 @@ class PersonDocGenNormalizer implements 'altNames' => implode( ', ', array_map( - static function (PersonAltName $altName) { - return $altName->getLabel(); - }, + static fn(PersonAltName $altName) => $altName->getLabel(), $person->getAltNames()->toArray() ) ), diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index a94ae3af9..29570e532 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -257,12 +257,10 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar { return $altNames ->map( - static function (PersonAltName $personAltName): array { - return [ - 'key' => $personAltName->getKey(), - 'label' => $personAltName->getLabel(), - ]; - } + static fn(PersonAltName $personAltName): array => [ + 'key' => $personAltName->getKey(), + 'label' => $personAltName->getLabel(), + ] ) ->toArray(); } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php index 3f2e46b3f..1f8994644 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php @@ -37,9 +37,7 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz 'type' => 'social_issue', 'id' => $socialIssue->getId(), 'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null, - 'children_ids' => $socialIssue->getChildren()->map(static function (SocialIssue $si) { - return $si->getId(); - }), + 'children_ids' => $socialIssue->getChildren()->map(static fn(SocialIssue $si) => $si->getId()), 'title' => $socialIssue->getTitle(), 'text' => $this->render->renderString($socialIssue, []), ]; diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index 4a08eff08..ed66593c4 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -143,14 +143,10 @@ class AccompanyingPeriodContext implements ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('c') - ->where('c.documentClass = :docClass') - ->setParameter('docClass', AccompanyingCourseDocument::class); - }, - 'choice_label' => function ($entity = null) { - return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + ->where('c.documentClass = :docClass') + ->setParameter('docClass', AccompanyingCourseDocument::class), + 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); } @@ -160,9 +156,7 @@ class AccompanyingPeriodContext implements public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, mixed $entity): void { $options = $template->getOptions(); - $persons = new ArrayCollection($entity->getCurrentParticipations()->map(static function (AccompanyingPeriodParticipation $p) { - return $p->getPerson(); - })->toArray()); + $persons = new ArrayCollection($entity->getCurrentParticipations()->map(static fn(AccompanyingPeriodParticipation $p) => $p->getPerson())->toArray()); foreach ($entity->getCurrentParticipations() as $p) { foreach ($p->getPerson()->getResources() as $r) { @@ -187,9 +181,7 @@ class AccompanyingPeriodContext implements $builder->add($key, EntityType::class, [ 'class' => Person::class, 'choices' => $persons, - 'choice_label' => function (Person $p) { - return $this->personRender->renderString($p, ['addAge' => true]); - }, + 'choice_label' => fn(Person $p) => $this->personRender->renderString($p, ['addAge' => true]), 'multiple' => false, 'expanded' => true, 'required' => false, diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index 4718b7b00..325e666b9 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -63,9 +63,7 @@ class AccompanyingPeriodWorkEvaluationContext implements $this->accompanyingPeriodWorkContext->adminFormReverseTransform($data), [ 'evaluations' => array_map( - static function (Evaluation $e) { - return $e->getId(); - }, + static fn(Evaluation $e) => $e->getId(), $data['evaluations'] ), ] @@ -78,9 +76,7 @@ class AccompanyingPeriodWorkEvaluationContext implements $this->accompanyingPeriodWorkContext->adminFormTransform($data), [ 'evaluations' => array_map( - function ($id) { - return $this->evaluationRepository->find($id); - }, + fn($id) => $this->evaluationRepository->find($id), $data['evaluations'] ?? [] ), ] @@ -97,9 +93,7 @@ class AccompanyingPeriodWorkEvaluationContext implements 'class' => Evaluation::class, 'label' => 'Linked evaluations', 'choices' => $this->evaluationRepository->findAll(), - 'choice_label' => function (Evaluation $e) { - return $this->translatableStringHelper->localize($e->getTitle()); - }, + 'choice_label' => fn(Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), 'multiple' => true, 'attr' => ['class' => 'select2'], ]); diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index c7c7d2352..8a7b7e2ba 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -126,14 +126,10 @@ final class PersonContext implements PersonContextInterface ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('c') - ->where('c.documentClass = :docClass') - ->setParameter('docClass', PersonDocument::class); - }, - 'choice_label' => function ($entity = null) { - return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + ->where('c.documentClass = :docClass') + ->setParameter('docClass', PersonDocument::class), + 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', 'required' => true, ]); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index 596e0a870..53d6a0a93 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -342,9 +342,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase // check that the person id is contained $participationsPersonsIds = array_map( - static function ($participation) { - return $participation->person->id; - }, + static fn($participation) => $participation->person->id, $data->participations ); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php index 710c5fc6b..cb0587b5e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -161,9 +161,7 @@ final class HouseholdApiControllerTest extends WebTestCase $this->assertArrayHasKey('count', $data); $this->assertArrayHasKey('results', $data); - $householdIds = array_map(static function ($r) { - return $r['id']; - }, $data['results']); + $householdIds = array_map(static fn($r) => $r['id'], $data['results']); $this->assertContains($expectedHouseholdId, $householdIds); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php index bb70866e2..cf8c134ad 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php @@ -294,49 +294,23 @@ final class PersonControllerUpdateTest extends WebTestCase public function validTextFieldsProvider() { return [ - ['firstName', 'random Value', static function (Person $person) { - return $person->getFirstName(); - }], - ['lastName', 'random Value', static function (Person $person) { - return $person->getLastName(); - }], + ['firstName', 'random Value', static fn(Person $person) => $person->getFirstName()], + ['lastName', 'random Value', static fn(Person $person) => $person->getLastName()], // reminder: this value is capitalized - ['placeOfBirth', 'A PLACE', static function (Person $person) { - return $person->getPlaceOfBirth(); - }], - ['birthdate', '1980-12-15', static function (Person $person) { - return $person->getBirthdate()->format('Y-m-d'); - }], + ['placeOfBirth', 'A PLACE', static fn(Person $person) => $person->getPlaceOfBirth()], + ['birthdate', '1980-12-15', static fn(Person $person) => $person->getBirthdate()->format('Y-m-d')], // TODO test on phonenumber update // ['phonenumber', '+32123456789', static function (Person $person) { return $person->getPhonenumber(); }], - ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) { - return $person->getMemo(); - }], - ['countryOfBirth', 'BE', static function (Person $person) { - return $person->getCountryOfBirth()->getCountryCode(); - }], - ['nationality', 'FR', static function (Person $person) { - return $person->getNationality()->getCountryCode(); - }], - ['placeOfBirth', '', static function (Person $person) { - return $person->getPlaceOfBirth(); - }], - ['birthdate', '', static function (Person $person) { - return $person->getBirthdate(); - }], + ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn(Person $person) => $person->getMemo()], + ['countryOfBirth', 'BE', static fn(Person $person) => $person->getCountryOfBirth()->getCountryCode()], + ['nationality', 'FR', static fn(Person $person) => $person->getNationality()->getCountryCode()], + ['placeOfBirth', '', static fn(Person $person) => $person->getPlaceOfBirth()], + ['birthdate', '', static fn(Person $person) => $person->getBirthdate()], //['phonenumber', '', static function (Person $person) { return $person->getPhonenumber(); }], - ['memo', '', static function (Person $person) { - return $person->getMemo(); - }], - ['countryOfBirth', null, static function (Person $person) { - return $person->getCountryOfBirth(); - }], - ['nationality', null, static function (Person $person) { - return $person->getNationality(); - }], - ['gender', Person::FEMALE_GENDER, static function (Person $person) { - return $person->getGender(); - }], + ['memo', '', static fn(Person $person) => $person->getMemo()], + ['countryOfBirth', null, static fn(Person $person) => $person->getCountryOfBirth()], + ['nationality', null, static fn(Person $person) => $person->getNationality()], + ['gender', Person::FEMALE_GENDER, static fn(Person $person) => $person->getGender()], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php index 403f89dd4..d9cf2241a 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php @@ -197,24 +197,12 @@ final class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase public function validTextFieldsProvider() { return [ - ['firstName', 'random Value', static function (Person $person) { - return $person->getFirstName(); - }], - ['lastName', 'random Value', static function (Person $person) { - return $person->getLastName(); - }], - ['birthdate', '15-12-1980', static function (Person $person) { - return $person->getBirthdate()->format('d-m-Y'); - }], - ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) { - return $person->getMemo(); - }], - ['birthdate', '', static function (Person $person) { - return $person->getBirthdate(); - }], - ['gender', Person::FEMALE_GENDER, static function (Person $person) { - return $person->getGender(); - }], + ['firstName', 'random Value', static fn(Person $person) => $person->getFirstName()], + ['lastName', 'random Value', static fn(Person $person) => $person->getLastName()], + ['birthdate', '15-12-1980', static fn(Person $person) => $person->getBirthdate()->format('d-m-Y')], + ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn(Person $person) => $person->getMemo()], + ['birthdate', '', static fn(Person $person) => $person->getBirthdate()], + ['gender', Person::FEMALE_GENDER, static fn(Person $person) => $person->getGender()], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php index 2f38da244..5ce35317e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php @@ -152,9 +152,7 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase $locations = $period->getLocationHistories()->toArray(); - usort($locations, static function (AccompanyingPeriod\AccompanyingPeriodLocationHistory $a, AccompanyingPeriod\AccompanyingPeriodLocationHistory $b) { - return $a->getStartDate() <=> $b->getStartDate(); - }); + usort($locations, static fn(AccompanyingPeriod\AccompanyingPeriodLocationHistory $a, AccompanyingPeriod\AccompanyingPeriodLocationHistory $b) => $a->getStartDate() <=> $b->getStartDate()); $iterator = new ArrayIterator($locations); $iterator->rewind(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php b/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php index a58560bdd..55169757f 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php @@ -101,19 +101,13 @@ final class MembersEditorTest extends TestCase $editor = $factory->createEditor($household2 = new Household()); $editor->addMovement(new DateTimeImmutable('yesterday'), $person, $positionNotSharing); - $sharings = $household->getCurrentMembers()->filter(static function (HouseholdMember $m) { - return $m->getShareHousehold(); - }); - $notSharing = $household2->getCurrentMembers()->filter(static function (HouseholdMember $m) { - return !$m->getShareHousehold(); - }); + $sharings = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => $m->getShareHousehold()); + $notSharing = $household2->getCurrentMembers()->filter(static fn(HouseholdMember $m) => !$m->getShareHousehold()); $this->assertCount(1, $notSharing); $this->assertCount(1, $sharings); - $getPerson = static function (HouseholdMember $m) { - return $m->getPerson(); - }; + $getPerson = static fn(HouseholdMember $m) => $m->getPerson(); $this->assertContains($person, $notSharing->map($getPerson)); } @@ -143,19 +137,13 @@ final class MembersEditorTest extends TestCase $editor = $factory->createEditor($household); $editor->addMovement(new DateTimeImmutable('yesterday'), $person, $positionNotSharing); - $sharings = $household->getCurrentMembers()->filter(static function (HouseholdMember $m) { - return $m->getShareHousehold(); - }); - $notSharing = $household->getCurrentMembers()->filter(static function (HouseholdMember $m) { - return !$m->getShareHousehold(); - }); + $sharings = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => $m->getShareHousehold()); + $notSharing = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => !$m->getShareHousehold()); $this->assertCount(1, $notSharing); $this->assertCount(0, $sharings); - $getPerson = static function (HouseholdMember $m) { - return $m->getPerson(); - }; + $getPerson = static fn(HouseholdMember $m) => $m->getPerson(); $this->assertContains($person, $notSharing->map($getPerson)); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php index e85813d62..6057a29c9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php @@ -318,9 +318,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase $normalizerManager = $this->prophesize(NormalizerInterface::class); $normalizerManager->supportsNormalization(Argument::any(), 'docgen', Argument::any())->willReturn(true); $normalizerManager->normalize(Argument::type(Person::class), 'docgen', Argument::any()) - ->will(static function ($args) use ($normalizer) { - return $normalizer->normalize($args[0], $args[1], $args[2]); - }); + ->will(static fn($args) => $normalizer->normalize($args[0], $args[1], $args[2])); $normalizerManager->normalize(Argument::any(), 'docgen', Argument::any())->will( static function ($args) { if (is_iterable($args[0])) { diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php index 05d2eace1..6d841436e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php @@ -118,9 +118,7 @@ final class RelationshipDocGenNormalizerTest extends TestCase { $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); $translatableStringHelper->localize(Argument::type('array'))->will( - static function ($args) { - return $args[0][array_keys($args[0])[0]]; - } + static fn($args) => $args[0][array_keys($args[0])[0]] ); $normalizer = new RelationshipDocGenNormalizer( @@ -130,9 +128,7 @@ final class RelationshipDocGenNormalizerTest extends TestCase $normalizerManager = $this->prophesize(NormalizerInterface::class); $normalizerManager->supportsNormalization(Argument::any(), 'docgen', Argument::any())->willReturn(true); $normalizerManager->normalize(Argument::type(Relationship::class), 'docgen', Argument::any()) - ->will(static function ($args) use ($normalizer) { - return $normalizer->normalize($args[0], $args[1], $args[2]); - }); + ->will(static fn($args) => $normalizer->normalize($args[0], $args[1], $args[2])); $normalizerManager->normalize(Argument::any(), 'docgen', Argument::any())->will( static function ($args) { if (null === $args[0]) { diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php index 17c6195b3..e84b27813 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php @@ -263,9 +263,7 @@ final class PersonContextTest extends TestCase if (null === $translatableStringHelper) { $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); // return only the 'fr' key - $translatableStringHelper->localize(Argument::type('array'))->will(static function ($args) { - return $args[0]['fr']; - }); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn($args) => $args[0]['fr']); $translatableStringHelper = $translatableStringHelper->reveal(); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php index a4f08e7c1..753a9f855 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php @@ -70,9 +70,7 @@ final class PersonContextWithThirdPartyTest extends KernelTestCase { $normalizer = $this->prophesize(NormalizerInterface::class); $normalizer->normalize(Argument::type(ThirdParty::class), 'docgen', Argument::type('array')) - ->will(static function ($args): array { - return ['class' => '3party', 'hash' => spl_object_hash($args[0])]; - }); + ->will(static fn($args): array => ['class' => '3party', 'hash' => spl_object_hash($args[0])]); $personContext = $this->prophesize(PersonContextInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php index 9454d31d0..cae4829f7 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php @@ -74,9 +74,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator $periodIssuesWithAncestors = array_merge( $periodIssuesWithAncestors, array_map( - static function (SocialIssue $si) { - return spl_object_hash($si); - }, + static fn(SocialIssue $si) => spl_object_hash($si), $si->getAncestors(true) ) ); diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 16ae19daa..d957f37e3 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -306,7 +306,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface } // add the key from slugs and return - return array_merge($fields, array_keys($this->slugs)); + return [...$fields, ...array_keys($this->slugs)]; } public function getResult($query, $data) @@ -331,9 +331,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { @@ -505,9 +503,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface private function getCustomFields() { return array_filter($this->customfieldsGroup - ->getCustomFields()->toArray(), static function (CustomField $cf) { - return $cf->getType() !== 'title'; - }); + ->getCustomFields()->toArray(), static fn(CustomField $cf) => $cf->getType() !== 'title'); } private function getLabelForCustomField($key, array $values, $data) diff --git a/src/Bundle/ChillReportBundle/Search/ReportSearch.php b/src/Bundle/ChillReportBundle/Search/ReportSearch.php index e392c37f5..e0aaa89e1 100644 --- a/src/Bundle/ChillReportBundle/Search/ReportSearch.php +++ b/src/Bundle/ChillReportBundle/Search/ReportSearch.php @@ -97,9 +97,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface foreach ($reachableCenters as $center) { $reachableScopesId = array_map( - static function (Scope $scope) { - return $scope->getId(); - }, + static fn(Scope $scope) => $scope->getId(), $this->helper->getReachableScopes($this->user, $role, $center) ); $whereElement->add( diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php index d299860bc..803ecf38f 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php @@ -68,9 +68,7 @@ final class ReportControllerNextTest extends WebTestCase //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, - static function (CustomFieldsGroup $group) { - return in_array('Situation de logement', $group->getName(), true); - } + static fn(CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) ); $this->group = $filteredCustomFieldsGroupHouse[0]; } diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php index 1afe851b8..cd3b0f185 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php @@ -86,9 +86,7 @@ final class ReportControllerTest extends WebTestCase //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, - static function (CustomFieldsGroup $group) { - return in_array('Situation de logement', $group->getName(), true); - } + static fn(CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) ); self::$group = $filteredCustomFieldsGroupHouse[0]; diff --git a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php index ecaabb495..253616a84 100644 --- a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php @@ -67,9 +67,7 @@ final class TimelineProviderTest extends WebTestCase self::$em ->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(), - static function (Scope $scope) { - return $scope->getName()['en'] === 'social'; - } + static fn(Scope $scope) => $scope->getName()['en'] === 'social' ); $report = (new Report()) diff --git a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php index 900920a7f..0e28fffa9 100644 --- a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php +++ b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php @@ -267,7 +267,7 @@ class TimelineReportProvider implements TimelineProviderInterface '{scopes_ids}' => implode(', ', array_fill(0, count($scopeIds), '?')), ]); // append $scopeIds to parameters - $parameters = array_merge($parameters, $scopeIds); + $parameters = [...$parameters, ...$scopeIds]; } if (0 === count($formattedClauses)) { diff --git a/src/Bundle/ChillTaskBundle/Controller/TaskController.php b/src/Bundle/ChillTaskBundle/Controller/TaskController.php index 6525d5572..2c052619b 100644 --- a/src/Bundle/ChillTaskBundle/Controller/TaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/TaskController.php @@ -94,9 +94,7 @@ class TaskController extends AbstractController $transitionInstance = array_values( // array_values needed to reset keys (array_filter preserves keys) array_filter( $workflow->getEnabledTransitions($task), - static function (Transition $t) use ($transition) { - return $t->getName() === $transition; - } + static fn(Transition $t) => $t->getName() === $transition ) )[0]; diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php index 4020eeef3..ec336856e 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php @@ -218,13 +218,9 @@ class SingleTaskListType extends AbstractType $users = $this->getUsersAssigneedToTask($options); $choices = array_combine( // get usernames - array_map(static function (User $user) { - return $user->getUsername(); - }, $users), + array_map(static fn(User $user) => $user->getUsername(), $users), // get ids - array_map(static function (User $user) { - return $user->getId(); - }, $users) + array_map(static fn(User $user) => $user->getId(), $users) ); $choices['Unassigned'] = '_unassigned'; diff --git a/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php b/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php index c51eb9ed4..50c360610 100644 --- a/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php +++ b/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php @@ -92,9 +92,7 @@ final class SingleTaskControllerTest extends WebTestCase $center = array_filter( $centers, - static function (Center $c) use ($centerName) { - return $c->getName() === $centerName; - } + static fn(Center $c) => $c->getName() === $centerName )[0]; $ids = $em diff --git a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php index b29c1818e..c07fd707e 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php @@ -86,9 +86,7 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn ->findBy(['id' => $ids]); return array_combine( - array_map(static function ($e) { - return $e->getId(); - }, $events), + array_map(static fn($e) => $e->getId(), $events), $events ); } diff --git a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php index 4d8ddd062..e6f98cef9 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php @@ -97,9 +97,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface ->findBy(['id' => $ids]); return array_combine( - array_map(static function ($e) { - return $e->getId(); - }, $events), + array_map(static fn($e) => $e->getId(), $events), $events ); } diff --git a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php index 6b40f01b9..8250f7bf0 100644 --- a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php @@ -69,9 +69,7 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface private function getCenters(): Iterator { $references = array_map( - static function ($a) { - return $a['ref']; - }, + static fn($a) => $a['ref'], LoadCenters::$centers ); $number = random_int(1, count($references)); diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index ca24d2442..09b8ba516 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -189,7 +189,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @ORM\JoinColumn(name="created_by", referencedColumnName="id") */ - private ?User $createdBy; + private ?User $createdBy = null; /** * @ORM\Column(name="email", type="string", length=255, nullable=true) @@ -272,13 +272,13 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(name="updated_at", type="datetime_immutable", nullable=true) */ - private ?DateTimeImmutable $updatedAt; + private ?DateTimeImmutable $updatedAt = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @ORM\JoinColumn(name="updated_by", referencedColumnName="id") */ - private ?User $updatedBy; + private ?User $updatedBy = null; /** * ThirdParty constructor. diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php index ed4b3c1e7..01309a37e 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php @@ -103,15 +103,11 @@ class PickThirdPartyType extends AbstractType $resolver ->setDefault('class', ThirdParty::class) - ->setDefault('choice_label', static function (ThirdParty $tp) { - return $tp->getName(); - }) - ->setDefault('choice_loader', function (Options $options) { - return new ThirdPartyChoiceLoader( - $options['center'], - $this->em->getRepository(ThirdParty::class) - ); - }); + ->setDefault('choice_label', static fn(ThirdParty $tp) => $tp->getName()) + ->setDefault('choice_loader', fn(Options $options) => new ThirdPartyChoiceLoader( + $options['center'], + $this->em->getRepository(ThirdParty::class) + )); } public function getParent(): string diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php index eb7966084..6bc83f0f2 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php @@ -77,9 +77,7 @@ class PickThirdPartyTypeCategoryType extends \Symfony\Component\Form\AbstractTyp return self::PREFIX_TYPE . $item; }, - 'choice_value' => function ($item) { - return $this->reverseTransform($item); - }, + 'choice_value' => fn($item) => $this->reverseTransform($item), ]); } From a9db133a7be4e581e3e049941ea8c92ce0f56014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:33:31 +0200 Subject: [PATCH 08/43] DX: fix typing in SearchProvider --- .../_static/code/exports/CountPerson.php | 4 +- .../Form/AdvancedSearchType.php | 44 ------------------- .../Search/HasAdvancedSearchFormInterface.php | 2 + .../ChillMainBundle/Search/SearchProvider.php | 10 ++--- .../ChillPersonBundle/Search/PersonSearch.php | 2 +- 5 files changed, 7 insertions(+), 55 deletions(-) delete mode 100644 src/Bundle/ChillMainBundle/Form/AdvancedSearchType.php diff --git a/docs/source/_static/code/exports/CountPerson.php b/docs/source/_static/code/exports/CountPerson.php index 48eab8a55..afe19c73b 100644 --- a/docs/source/_static/code/exports/CountPerson.php +++ b/docs/source/_static/code/exports/CountPerson.php @@ -90,9 +90,7 @@ class CountPerson implements ExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { // we gather all center the user choose. - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillMainBundle/Form/AdvancedSearchType.php b/src/Bundle/ChillMainBundle/Form/AdvancedSearchType.php deleted file mode 100644 index 9157e8023..000000000 --- a/src/Bundle/ChillMainBundle/Form/AdvancedSearchType.php +++ /dev/null @@ -1,44 +0,0 @@ -searchProvider = $searchProvider; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - $this->searchProvider - ->getHasAdvancedFormByName($options['search_service']) - ->createSearchForm($builder); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired('search_service') - ->setAllowedTypes('search_service', ['string']); - } -} diff --git a/src/Bundle/ChillMainBundle/Search/HasAdvancedSearchFormInterface.php b/src/Bundle/ChillMainBundle/Search/HasAdvancedSearchFormInterface.php index e5f103cdf..7aaf31bb3 100644 --- a/src/Bundle/ChillMainBundle/Search/HasAdvancedSearchFormInterface.php +++ b/src/Bundle/ChillMainBundle/Search/HasAdvancedSearchFormInterface.php @@ -20,4 +20,6 @@ interface HasAdvancedSearchFormInterface extends SearchInterface public function convertFormDataToQuery(array $data); public function convertTermsToFormData(array $terms); + + public function getAdvancedSearchTitle(): string; } diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index a629a45d2..a6b17133f 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -33,7 +33,7 @@ use function count; class SearchProvider { /** - * @var HasAdvancedSearchForm[] + * @var HasAdvancedSearchFormInterface[] */ private $hasAdvancedFormSearchServices = []; @@ -101,13 +101,9 @@ class SearchProvider * return searchservice with an advanced form, defined in service * definition. * - * @param string $name - * * @throws UnknowSearchNameException - * - * @return HasAdvancedSearchForm */ - public function getHasAdvancedFormByName($name) + public function getHasAdvancedFormByName(string $name): HasAdvancedSearchFormInterface { if (array_key_exists($name, $this->hasAdvancedFormSearchServices)) { return $this->hasAdvancedFormSearchServices[$name]; @@ -119,7 +115,7 @@ class SearchProvider public function getHasAdvancedFormSearchServices() { //sort the array - uasort($this->hasAdvancedFormSearchServices, static function (SearchInterface $a, SearchInterface $b) { + uasort($this->hasAdvancedFormSearchServices, static function (HasAdvancedSearchFormInterface $a, HasAdvancedSearchFormInterface $b): int { return $a->getOrder() <=> $b->getOrder(); }); diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php index 7cd1849a3..dabc79475 100644 --- a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php +++ b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php @@ -173,7 +173,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf return $data; } - public function getAdvancedSearchTitle() + public function getAdvancedSearchTitle(): string { return 'Search within persons'; } From 746ed4f5e5b2f4f3830c91718edb232e672a85d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:43:55 +0200 Subject: [PATCH 09/43] DX: fix cs --- .../DependencyInjection/Configuration.php | 2 +- .../LinkedToACP/AvgActivityDuration.php | 2 +- .../LinkedToACP/AvgActivityVisitDuration.php | 2 +- .../Export/LinkedToACP/CountActivity.php | 2 +- .../Export/LinkedToACP/ListActivity.php | 2 +- .../LinkedToACP/SumActivityDuration.php | 2 +- .../LinkedToACP/SumActivityVisitDuration.php | 2 +- .../Export/LinkedToPerson/ListActivity.php | 4 +-- .../Filter/ACPFilters/ActivityTypeFilter.php | 2 +- .../Filter/ACPFilters/UserScopeFilter.php | 2 +- .../Export/Filter/ActivityTypeFilter.php | 2 +- .../ChillActivityBundle/Form/ActivityType.php | 6 ++--- .../Form/ActivityTypeType.php | 2 +- .../Form/Type/PickActivityReasonType.php | 2 +- ...TranslatableActivityReasonCategoryType.php | 2 +- .../Form/Type/TranslatableActivityType.php | 2 +- .../Repository/ActivityACLAwareRepository.php | 2 +- .../Service/DocGenerator/ActivityContext.php | 2 +- ...tActivitiesByAccompanyingPeriodContext.php | 4 +-- .../Controller/ActivityControllerTest.php | 4 +-- .../Tests/Form/ActivityTypeTest.php | 2 +- .../Type/TranslatableActivityReasonTest.php | 2 +- .../src/DependencyInjection/Configuration.php | 2 +- .../src/Export/Export/CountAsideActivity.php | 2 +- .../ChillBudgetBundle/Form/ChargeType.php | 2 +- .../ChillBudgetBundle/Form/ResourceType.php | 2 +- .../Service/Summary/SummaryBudget.php | 6 ++--- .../Service/Summary/SummaryBudgetTest.php | 6 ++--- .../ChillCalendarBundle/Entity/Calendar.php | 4 +-- .../Export/Export/CountCalendars.php | 4 +-- .../Export/Export/StatCalendarAvgDuration.php | 2 +- .../Export/Export/StatCalendarSumDuration.php | 2 +- .../Export/Filter/AgentFilter.php | 2 +- .../Export/Filter/JobFilter.php | 2 +- .../Export/Filter/ScopeFilter.php | 2 +- .../Handler/CalendarToRemoteHandler.php | 4 +-- .../Messenger/Message/CalendarMessage.php | 2 +- .../MSGraph/RemoteEventConverter.php | 4 +-- .../MSGraphRemoteCalendarConnector.php | 8 +++--- .../Tests/Form/CalendarTypeTest.php | 14 +++++----- .../MSGraph/AddressConverterTest.php | 2 +- .../CalendarForShortMessageProviderTest.php | 8 +++--- .../CustomFields/CustomFieldLongChoice.php | 2 +- .../OptionRepository.php | 2 +- .../Form/CustomFieldType.php | 2 +- .../JsonCustomFieldToArrayTransformer.php | 2 +- .../Form/DocGeneratorTemplateType.php | 4 +-- .../Form/AccompanyingCourseDocumentType.php | 4 +-- .../Form/PersonDocumentType.php | 4 +-- ...ompanyingCourseDocumentWorkflowHandler.php | 2 +- .../Controller/ParticipationController.php | 6 ++--- src/Bundle/ChillEventBundle/Entity/Event.php | 2 +- .../Form/ChoiceLoader/EventChoiceLoader.php | 2 +- src/Bundle/ChillEventBundle/Form/RoleType.php | 2 +- .../Form/Type/PickEventType.php | 8 +++--- .../Form/Type/PickEventTypeType.php | 6 ++--- .../Form/Type/PickRoleType.php | 6 ++--- .../Form/Type/PickStatusType.php | 6 ++--- .../ParticipationControllerTest.php | 8 +++--- .../Timeline/TimelineEventProvider.php | 2 +- .../CRUD/Routing/CRUDRoutesLoader.php | 2 +- .../Controller/NotificationController.php | 2 +- .../Controller/PermissionsGroupController.php | 8 +++--- .../Controller/UserController.php | 5 ++-- .../Controller/WorkflowController.php | 2 +- .../CompilerPass/MenuCompilerPass.php | 2 +- .../ChillMainBundle/Doctrine/DQL/Greatest.php | 2 +- .../ChillMainBundle/Doctrine/DQL/Least.php | 2 +- .../Entity/PermissionsGroup.php | 2 +- .../Entity/Workflow/EntityWorkflowStep.php | 2 +- .../Export/Formatter/CSVListFormatter.php | 2 +- .../Formatter/CSVPivotedListFormatter.php | 2 +- .../Export/Helper/ExportAddressHelper.php | 2 +- .../ChoiceLoader/PostalCodeChoiceLoader.php | 2 +- .../DataMapper/ExportPickCenterDataMapper.php | 2 +- .../IdToEntityDataTransformer.php | 2 +- .../ChillMainBundle/Form/LocationFormType.php | 4 +-- .../Form/Type/ComposedGroupCenterType.php | 4 +-- .../Form/Type/ComposedRoleScopeType.php | 4 +-- .../EntityToJsonTransformer.php | 2 +- .../Form/Type/Export/PickCenterType.php | 4 +-- .../Form/Type/PickCenterType.php | 2 +- .../Form/Type/PickCivilityType.php | 4 +-- .../Form/Type/PickLocationTypeType.php | 2 +- .../Form/Type/PickUserLocationType.php | 2 +- .../Form/Type/PostalCodeType.php | 2 +- .../Form/Type/ScopePickerType.php | 4 +-- .../Form/Type/UserPickerType.php | 2 +- src/Bundle/ChillMainBundle/Form/UserType.php | 6 ++--- .../ChillMainBundle/Form/WorkflowStepType.php | 6 ++--- .../ChillMainBundle/Search/SearchProvider.php | 2 +- .../AddressReferenceBEFromBestAddress.php | 2 +- .../Import/PostalCodeBEFromBestAddress.php | 2 +- .../Service/Mailer/ChillMailer.php | 2 +- .../Tests/Entity/NotificationTest.php | 2 +- .../Tests/Form/Type/ScopePickerTypeTest.php | 2 +- .../Utils/ExtractDateFromPatternTest.php | 2 +- .../Authorization/AuthorizationHelperTest.php | 2 +- ...ntityWorkflowTransitionEventSubscriber.php | 2 +- .../NotificationOnTransition.php | 2 +- .../EntityWorkflowCreationValidator.php | 2 +- .../AccompanyingCourseApiController.php | 2 +- .../AccompanyingPeriodController.php | 6 ++--- ...mpanyingPeriodRegulationListController.php | 8 +++--- .../HouseholdCompositionController.php | 2 +- .../Controller/HouseholdController.php | 2 +- .../Controller/PersonApiController.php | 4 +-- .../SocialWorkSocialActionApiController.php | 2 +- .../DataFixtures/ORM/LoadCustomFields.php | 2 +- .../Entity/AccompanyingPeriod.php | 4 +-- .../Entity/Household/Household.php | 8 +++--- .../ChillPersonBundle/Entity/Person.php | 4 +-- .../GeographicalUnitStatAggregator.php | 2 +- .../CountryOfBirthAggregator.php | 2 +- .../GeographicalUnitAggregator.php | 2 +- .../NationalityAggregator.php | 2 +- .../Export/Export/CountAccompanyingCourse.php | 4 +-- .../Export/CountAccompanyingPeriodWork.php | 4 +-- .../Export/Export/CountEvaluation.php | 4 +-- .../Export/Export/CountHousehold.php | 2 +- .../Export/Export/CountPerson.php | 4 +-- .../CountPersonWithAccompanyingCourse.php | 4 +-- .../Export/Export/ListAccompanyingPeriod.php | 2 +- .../Export/ListAccompanyingPeriodWork.php | 2 +- .../Export/Export/ListEvaluation.php | 2 +- .../Export/Export/ListHouseholdInPeriod.php | 2 +- .../Export/Export/ListPerson.php | 2 +- .../ListPersonWithAccompanyingPeriod.php | 2 +- .../Export/StatAccompanyingCourseDuration.php | 2 +- .../ClosingMotiveFilter.php | 2 +- .../CreatorJobFilter.php | 2 +- .../EvaluationFilter.php | 2 +- .../GeographicalUnitStatFilter.php | 4 +-- .../OriginFilter.php | 2 +- .../EvaluationTypeFilter.php | 2 +- .../HouseholdFilters/CompositionFilter.php | 2 +- .../PersonFilters/AddressRefStatusFilter.php | 4 +-- .../Filter/PersonFilters/GenderFilter.php | 2 +- .../PersonFilters/GeographicalUnitFilter.php | 4 +-- .../PersonFilters/MaritalStatusFilter.php | 2 +- .../PersonFilters/NationalityFilter.php | 2 +- .../ResidentialAddressAtThirdpartyFilter.php | 2 +- .../Filter/SocialWorkFilters/JobFilter.php | 2 +- .../Filter/SocialWorkFilters/ScopeFilter.php | 2 +- .../Form/ChoiceLoader/PersonChoiceLoader.php | 2 +- .../Form/HouseholdCompositionType.php | 2 +- .../ChillPersonBundle/Form/PersonType.php | 6 ++--- .../Form/SocialWork/GoalType.php | 2 +- .../Form/SocialWork/SocialActionType.php | 10 +++---- .../Form/Type/ClosingMotivePickerType.php | 4 +-- .../Form/Type/PickPersonType.php | 8 +++--- .../Form/Type/PickSocialActionType.php | 2 +- .../Form/Type/PickSocialIssueType.php | 2 +- .../Privacy/PrivacyEventSubscriber.php | 4 +-- .../Repository/PersonACLAwareRepository.php | 2 +- .../Security/Authorization/HouseholdVoter.php | 2 +- .../AccompanyingPeriodDocGenNormalizer.php | 4 +-- ...mpanyingPeriodWorkEvaluationNormalizer.php | 2 +- .../Normalizer/PersonDocGenNormalizer.php | 4 +-- .../Normalizer/PersonJsonNormalizer.php | 2 +- .../Normalizer/SocialIssueNormalizer.php | 2 +- .../AccompanyingPeriodContext.php | 8 +++--- ...ccompanyingPeriodWorkEvaluationContext.php | 6 ++--- .../Service/DocGenerator/PersonContext.php | 4 +-- .../AccompanyingCourseApiControllerTest.php | 2 +- .../Controller/HouseholdApiControllerTest.php | 2 +- .../Controller/PersonControllerUpdateTest.php | 26 +++++++++---------- ...onControllerUpdateWithHiddenFieldsTest.php | 12 ++++----- .../Tests/Entity/AccompanyingPeriodTest.php | 2 +- .../Tests/Household/MembersEditorTest.php | 12 ++++----- .../Normalizer/PersonDocGenNormalizerTest.php | 2 +- .../RelationshipDocGenNormalizerTest.php | 4 +-- .../DocGenerator/PersonContextTest.php | 2 +- .../PersonContextWithThirdPartyTest.php | 2 +- .../AccompanyingPeriodValidityValidator.php | 2 +- .../Export/Export/ReportList.php | 4 +-- .../ChillReportBundle/Search/ReportSearch.php | 2 +- .../Controller/ReportControllerNextTest.php | 2 +- .../Tests/Controller/ReportControllerTest.php | 2 +- .../Tests/Timeline/TimelineProviderTest.php | 2 +- .../Controller/TaskController.php | 2 +- .../Form/SingleTaskListType.php | 4 +-- .../Controller/SingleTaskControllerTest.php | 2 +- ...TaskTaskLifeCycleEventTimelineProvider.php | 2 +- .../TaskLifeCycleEventTimelineProvider.php | 2 +- .../DataFixtures/ORM/LoadThirdParty.php | 2 +- .../Form/Type/PickThirdPartyType.php | 4 +-- .../Type/PickThirdPartyTypeCategoryType.php | 2 +- 188 files changed, 309 insertions(+), 308 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php index 35388464b..57a1ec578 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php @@ -59,7 +59,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(static fn($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') + ->ifTrue(static fn ($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') ->end() ->end() ->scalarNode('label') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 0de7f420c..34771d077 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -86,7 +86,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index d9382d857..df21362cd 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -87,7 +87,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index fe6de3e24..6b7b1562d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -86,7 +86,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 616f4d848..026e16f90 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -109,7 +109,7 @@ class ListActivity implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index d4aa65f22..e916cab54 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -87,7 +87,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index 859c3e6b5..18a47289c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -87,7 +87,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index d9b1eb212..60110c9a8 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -137,7 +137,7 @@ class ListActivity implements ListInterface, GroupedExportInterface $activity = $activityRepository->find($value); - return implode(', ', array_map(fn(ActivityReason $r) => '"' . + return implode(', ', array_map(fn (ActivityReason $r) => '"' . $this->translatableStringHelper->localize($r->getCategory()->getName()) . ' > ' . $this->translatableStringHelper->localize($r->getName()) @@ -195,7 +195,7 @@ class ListActivity implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index 346eab316..c6616a4c6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -61,7 +61,7 @@ class ActivityTypeFilter implements FilterInterface $builder->add('accepted_activitytypes', EntityType::class, [ 'class' => ActivityType::class, 'choices' => $this->activityTypeRepository->findAllActive(), - 'choice_label' => fn(ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + 'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') . $this->translatableStringHelper->localize($aty->getName()), 'multiple' => true, diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index 4254137ba..4319c100a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -64,7 +64,7 @@ class UserScopeFilter implements FilterInterface { $builder->add('accepted_userscope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize( $s->getName() ), 'multiple' => true, diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index 725223fdd..b9d39c3ce 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -61,7 +61,7 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter $builder->add('types', EntityType::class, [ 'choices' => $this->activityTypeRepository->findAllActive(), 'class' => ActivityType::class, - 'choice_label' => fn(ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + 'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') . $this->translatableStringHelper->localize($aty->getName()), 'group_by' => function (ActivityType $type) { diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index dad4c3137..a74178afd 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -211,8 +211,8 @@ class ActivityType extends AbstractType 'required' => $activityType->isRequired('attendee'), 'expanded' => true, 'class' => ActivityPresence::class, - 'choice_label' => fn(ActivityPresence $activityPresence) => $this->translatableStringHelper->localize($activityPresence->getName()), - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('a') + 'choice_label' => fn (ActivityPresence $activityPresence) => $this->translatableStringHelper->localize($activityPresence->getName()), + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('a') ->where('a.active = true'), ]); } @@ -353,7 +353,7 @@ class ActivityType extends AbstractType return (string) $location->getId(); }, - fn(?string $id): ?Location => $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id]) + fn (?string $id): ?Location => $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id]) )); } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index 42353cda7..073b8099f 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -45,7 +45,7 @@ class ActivityTypeType extends AbstractType ]) ->add('category', EntityType::class, [ 'class' => ActivityTypeCategory::class, - 'choice_label' => fn(ActivityTypeCategory $activityTypeCategory) => $this->translatableStringHelper->localize($activityTypeCategory->getName()), + 'choice_label' => fn (ActivityTypeCategory $activityTypeCategory) => $this->translatableStringHelper->localize($activityTypeCategory->getName()), ]) ->add('ordering', NumberType::class, [ 'required' => true, diff --git a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php index 0b63de112..35da7e02f 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php @@ -45,7 +45,7 @@ class PickActivityReasonType extends AbstractType $resolver->setDefaults( [ 'class' => ActivityReason::class, - 'choice_label' => fn(ActivityReason $choice) => $this->reasonRender->renderString($choice, []), + 'choice_label' => fn (ActivityReason $choice) => $this->reasonRender->renderString($choice, []), 'group_by' => function (ActivityReason $choice): ?string { if (null !== $category = $choice->getCategory()) { return $this->translatableStringHelper->localize($category->getName()); diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php index 83dcb43f0..4aa259097 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php @@ -38,7 +38,7 @@ class TranslatableActivityReasonCategoryType extends AbstractType $resolver->setDefaults( [ 'class' => ActivityReasonCategory::class, - 'choice_label' => fn(ActivityReasonCategory $category) => $this->translatableStringHelper->localize($category->getName()) + 'choice_label' => fn (ActivityReasonCategory $category) => $this->translatableStringHelper->localize($category->getName()) . (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : ''), ] ); diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php index 065f80c9b..d4807b82d 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php @@ -39,7 +39,7 @@ class TranslatableActivityType extends AbstractType 'class' => ActivityType::class, 'active_only' => true, 'choices' => $this->activityTypeRepository->findAllActive(), - 'choice_label' => fn(ActivityType $type) => $this->translatableStringHelper->localize($type->getName()), + 'choice_label' => fn (ActivityType $type) => $this->translatableStringHelper->localize($type->getName()), ] ); } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php index 3e5ff813b..1f2039a2c 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php @@ -254,7 +254,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte $reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), ActivityVoter::SEE, $center); // we get the ids for those scopes $reachablesScopesId = array_map( - static fn(Scope $scope) => $scope->getId(), + static fn (Scope $scope) => $scope->getId(), $reachableScopes ); diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php index 241526b03..624859eda 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php @@ -134,7 +134,7 @@ class ActivityContext implements $builder->add($key, EntityType::class, [ 'class' => Person::class, 'choices' => $persons, - 'choice_label' => fn(Person $p) => $this->personRender->renderString($p, []), + 'choice_label' => fn (Person $p) => $this->personRender->renderString($p, []), 'multiple' => false, 'required' => false, 'expanded' => true, diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php index 9f9e03669..557bbcb84 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php @@ -146,7 +146,7 @@ class ListActivitiesByAccompanyingPeriodContext implements return array_filter( $activities, function ($activity) use ($user) { - $activityUsernames = array_map(static fn($user) => $user['username'], $activity['users'] ?? []); + $activityUsernames = array_map(static fn ($user) => $user['username'], $activity['users'] ?? []); return in_array($user->getUsername(), $activityUsernames, true); } ); @@ -157,7 +157,7 @@ class ListActivitiesByAccompanyingPeriodContext implements return array_filter( $works, function ($work) use ($user) { - $workUsernames = array_map(static fn($user) => $user['username'], $work['referrers'] ?? []); + $workUsernames = array_map(static fn ($user) => $user['username'], $work['referrers'] ?? []); return in_array($user->getUsername(), $workUsernames, true); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php index d01821e6e..04301afae 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php @@ -369,8 +369,8 @@ final class ActivityControllerTest extends WebTestCase $center ); $reachableScopesId = array_intersect( - array_map(static fn($s) => $s->getId(), $reachableScopesDelete), - array_map(static fn($s) => $s->getId(), $reachableScopesUpdate) + array_map(static fn ($s) => $s->getId(), $reachableScopesDelete), + array_map(static fn ($s) => $s->getId(), $reachableScopesUpdate) ); if (count($reachableScopesId) === 0) { diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php index cd73b259a..3ed6b4409 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php @@ -188,7 +188,7 @@ final class ActivityTypeTest extends KernelTestCase // map all the values in an array $values = array_map( - static fn($choice) => $choice->value, + static fn ($choice) => $choice->value, $view['activity']['durationTime']->vars['choices'] ); diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php index aefa0d115..a8d85daa6 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php @@ -83,7 +83,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase $request->getLocale()->willReturn($fallbackLocale); $requestStack->willExtend(\Symfony\Component\HttpFoundation\RequestStack::class); - $requestStack->getCurrentRequest()->will(static fn() => $request); + $requestStack->getCurrentRequest()->will(static fn () => $request); $translator->willExtend(\Symfony\Component\Translation\Translator::class); $translator->getFallbackLocales()->willReturn($locale); diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php index 85d76227d..2e2398c3e 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php @@ -132,7 +132,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(static fn($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') + ->ifTrue(static fn ($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') ->end() ->end() ->scalarNode('label') diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php index 8eb8d1b64..9204fad4b 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php @@ -59,7 +59,7 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php index de8317ab3..72863163f 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php @@ -52,7 +52,7 @@ class ChargeType extends AbstractType 'label' => 'Charge type', 'required' => true, 'placeholder' => $this->translator->trans('admin.form.Choose the type of charge'), - 'choice_label' => fn(ChargeKind $resource) => $this->translatableStringHelper->localize($resource->getName()), + 'choice_label' => fn (ChargeKind $resource) => $this->translatableStringHelper->localize($resource->getName()), 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) diff --git a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php index 3b14e9a05..09dfd16f3 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php @@ -51,7 +51,7 @@ class ResourceType extends AbstractType 'label' => 'Resource type', 'required' => true, 'placeholder' => $this->translator->trans('admin.form.Choose the type of resource'), - 'choice_label' => fn(ResourceKind $resource) => $this->translatableStringHelper->localize($resource->getName()), + 'choice_label' => fn (ResourceKind $resource) => $this->translatableStringHelper->localize($resource->getName()), 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) diff --git a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php index 3e0ee2cec..1c66d4c1c 100644 --- a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php +++ b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php @@ -66,7 +66,7 @@ final class SummaryBudget implements SummaryBudgetInterface ]; } - $personIds = $household->getCurrentPersons()->map(static fn(Person $p) => $p->getId()); + $personIds = $household->getCurrentPersons()->map(static fn (Person $p) => $p->getId()); $ids = implode(', ', array_fill(0, count($personIds), '?')); $parameters = [...$personIds, $household->getId()]; @@ -125,14 +125,14 @@ final class SummaryBudget implements SummaryBudgetInterface { $keys = array_map(static fn (ChargeKind $kind) => $kind->getKind(), $this->chargeKindRepository->findAll()); - return array_combine($keys, array_map(fn($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); + return array_combine($keys, array_map(fn ($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); } private function getEmptyResourceArray(): array { $keys = array_map(static fn (ResourceKind $kind) => $kind->getKind(), $this->resourceKindRepository->findAll()); - return array_combine($keys, array_map(fn($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); + return array_combine($keys, array_map(fn ($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); } private function rowToArray(array $rows, string $kind): array diff --git a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php index 194c23672..77017abc5 100644 --- a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php +++ b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php @@ -50,7 +50,7 @@ final class SummaryBudgetTest extends TestCase ], ]); $queryCharges->setParameters(Argument::type('array')) - ->will(static fn($args, $query) => $query); + ->will(static fn ($args, $query) => $query); $queryResources = $this->prophesize(AbstractQuery::class); $queryResources->getResult()->willReturn([ @@ -61,7 +61,7 @@ final class SummaryBudgetTest extends TestCase ], ]); $queryResources->setParameters(Argument::type('array')) - ->will(static fn($args, $query) => $query); + ->will(static fn ($args, $query) => $query); $em = $this->prophesize(EntityManagerInterface::class); $em->createNativeQuery(Argument::type('string'), Argument::type(Query\ResultSetMapping::class)) @@ -96,7 +96,7 @@ final class SummaryBudgetTest extends TestCase $resourceRepository->findOneByKind('misc')->willReturn($misc); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); - $translatableStringHelper->localize(Argument::type('array'))->will(static fn($arg) => $arg[0]['fr']); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn ($arg) => $arg[0]['fr']); $person = new Person(); $personReflection = new ReflectionClass($person); diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 418bfcea2..79219a6e0 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -514,7 +514,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente */ public function getUsers(): ReadableCollection { - return $this->getInvites()->map(static fn(Invite $i) => $i->getUser()); + return $this->getInvites()->map(static fn (Invite $i) => $i->getUser()); } public function hasCalendarRange(): bool @@ -599,7 +599,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente } $invite = $this->invites - ->filter(static fn(Invite $invite) => $invite->getUser() === $user) + ->filter(static fn (Invite $invite) => $invite->getUser() === $user) ->first(); $this->removeInvite($invite); diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index c21b4a4d6..9d3f00f99 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -61,7 +61,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -89,7 +89,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->calendarRepository->createQueryBuilder('cal'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 78be10834..14dd42d6b 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -61,7 +61,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 5dd9dca44..1d31bfa26 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -61,7 +61,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index 058251004..b58cee594 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -58,7 +58,7 @@ class AgentFilter implements FilterInterface { $builder->add('accepted_agents', EntityType::class, [ 'class' => User::class, - 'choice_label' => fn(User $u) => $this->userRender->renderString($u, []), + 'choice_label' => fn (User $u) => $this->userRender->renderString($u, []), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 04f6ba02b..69fb24447 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -69,7 +69,7 @@ class JobFilter implements FilterInterface { $builder->add('job', EntityType::class, [ 'class' => UserJob::class, - 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + 'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize( $j->getLabel() ), 'multiple' => true, diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index ce6c90de2..08d9ae023 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -69,7 +69,7 @@ class ScopeFilter implements FilterInterface { $builder->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize( $s->getName() ), 'multiple' => true, diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php index 1ec257cad..eabdf9063 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php @@ -89,10 +89,10 @@ class CalendarToRemoteHandler implements MessageHandlerInterface $newInvites = array_filter( array_map( - fn($id) => $this->inviteRepository->find($id), + fn ($id) => $this->inviteRepository->find($id), $calendarMessage->getNewInvitesIds(), ), - static fn(?Invite $invite) => null !== $invite + static fn (?Invite $invite) => null !== $invite ); $this->calendarConnector->syncCalendar( diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php index 6232ca06c..c8a8f8aeb 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php @@ -58,7 +58,7 @@ class CalendarMessage $this->previousMainUserId = null !== $calendar->previousMainUser ? $calendar->previousMainUser->getId() : null; $this->newInvitesIds = array_map(static fn (Invite $i) => $i->getId(), $calendar->newInvites); - $this->oldInvites = array_map(static fn(Invite $i) => [ + $this->oldInvites = array_map(static fn (Invite $i) => [ 'inviteId' => $i->getId(), 'userId' => $i->getUser()->getId(), 'userEmail' => $i->getUser()->getEmail(), diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php index b7a1c2df6..176dbe0b0 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php @@ -121,7 +121,7 @@ class RemoteEventConverter 'subject' => '[Chill] ' . implode( ', ', - $calendar->getPersons()->map(fn(Person $p) => $this->personRender->renderString($p, []))->toArray() + $calendar->getPersons()->map(fn (Person $p) => $this->personRender->renderString($p, []))->toArray() ), 'start' => [ 'dateTime' => $calendar->getStartDate()->setTimezone($this->remoteDateTimeZone) @@ -159,7 +159,7 @@ class RemoteEventConverter { return [ 'attendees' => $calendar->getInvites()->map( - fn(Invite $i) => $this->buildInviteToAttendee($i) + fn (Invite $i) => $this->buildInviteToAttendee($i) )->toArray(), ]; } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php index 75995948e..e3690042c 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php @@ -190,17 +190,17 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface ] )->toArray(); - $ids = array_map(static fn($item) => $item['id'], $bareEvents['value']); + $ids = array_map(static fn ($item) => $item['id'], $bareEvents['value']); $existingIdsInRange = $this->calendarRangeRepository->findRemoteIdsPresent($ids); $existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids); return array_values( array_map( - fn($item) => $this->remoteEventConverter->convertToRemote($item), + fn ($item) => $this->remoteEventConverter->convertToRemote($item), // filter all event to keep only the one not in range array_filter( $bareEvents['value'], - static fn($item) => ((!$existingIdsInRange[$item['id']]) ?? true) && ((!$existingIdsInCalendar[$item['id']]) ?? true) + static fn ($item) => ((!$existingIdsInRange[$item['id']]) ?? true) && ((!$existingIdsInCalendar[$item['id']]) ?? true) ) ) ); @@ -595,7 +595,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface } $this->cacheScheduleTimeForUser[$userId] = array_map( - fn($item) => $this->remoteEventConverter->convertAvailabilityToRemoteEvent($item), + fn ($item) => $this->remoteEventConverter->convertAvailabilityToRemoteEvent($item), $response['value'][0]['scheduleItems'] ); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php index f7a3509f4..9195d5eac 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php @@ -114,8 +114,8 @@ final class CalendarTypeTest extends TypeTestCase $this->assertEquals(8, $calendar->getCalendarRange()->getId()); $this->assertEquals(9, $calendar->getLocation()->getId()); $this->assertEquals(true, $calendar->getSendSMS()); - $this->assertContains(2, $calendar->getUsers()->map(static fn(User $u) => $u->getId())); - $this->assertContains(3, $calendar->getUsers()->map(static fn(User $u) => $u->getId())); + $this->assertContains(2, $calendar->getUsers()->map(static fn (User $u) => $u->getId())); + $this->assertContains(3, $calendar->getUsers()->map(static fn (User $u) => $u->getId())); } protected function getExtensions() @@ -144,16 +144,16 @@ final class CalendarTypeTest extends TypeTestCase ) { $transformer = $this->prophesize($classTransformer); $transformer->transform(Argument::type('array')) - ->will(static fn($args) => implode( + ->will(static fn ($args) => implode( ',', - array_map(static fn($p) => $p->getId(), $args[0]) + array_map(static fn ($p) => $p->getId(), $args[0]) )); $transformer->transform(Argument::exact(null)) ->willReturn([]); $transformer->transform(Argument::type(Collection::class)) - ->will(static fn($args) => implode( + ->will(static fn ($args) => implode( ',', - array_map(static fn($p) => $p->getId(), $args[0]->toArray()) + array_map(static fn ($p) => $p->getId(), $args[0]->toArray()) )); $transformer->reverseTransform(Argument::type('string')) ->will(static function ($args) use ($objClass) { @@ -183,7 +183,7 @@ final class CalendarTypeTest extends TypeTestCase ) { $transformer = $this->prophesize($classTransformer); $transformer->transform(Argument::type('object')) - ->will(static fn($args) => (string) $args[0]->getId()); + ->will(static fn ($args) => (string) $args[0]->getId()); $transformer->transform(Argument::exact(null)) ->willReturn(''); $transformer->reverseTransform(Argument::type('string')) diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php index 35c067eb7..827e22381 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php @@ -63,7 +63,7 @@ final class AddressConverterTest extends TestCase { $engine = $this->prophesize(EngineInterface::class); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); - $translatableStringHelper->localize(Argument::type('array'))->will(static fn($args): string => ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided'); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn ($args): string => ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided'); $addressRender = new AddressRender($engine->reveal(), $translatableStringHelper->reveal()); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php index 9ee2ac82b..34867d8bd 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php @@ -72,13 +72,13 @@ final class CalendarForShortMessageProviderTest extends TestCase Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::exact(0) - )->will(static fn($args) => array_fill(0, $args[2], new Calendar()))->shouldBeCalledTimes(1); + )->will(static fn ($args) => array_fill(0, $args[2], new Calendar()))->shouldBeCalledTimes(1); $calendarRepository->findByNotificationAvailable( Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::not(0) - )->will(static fn($args) => array_fill(0, $args[2] - 1, new Calendar()))->shouldBeCalledTimes(1); + )->will(static fn ($args) => array_fill(0, $args[2] - 1, new Calendar()))->shouldBeCalledTimes(1); $em = $this->prophesize(EntityManagerInterface::class); $em->clear()->shouldBeCalled(); @@ -104,13 +104,13 @@ final class CalendarForShortMessageProviderTest extends TestCase Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::exact(0) - )->will(static fn($args) => array_fill(0, 1, new Calendar()))->shouldBeCalledTimes(1); + )->will(static fn ($args) => array_fill(0, 1, new Calendar()))->shouldBeCalledTimes(1); $calendarRepository->findByNotificationAvailable( Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::not(0) - )->will(static fn($args) => [])->shouldBeCalledTimes(1); + )->will(static fn ($args) => [])->shouldBeCalledTimes(1); $em = $this->prophesize(EntityManagerInterface::class); $em->clear()->shouldBeCalled(); diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php index c60d947dd..75dc7792f 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php @@ -58,7 +58,7 @@ class CustomFieldLongChoice extends AbstractCustomField $translatableStringHelper = $this->translatableStringHelper; $builder->add($customField->getSlug(), Select2ChoiceType::class, [ 'choices' => $entries, - 'choice_label' => static fn(Option $option) => $translatableStringHelper->localize($option->getText()), + 'choice_label' => static fn (Option $option) => $translatableStringHelper->localize($option->getText()), 'choice_value' => static fn (Option $key): ?int => null === $key ? null : $key->getId(), 'multiple' => false, 'expanded' => false, diff --git a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php index e1ed1d363..4ef6e046d 100644 --- a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php +++ b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php @@ -57,6 +57,6 @@ class OptionRepository extends EntityRepository ->getQuery() ->getScalarResult(); - return array_map(static fn($r) => $r['key'], $keys); + return array_map(static fn ($r) => $r['key'], $keys); } } diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php index f9a9f2509..0630bccf5 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php @@ -70,7 +70,7 @@ class CustomFieldType extends AbstractType if ('entity' === $options['group_widget']) { $builder->add('customFieldsGroup', EntityType::class, [ 'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup', - 'choice_label' => fn($g) => $this->translatableStringHelper->localize($g->getName()), + 'choice_label' => fn ($g) => $this->translatableStringHelper->localize($g->getName()), ]); } elseif ('hidden' === $options['group_widget']) { $builder->add('customFieldsGroup', HiddenType::class); diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php index ab67ca581..2b34b498a 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php @@ -38,7 +38,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface // @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here? $customFieldsLablels = array_map( - static fn($e) => $e->getLabel(), + static fn ($e) => $e->getLabel(), $customFields ); diff --git a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php index 0b1fbec9d..5b4a8be30 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php +++ b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php @@ -61,8 +61,8 @@ class DocGeneratorTemplateType extends AbstractType $sub = $builder ->create('options', null, ['compound' => true]) ->addModelTransformer(new CallbackTransformer( - static fn(array $data) => $context->adminFormTransform($data), - static fn(array $data) => $context->adminFormReverseTransform($data) + static fn (array $data) => $context->adminFormTransform($data), + static fn (array $data) => $context->adminFormReverseTransform($data) )); $context->buildAdminForm($sub); $builder->add($sub); diff --git a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php index 255ca5dc5..5ed5b5981 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php @@ -72,10 +72,10 @@ class AccompanyingCourseDocumentType extends AbstractType ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('c') ->where('c.documentClass = :docClass') ->setParameter('docClass', AccompanyingCourseDocument::class), - 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', + 'choice_label' => fn ($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); } diff --git a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php index c7cf31534..11f73e862 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php @@ -67,10 +67,10 @@ class PersonDocumentType extends AbstractType ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('c') ->where('c.documentClass = :docClass') ->setParameter('docClass', PersonDocument::class), - 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', + 'choice_label' => fn ($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) { diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index b819ae8c3..c3285507e 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -51,7 +51,7 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler $persons = []; if (null !== $course) { - $persons = $course->getCurrentParticipations()->map(static fn(AccompanyingPeriodParticipation $participation) => $participation->getPerson())->toArray(); + $persons = $course->getCurrentParticipations()->map(static fn (AccompanyingPeriodParticipation $participation) => $participation->getPerson())->toArray(); } return [ diff --git a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php index 51ba3634d..1929beac1 100644 --- a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php +++ b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php @@ -113,7 +113,7 @@ class ParticipationController extends AbstractController [ 'event_id' => current($participations)->getEvent()->getId(), 'persons_ids' => implode(',', array_map( - static fn(Participation $p) => $p->getPerson()->getId(), + static fn (Participation $p) => $p->getPerson()->getId(), $participations )), ] @@ -648,13 +648,13 @@ class ParticipationController extends AbstractController // create a collection of person's id participating to the event /** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */ $peopleParticipating ??= $participation->getEvent()->getParticipations()->map( - static fn(Participation $p) => $p->getPerson()->getId() + static fn (Participation $p) => $p->getPerson()->getId() ); // check that the user is not already in the event if ($peopleParticipating->contains($participation->getPerson()->getId())) { $ignoredParticipations[] = $participation ->getEvent()->getParticipations()->filter( - static fn(Participation $p) => $p->getPerson()->getId() === $participation->getPerson()->getId() + static fn (Participation $p) => $p->getPerson()->getId() === $participation->getPerson()->getId() )->first(); } else { $newParticipations[] = $participation; diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index 669cb02db..d55a7b8a8 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -176,7 +176,7 @@ class Event implements HasCenterInterface, HasScopeInterface { $iterator = $this->participations->getIterator(); - $iterator->uasort(static fn($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName())); + $iterator->uasort(static fn ($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName())); return $iterator; } diff --git a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php index de1c42cf8..962799dbc 100644 --- a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php +++ b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php @@ -62,7 +62,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedEvents, - static fn(Event $p) => call_user_func($value, $p) + static fn (Event $p) => call_user_func($value, $p) ); } diff --git a/src/Bundle/ChillEventBundle/Form/RoleType.php b/src/Bundle/ChillEventBundle/Form/RoleType.php index 2a0b6765a..519e814cf 100644 --- a/src/Bundle/ChillEventBundle/Form/RoleType.php +++ b/src/Bundle/ChillEventBundle/Form/RoleType.php @@ -38,7 +38,7 @@ class RoleType extends AbstractType ->add('active') ->add('type', EntityType::class, [ 'class' => EventType::class, - 'choice_label' => fn(EventType $e) => $this->translatableStringHelper->localize($e->getName()), + 'choice_label' => fn (EventType $e) => $this->translatableStringHelper->localize($e->getName()), ]); } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php index 1ec088ba6..05436b3e8 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php @@ -109,12 +109,12 @@ class PickEventType extends AbstractType // add the default options $resolver->setDefaults([ 'class' => Event::class, - 'choice_label' => static fn(Event $e) => $e->getDate()->format('d/m/Y, H:i') . ' → ' . + 'choice_label' => static fn (Event $e) => $e->getDate()->format('d/m/Y, H:i') . ' → ' . // $e->getType()->getName()['fr'] . ': ' . // display the type of event $e->getName(), 'placeholder' => 'Pick an event', 'attr' => ['class' => 'select2 '], - 'choice_attr' => static fn(Event $e) => ['data-center' => $e->getCenter()->getId()], + 'choice_attr' => static fn (Event $e) => ['data-center' => $e->getCenter()->getId()], 'choiceloader' => function (Options $options) { $centers = $this->filterCenters($options); @@ -139,7 +139,7 @@ class PickEventType extends AbstractType // option role if (null === $options['role']) { $centers = array_map( - static fn(GroupCenter $g) => $g->getCenter(), + static fn (GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray() ); } else { @@ -167,7 +167,7 @@ class PickEventType extends AbstractType if ( !in_array($c->getId(), array_map( - static fn(Center $c) => $c->getId(), + static fn (Center $c) => $c->getId(), $centers ), true) ) { diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php index 2ecdb27d7..d027c05cf 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php @@ -39,10 +39,10 @@ class PickEventTypeType extends AbstractType $resolver->setDefaults( [ 'class' => EventType::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('et') + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('et') ->where('et.active = true'), - 'choice_label' => static fn(EventType $t) => $helper->localize($t->getName()), - 'choice_attrs' => static fn(EventType $t) => ['data-link-category' => $t->getId()], + 'choice_label' => static fn (EventType $t) => $helper->localize($t->getName()), + 'choice_attrs' => static fn (EventType $t) => ['data-link-category' => $t->getId()], ] ); } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php b/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php index ca6425dc8..8fd8ff7d7 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php @@ -80,7 +80,7 @@ class PickRoleType extends AbstractType $options = $config->getOptions(); $form->getParent()->add($name, $type, array_replace($options, [ - 'group_by' => fn(Role $r) => $this->translatableStringHelper->localize($r->getType()->getName()), + 'group_by' => fn (Role $r) => $this->translatableStringHelper->localize($r->getType()->getName()), ])); } } @@ -109,11 +109,11 @@ class PickRoleType extends AbstractType 'class' => Role::class, 'query_builder' => $qb, 'group_by' => null, - 'choice_attr' => static fn(Role $r) => [ + 'choice_attr' => static fn (Role $r) => [ 'data-event-type' => $r->getType()->getId(), 'data-link-category' => $r->getType()->getId(), ], - 'choice_label' => static fn(Role $r) => $translatableStringHelper->localize($r->getName()) . + 'choice_label' => static fn (Role $r) => $translatableStringHelper->localize($r->getName()) . ($r->getActive() === true ? '' : ' (' . $translator->trans('unactive') . ')'), ]); diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php b/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php index b1078ab61..dcc3ba205 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php @@ -82,7 +82,7 @@ class PickStatusType extends AbstractType $type = $config->getType()->getName(); $options = $config->getOptions(); $form->getParent()->add($name, $type, array_replace($options, [ - 'group_by' => fn(Status $s) => $this->translatableStringHelper->localize($s->getType()->getName()), + 'group_by' => fn (Status $s) => $this->translatableStringHelper->localize($s->getType()->getName()), ])); } ); @@ -110,11 +110,11 @@ class PickStatusType extends AbstractType 'class' => Status::class, 'query_builder' => $qb, 'group_by' => null, - 'choice_attr' => static fn(Status $s) => [ + 'choice_attr' => static fn (Status $s) => [ 'data-event-type' => $s->getType()->getId(), 'data-link-category' => $s->getType()->getId(), ], - 'choice_label' => static fn(Status $s) => $translatableStringHelper->localize($s->getName()) . + 'choice_label' => static fn (Status $s) => $translatableStringHelper->localize($s->getName()) . ($s->getActive() === true ? '' : ' (' . $translator->trans('unactive') . ')'), ]); diff --git a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php index 7c79e52e3..d61c1f385 100644 --- a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php @@ -239,7 +239,7 @@ final class ParticipationControllerTest extends WebTestCase $this->personsIdsCache = array_merge( $this->personsIdsCache, $event->getParticipations()->map( - static fn($p) => $p->getPerson()->getId() + static fn ($p) => $p->getPerson()->getId() ) ->toArray() ); @@ -303,7 +303,7 @@ final class ParticipationControllerTest extends WebTestCase $event = $this->getRandomEventWithMultipleParticipations(); $persons_id = implode(',', $event->getParticipations()->map( - static fn($p) => $p->getPerson()->getId() + static fn ($p) => $p->getPerson()->getId() )->toArray()); $crawler = $this->client->request( @@ -329,7 +329,7 @@ final class ParticipationControllerTest extends WebTestCase $nbParticipations = $event->getParticipations()->count(); // get the persons_id participating on this event $persons_id = $event->getParticipations()->map( - static fn($p) => $p->getPerson()->getId() + static fn ($p) => $p->getPerson()->getId() )->toArray(); // exclude the existing persons_ids from the new person $this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id); @@ -458,7 +458,7 @@ final class ParticipationControllerTest extends WebTestCase $circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(); - array_filter($circles, static fn($circle) => in_array($circleName, $circle->getName(), true)); + array_filter($circles, static fn ($circle) => in_array($circleName, $circle->getName(), true)); $circle = $circles[0]; $events = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class) diff --git a/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php b/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php index a7bf08741..9fac6c88e 100644 --- a/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php +++ b/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php @@ -208,7 +208,7 @@ class TimelineEventProvider implements TimelineProviderInterface foreach ($reachableCenters as $center) { $reachableCircleId = array_map( - static fn(Scope $scope) => $scope->getId(), + static fn (Scope $scope) => $scope->getId(), $this->helper->getReachableCircles($this->user, $role, $person->getCenter()) ); $centerAndScopeLines[] = sprintf( diff --git a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php index 01f80d1b8..4fbf5961d 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php +++ b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php @@ -141,7 +141,7 @@ class CRUDRoutesLoader extends Loader $methods = array_keys(array_filter( $action['methods'], - static fn($value, $key) => $value, + static fn ($value, $key) => $value, ARRAY_FILTER_USE_BOTH )); diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index 29ec6e7f0..327a06df6 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -282,7 +282,7 @@ class NotificationController extends AbstractController if ($request->query->has('edit')) { $commentId = $request->query->getInt('edit'); - $editedComment = $notification->getComments()->filter(static fn(NotificationComment $c) => $c->getId() === $commentId)->first(); + $editedComment = $notification->getComments()->filter(static fn (NotificationComment $c) => $c->getId() === $commentId)->first(); if (false === $editedComment) { throw $this->createNotFoundException("Comment with id {$commentId} does not exists nor belong to this notification"); diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index 3292b3540..5d32a8dbb 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -158,7 +158,7 @@ class PermissionsGroupController extends AbstractController 'edit_form' => $editForm->createView(), 'role_scopes_sorted' => $roleScopesSorted, 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn ($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -303,7 +303,7 @@ class PermissionsGroupController extends AbstractController 'role_scopes_sorted' => $roleScopesSorted, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn ($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -445,7 +445,7 @@ class PermissionsGroupController extends AbstractController 'role_scopes_sorted' => $roleScopesSorted, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn ($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -567,7 +567,7 @@ class PermissionsGroupController extends AbstractController if (!array_key_exists($roleScope->getRole(), $expandedRoles)) { $expandedRoles[$roleScope->getRole()] = array_map( - static fn(Role $role) => $role->getRole(), + static fn (Role $role) => $role->getRole(), $this->roleHierarchy ->getReachableRoles( [new Role($roleScope->getRole())] diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 64cef168d..ecf8a3c9c 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -337,12 +337,13 @@ class UserController extends CRUDController [ 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(), 'delete_groupcenter_form' => array_map( - static fn(Form $form) => $form->createView(), + static fn (Form $form) => $form->createView(), iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true) ), ] ); - } elseif ('index' === $action) { + } + if ('index' === $action) { return array_merge( ['allow_change_password' => $this->parameterBag->get('chill_main.access_user_change_password')], $defaultTemplateParameters diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index af4974bbe..36647612b 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -345,7 +345,7 @@ class WorkflowController extends AbstractController if ($transitionForm->isSubmitted() && $transitionForm->isValid()) { if (!$workflow->can($entityWorkflow, $transition = $transitionForm['transition']->getData()->getName())) { $blockers = $workflow->buildTransitionBlockerList($entityWorkflow, $transition); - $msgs = array_map(fn(TransitionBlocker $tb) => $this->translator->trans( + $msgs = array_map(fn (TransitionBlocker $tb) => $this->translator->trans( $tb->getMessage(), $tb->getParameters() ), iterator_to_array($blockers)); diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php index da2cbff1f..d6a27c943 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php @@ -37,7 +37,7 @@ class MenuCompilerPass implements CompilerPassInterface ]; } - usort($services, static fn($a, $b) => $a['priority'] <=> $b['priority']); + usort($services, static fn ($a, $b) => $a['priority'] <=> $b['priority']); foreach ($services as $service) { $class = $container->getDefinition($service['id'])->getClass(); diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php index a56bcb50c..c76bd22cf 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php @@ -33,7 +33,7 @@ class Greatest extends FunctionNode public function getSql(SqlWalker $sqlWalker) { - return 'GREATEST(' . implode(', ', array_map(static fn(Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; + return 'GREATEST(' . implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; } public function parse(Parser $parser) diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php index e31d31456..9befa5f40 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php @@ -33,7 +33,7 @@ class Least extends FunctionNode public function getSql(SqlWalker $sqlWalker) { - return 'LEAST(' . implode(', ', array_map(static fn(Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; + return 'LEAST(' . implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; } public function parse(Parser $parser) diff --git a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php index 34e22d3e1..6c0d0be5b 100644 --- a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php +++ b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php @@ -121,7 +121,7 @@ class PermissionsGroup public function isRoleScopePresentOnce(ExecutionContextInterface $context) { $roleScopesId = array_map( - static fn(RoleScope $roleScope) => $roleScope->getId(), + static fn (RoleScope $roleScope) => $roleScope->getId(), $this->getRoleScopes()->toArray() ); $countedIds = array_count_values($roleScopesId); diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index f94a154db..1f3070eb2 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -291,7 +291,7 @@ class EntityWorkflowStep public function removeDestEmail(string $email): self { - $this->destEmail = array_filter($this->destEmail, static fn(string $existing) => $email !== $existing); + $this->destEmail = array_filter($this->destEmail, static fn (string $existing) => $email !== $existing); return $this; } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php index a6b7094e4..b84c80118 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php @@ -199,7 +199,7 @@ class CSVListFormatter implements FormatterInterface foreach ($keys as $key) { // get an array with all values for this key if possible - $values = array_map(static fn($v) => $v[$key], $this->result); + $values = array_map(static fn ($v) => $v[$key], $this->result); // store the label in the labelsCache property $this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData); } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php index 87814eb47..63d691443 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php @@ -187,7 +187,7 @@ class CSVPivotedListFormatter implements FormatterInterface foreach ($keys as $key) { // get an array with all values for this key if possible - $values = array_map(static fn($v) => $v[$key], $this->result); + $values = array_map(static fn ($v) => $v[$key], $this->result); // store the label in the labelsCache property $this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData); } diff --git a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php index 99f78fe80..fca338a6f 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php @@ -257,7 +257,7 @@ class ExportAddressHelper $prefixes = array_merge( $prefixes, array_map( - static fn($item) => $prefix . $item, + static fn ($item) => $prefix . $item, self::COLUMN_MAPPING[$key] ) ); diff --git a/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php b/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php index 99fb54514..174fb3304 100644 --- a/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php +++ b/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php @@ -48,7 +48,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedPostalCodes, - static fn(?PostalCode $pc = null) => call_user_func($value, $pc) + static fn (?PostalCode $pc = null) => call_user_func($value, $pc) ); } diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php index 90c919f1d..01303bfbb 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php @@ -37,7 +37,7 @@ class ExportPickCenterDataMapper implements DataMapperInterface foreach ($this->regroupmentRepository->findAll() as $regroupment) { /** @phpstan-ignore-next-line */ - [$contained, $notContained] = $regroupment->getCenters()->partition(static fn(Center $center): bool => false); + [$contained, $notContained] = $regroupment->getCenters()->partition(static fn (Center $center): bool => false); if (0 === count($notContained)) { $pickedRegroupment[] = $regroupment; diff --git a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php index 4d89f7851..6aa5eee40 100644 --- a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php @@ -42,7 +42,7 @@ class IdToEntityDataTransformer implements DataTransformerInterface { $this->repository = $repository; $this->multiple = $multiple; - $this->getId = $getId ?? static fn(object $o) => $o->getId(); + $this->getId = $getId ?? static fn (object $o) => $o->getId(); } /** diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index 3cf599a52..ff2c563d3 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -36,11 +36,11 @@ final class LocationFormType extends AbstractType $builder ->add('locationType', EntityType::class, [ 'class' => EntityLocationType::class, - 'choice_attr' => static fn(EntityLocationType $entity) => [ + 'choice_attr' => static fn (EntityLocationType $entity) => [ 'data-address' => $entity->getAddressRequired(), 'data-contact' => $entity->getContactData(), ], - 'choice_label' => fn(EntityLocationType $entity) => $this->translatableStringHelper->localize($entity->getTitle()), + 'choice_label' => fn (EntityLocationType $entity) => $this->translatableStringHelper->localize($entity->getTitle()), ]) ->add('name', TextType::class) ->add('phonenumber1', ChillPhoneNumberType::class, ['required' => false]) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php index fdd24eb3f..48bd37dcc 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php @@ -24,10 +24,10 @@ class ComposedGroupCenterType extends AbstractType { $builder->add('permissionsgroup', EntityType::class, [ 'class' => \Chill\MainBundle\Entity\PermissionsGroup::class, - 'choice_label' => static fn(PermissionsGroup $group) => $group->getName(), + 'choice_label' => static fn (PermissionsGroup $group) => $group->getName(), ])->add('center', EntityType::class, [ 'class' => \Chill\MainBundle\Entity\Center::class, - 'choice_label' => static fn(Center $center) => $center->getName(), + 'choice_label' => static fn (Center $center) => $center->getName(), ]); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php index 4424cccf3..970787cd1 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php @@ -82,11 +82,11 @@ class ComposedRoleScopeType extends AbstractType return ['data-has-scope' => '1']; }, - 'group_by' => fn($role, $key, $index) => $this->roleProvider->getRoleTitle($role), + 'group_by' => fn ($role, $key, $index) => $this->roleProvider->getRoleTitle($role), ]) ->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => static fn(Scope $scope) => $translatableStringHelper->localize($scope->getName()), + 'choice_label' => static fn (Scope $scope) => $translatableStringHelper->localize($scope->getName()), 'required' => false, 'data' => null, ]); diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index 24e3ffc5b..529bd9789 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -51,7 +51,7 @@ class EntityToJsonTransformer implements DataTransformerInterface } return array_map( - fn($item) => $this->denormalizeOne($item), + fn ($item) => $this->denormalizeOne($item), $denormalized ); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index 7a1ebcaf5..c89907cf3 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -67,7 +67,7 @@ final class PickCenterType extends AbstractType 'choices' => $centers, 'multiple' => true, 'expanded' => true, - 'choice_label' => static fn(Center $c) => $c->getName(), + 'choice_label' => static fn (Center $c) => $c->getName(), 'data' => $centers, ]); @@ -78,7 +78,7 @@ final class PickCenterType extends AbstractType 'multiple' => true, 'expanded' => true, 'choices' => $this->regroupmentRepository->findAllActive(), - 'choice_label' => static fn(Regroupment $r) => $r->getName(), + 'choice_label' => static fn (Regroupment $r) => $r->getName(), ]); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php index b977dd102..83e957623 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php @@ -90,7 +90,7 @@ class PickCenterType extends AbstractType return ['center' => $data]; }, - static fn($data) => $data['center'] + static fn ($data) => $data['center'] )); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php index c5e0f7d80..adb0f2a67 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php @@ -34,11 +34,11 @@ class PickCivilityType extends AbstractType ->setDefault('label', 'Civility') ->setDefault( 'choice_label', - fn(Civility $civility): string => $this->translatableStringHelper->localize($civility->getName()) + fn (Civility $civility): string => $this->translatableStringHelper->localize($civility->getName()) ) ->setDefault( 'query_builder', - static fn(EntityRepository $er): QueryBuilder => $er->createQueryBuilder('c') + static fn (EntityRepository $er): QueryBuilder => $er->createQueryBuilder('c') ->where('c.active = true') ->orderBy('c.order'), ) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php index 0763e485e..3d993c9f1 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php @@ -31,7 +31,7 @@ class PickLocationTypeType extends AbstractType $resolver ->setDefaults([ 'class' => LocationType::class, - 'choice_label' => fn(LocationType $type) => $this->translatableStringHelper->localize($type->getTitle()), + 'choice_label' => fn (LocationType $type) => $this->translatableStringHelper->localize($type->getTitle()), 'placeholder' => 'Pick a location type', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php index bd19e5f29..d78957f29 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php @@ -36,7 +36,7 @@ class PickUserLocationType extends AbstractType ->setDefaults([ 'class' => Location::class, 'choices' => $this->locationRepository->findByPublicLocations(), - 'choice_label' => fn(Location $entity) => $entity->getName() ? + 'choice_label' => fn (Location $entity) => $entity->getName() ? $entity->getName() . ' (' . $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ')' : $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()), 'placeholder' => 'Pick a location', diff --git a/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php b/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php index a611f3da9..51a321be6 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php @@ -77,7 +77,7 @@ class PostalCodeType extends AbstractType $helper = $this->translatableStringHelper; $resolver ->setDefault('class', PostalCode::class) - ->setDefault('choice_label', static fn(PostalCode $code) => $code->getCode() . ' ' . $code->getName() . ' [' . + ->setDefault('choice_label', static fn (PostalCode $code) => $code->getCode() . ' ' . $code->getName() . ' [' . $helper->localize($code->getCountry()->getName()) . ']') ->setDefault('choice_loader', $this->choiceLoader) ->setDefault('placeholder', 'Select a postal code'); diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index 77bf84cca..4d04b9f03 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -66,7 +66,7 @@ class ScopePickerType extends AbstractType $options['role'] instanceof Role ? $options['role']->getRole() : $options['role'], $options['center'] ), - static fn(Scope $s) => $s->isActive() + static fn (Scope $s) => $s->isActive() ); if (0 === count($items)) { @@ -77,7 +77,7 @@ class ScopePickerType extends AbstractType $builder->add('scope', EntityType::class, [ 'class' => Scope::class, 'placeholder' => 'Choose the circle', - 'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()), + 'choice_label' => fn (Scope $c) => $this->translatableStringHelper->localize($c->getName()), 'choices' => $items, ]); $builder->setDataMapper(new ScopePickerDataMapper()); diff --git a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php index 974ef4566..c430a1053 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php @@ -79,7 +79,7 @@ class UserPickerType extends AbstractType ->setAllowedTypes('having_permissions_group_flag', ['string', 'null']) ->setDefault('class', User::class) ->setDefault('placeholder', 'Choose an user') - ->setDefault('choice_label', fn(User $u) => $this->userRender->renderString($u, [])) + ->setDefault('choice_label', fn (User $u) => $this->userRender->renderString($u, [])) ->setDefault('scope', null) ->setAllowedTypes('scope', [Scope::class, 'array', 'null']) ->setNormalizer('choices', function (Options $options) { diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index e343b0fc4..f8485aa99 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -77,14 +77,14 @@ class UserType extends AbstractType 'required' => false, 'placeholder' => 'Choose a main scope', 'class' => Scope::class, - 'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()), + 'choice_label' => fn (Scope $c) => $this->translatableStringHelper->localize($c->getName()), ]) ->add('userJob', EntityType::class, [ 'label' => 'user job', 'required' => false, 'placeholder' => 'choose a job', 'class' => UserJob::class, - 'choice_label' => fn(UserJob $c) => $this->translatableStringHelper->localize($c->getLabel()), + 'choice_label' => fn (UserJob $c) => $this->translatableStringHelper->localize($c->getLabel()), 'query_builder' => static function (EntityRepository $er) { $qb = $er->createQueryBuilder('uj'); $qb->where('uj.active = TRUE'); @@ -97,7 +97,7 @@ class UserType extends AbstractType 'required' => false, 'placeholder' => 'choose a location', 'class' => Location::class, - 'choice_label' => fn(Location $l) => $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName(), + 'choice_label' => fn (Location $l) => $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName(), 'query_builder' => static function (EntityRepository $er) { $qb = $er->createQueryBuilder('l'); $qb->orderBy('l.locationType'); diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index 0e6e12b3e..b3d498610 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -69,7 +69,7 @@ class WorkflowStepType extends AbstractType $choices = array_combine( array_map( - static fn(Transition $transition) => $transition->getName(), + static fn (Transition $transition) => $transition->getName(), $transitions ), $transitions @@ -86,8 +86,8 @@ class WorkflowStepType extends AbstractType 'backward' => 'backward', 'neutral' => 'neutral', ], - 'choice_label' => fn(string $key) => $this->translatableStringHelper->localize($inputLabels[$key]), - 'choice_attr' => static fn(string $key) => [ + 'choice_label' => fn (string $key) => $this->translatableStringHelper->localize($inputLabels[$key]), + 'choice_attr' => static fn (string $key) => [ $key => $key, ], 'mapped' => false, diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index e96f531e2..7ebb5ed87 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -90,7 +90,7 @@ class SearchProvider public function getByOrder() { //sort the array - uasort($this->searchServices, static fn(SearchInterface $a, SearchInterface $b) => $a->getOrder() <=> $b->getOrder()); + uasort($this->searchServices, static fn (SearchInterface $a, SearchInterface $b) => $a->getOrder() <=> $b->getOrder()); return $this->searchServices; } diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php index a52379faa..c06ded0a8 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php @@ -54,7 +54,7 @@ class AddressReferenceBEFromBestAddress throw new RuntimeException('could not get the release definition', 0, $e); } - $asset = array_filter($release['assets'], static fn(array $item) => 'addresses-' . $list . '.' . $lang . '.csv.gz' === $item['name']); + $asset = array_filter($release['assets'], static fn (array $item) => 'addresses-' . $list . '.' . $lang . '.csv.gz' === $item['name']); return array_values($asset)[0]['browser_download_url']; } diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php index 4bca126a6..aa04c9ac3 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php @@ -82,7 +82,7 @@ class PostalCodeBEFromBestAddress throw new RuntimeException('could not get the release definition', 0, $e); } - $postals = array_filter($release['assets'], static fn(array $item) => 'postals.' . $lang . '.csv.gz' === $item['name']); + $postals = array_filter($release['assets'], static fn (array $item) => 'postals.' . $lang . '.csv.gz' === $item['name']); return array_values($postals)[0]['browser_download_url']; } diff --git a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php index c6246213f..36374c6af 100644 --- a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php +++ b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php @@ -39,7 +39,7 @@ class ChillMailer implements MailerInterface } $this->chillLogger->info('chill email sent', [ - 'to' => array_map(static fn(Address $address) => $address->getAddress(), $message->getTo()), + 'to' => array_map(static fn (Address $address) => $address->getAddress(), $message->getTo()), 'subject' => $message->getSubject(), ]); diff --git a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php index 051d04591..d641b94a8 100644 --- a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php @@ -134,7 +134,7 @@ final class NotificationTest extends KernelTestCase $this->assertEquals($senderId, $notification->getSender()->getId()); $this->assertCount(count($addressesIds), $notification->getUnreadBy()); - $unreadIds = $notification->getUnreadBy()->map(static fn(User $u) => $u->getId()); + $unreadIds = $notification->getUnreadBy()->map(static fn (User $u) => $u->getId()); foreach ($addressesIds as $addresseeId) { $this->assertContains($addresseeId, $unreadIds); diff --git a/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php b/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php index 42f6d71d8..0e37f0fde 100644 --- a/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php @@ -96,7 +96,7 @@ final class ScopePickerTypeTest extends TypeTestCase $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); $translatableStringHelper->localize(Argument::type('array'))->will( - static fn($args) => $args[0]['fr'] + static fn ($args) => $args[0]['fr'] ); $type = new ScopePickerType( diff --git a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php index 5f79494a3..49419f261 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php @@ -52,7 +52,7 @@ final class ExtractDateFromPatternTest extends TestCase $this->assertContainsOnlyInstancesOf(DateTimeImmutable::class, $result->getFound()); $dates = array_map( - static fn(DateTimeImmutable $d) => $d->format('Y-m-d'), + static fn (DateTimeImmutable $d) => $d->format('Y-m-d'), $result->getFound() ); diff --git a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php index 657e37e36..8c681bfb0 100644 --- a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php @@ -211,7 +211,7 @@ final class AuthorizationHelperTest extends KernelTestCase $centerA ); - $usernames = array_map(static fn(User $u) => $u->getUsername(), $users); + $usernames = array_map(static fn (User $u) => $u->getUsername(), $users); $this->assertContains('center a_social', $usernames); } diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php index dfe47ecc8..f3e04eeca 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php @@ -105,7 +105,7 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac [ '%users%' => implode( ', ', - $entityWorkflow->getCurrentStep()->getAllDestUser()->map(fn(User $u) => $this->userRender->renderString($u, []))->toArray() + $entityWorkflow->getCurrentStep()->getAllDestUser()->map(fn (User $u) => $this->userRender->renderString($u, []))->toArray() ), ] )); diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php index dc9657e3c..76ad4a4b0 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php @@ -109,7 +109,7 @@ class NotificationOnTransition implements EventSubscriberInterface 'dest' => $subscriber, 'place' => $place, 'workflow' => $workflow, - 'is_dest' => in_array($subscriber->getId(), array_map(static fn(User $u) => $u->getId(), $entityWorkflow->futureDestUsers), true), + 'is_dest' => in_array($subscriber->getId(), array_map(static fn (User $u) => $u->getId(), $entityWorkflow->futureDestUsers), true), ]; $notification = new Notification(); diff --git a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php index 6ab44f625..bb3586251 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php +++ b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php @@ -59,7 +59,7 @@ class EntityWorkflowCreationValidator extends \Symfony\Component\Validator\Const $workflows = $this->entityWorkflowManager->getSupportedWorkflows($value); - $matched = array_filter($workflows, static fn(WorkflowInterface $workflow) => $workflow->getName() === $value->getWorkflowName()); + $matched = array_filter($workflows, static fn (WorkflowInterface $workflow) => $workflow->getName() === $value->getWorkflowName()); if (0 === count($matched)) { $this->context->buildViolation($constraint->messageWorkflowNotAvailable) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index d7289c68a..181f60a02 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -169,7 +169,7 @@ final class AccompanyingCourseApiController extends ApiController $accompanyingPeriods = $person->getCurrentAccompanyingPeriods(); $accompanyingPeriodsChecked = array_filter( $accompanyingPeriods, - fn(AccompanyingPeriod $period) => $this->isGranted(AccompanyingPeriodVoter::SEE, $period) + fn (AccompanyingPeriod $period) => $this->isGranted(AccompanyingPeriodVoter::SEE, $period) ); return $this->json(array_values($accompanyingPeriodsChecked), Response::HTTP_OK, [], ['groups' => ['read']]); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php index 18098a129..b32454387 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php @@ -222,10 +222,10 @@ class AccompanyingPeriodController extends AbstractController $accompanyingPeriodsRaw = $this->accompanyingPeriodACLAwareRepository ->findByPerson($person, AccompanyingPeriodVoter::SEE); - usort($accompanyingPeriodsRaw, static fn($a, $b) => $b->getOpeningDate() > $a->getOpeningDate()); + usort($accompanyingPeriodsRaw, static fn ($a, $b) => $b->getOpeningDate() > $a->getOpeningDate()); // filter visible or not visible - $accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn(AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap)); + $accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn (AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap)); return $this->render('@ChillPerson/AccompanyingPeriod/list.html.twig', [ 'accompanying_periods' => $accompanyingPeriods, @@ -327,7 +327,7 @@ class AccompanyingPeriodController extends AbstractController /** @var AccompanyingPeriod $period */ $period = array_filter( $person->getAccompanyingPeriods(), - static fn(AccompanyingPeriod $p) => $p->getId() === ($period_id) + static fn (AccompanyingPeriod $p) => $p->getId() === ($period_id) )[0] ?? null; if (null === $period) { diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php index ced5ccd9d..6bbb6c368 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php @@ -105,8 +105,8 @@ class AccompanyingPeriodRegulationListController $builder ->add('services', EntityType::class, [ 'class' => Scope::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('s'), - 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize($s->getName()), + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('s'), + 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), 'multiple' => true, 'label' => 'Service', 'required' => false, @@ -119,7 +119,7 @@ class AccompanyingPeriodRegulationListController return $qb; }, - 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()), + 'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()), 'multiple' => true, 'label' => 'Métier', 'required' => false, @@ -141,7 +141,7 @@ class AccompanyingPeriodRegulationListController return $qb; }, - 'choice_label' => static fn(Location $l) => $l->getName(), + 'choice_label' => static fn (Location $l) => $l->getName(), 'multiple' => true, 'group_by' => function (Location $l) { if (null === $type = $l->getLocationType()) { diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php index 98fa0ebfe..61e030322 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php @@ -164,7 +164,7 @@ class HouseholdCompositionController extends AbstractController $isEdit = $request->query->has('edit'); if ($isEdit) { - $householdCompositions = $household->getCompositions()->filter(static fn(HouseholdComposition $composition) => $composition->getId() === $request->query->getInt('edit')); + $householdCompositions = $household->getCompositions()->filter(static fn (HouseholdComposition $composition) => $composition->getId() === $request->query->getInt('edit')); if ($householdCompositions->count() !== 1) { throw new BadRequestHttpException('could not find the composition with this id associated to the household'); diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php index 68f32c886..42092249b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php @@ -81,7 +81,7 @@ class HouseholdController extends AbstractController } } - usort($accompanyingPeriods, static fn($a, $b) => $b->getOpeningDate() <=> $a->getOpeningDate()); + usort($accompanyingPeriods, static fn ($a, $b) => $b->getOpeningDate() <=> $a->getOpeningDate()); $oldMembers = $household->getNonCurrentMembers(); $accompanyingPeriodsOld = []; diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 35256ce56..505f307e6 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -108,10 +108,10 @@ class PersonApiController extends ApiController $addresses = $person ->getAccompanyingPeriodParticipations() ->filter( - static fn(AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool => null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() + static fn (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool => null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() ) ->map( - static fn(AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address => $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() + static fn (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address => $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() ) ->filter( // We remove potential null addresses. diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php index 75293fd7b..4fe877a72 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php @@ -44,7 +44,7 @@ class SocialWorkSocialActionApiController extends ApiController $socialActions = $socialIssue->getRecursiveSocialActions()->toArray(); - usort($socialActions, static fn(SocialAction $sa, SocialAction $sb) => $sa->getOrdering() <=> $sb->getOrdering()); + usort($socialActions, static fn (SocialAction $sa, SocialAction $sb) => $sa->getOrdering() <=> $sb->getOrdering()); $pagination = $this->paginator->create(count($socialActions)); // max one page diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php index fb5ae6e4e..78180adff 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php @@ -115,7 +115,7 @@ class LoadCustomFields extends AbstractFixture implements // get possible values for cfGroup $choices = array_map( - static fn($a) => $a['slug'], + static fn ($a) => $a['slug'], $this->customFieldChoice->getOptions()['choices'] ); // create faker diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 364cb41d5..a0f6e7d7e 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -828,7 +828,7 @@ class AccompanyingPeriod implements $collection = $this ->getParticipationsContainsPerson($person) ->filter( - static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() + static fn (AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() ); return $collection->count() > 0 ? $collection->first() : null; @@ -842,7 +842,7 @@ class AccompanyingPeriod implements return $this ->getParticipations() ->filter( - static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() + static fn (AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() ); } diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php index 2fa1df203..8a99c7eb4 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php @@ -202,7 +202,7 @@ class Household { $at ??= new DateTime('today'); - $addrs = $this->getAddresses()->filter(static fn(Address $a) => $a->getValidFrom() <= $at && ( + $addrs = $this->getAddresses()->filter(static fn (Address $a) => $a->getValidFrom() <= $at && ( null === $a->getValidTo() || $a->getValidTo() > $at )); @@ -336,7 +336,7 @@ class Household public function getCurrentPersons(?DateTimeImmutable $now = null): ReadableCollection { return $this->getCurrentMembers($now) - ->map(static fn(HouseholdMember $m) => $m->getPerson()); + ->map(static fn (HouseholdMember $m) => $m->getPerson()); } public function getId(): ?int @@ -363,7 +363,7 @@ class Household $membership->getStartDate(), $membership->getEndDate() )->filter( - static fn(HouseholdMember $m) => $m->getPerson() !== $membership->getPerson() + static fn (HouseholdMember $m) => $m->getPerson() !== $membership->getPerson() ); } @@ -502,7 +502,7 @@ class Household usort( $compositionOrdered, - static fn(HouseholdComposition $a, HouseholdComposition $b) => $a->getStartDate() <=> $b->getStartDate() + static fn (HouseholdComposition $a, HouseholdComposition $b) => $a->getStartDate() <=> $b->getStartDate() ); $iterator = new ArrayIterator($compositionOrdered); diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 1507bafd7..af8e7f92b 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -775,7 +775,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI ): int { // TODO should be optimized to avoid loading accompanying period ? return $this->getAccompanyingPeriodInvolved($asParticipantOpen, $asRequestor) - ->filter(fn(AccompanyingPeriod $p) => $p->getStep() !== AccompanyingPeriod::STEP_DRAFT) + ->filter(fn (AccompanyingPeriod $p) => $p->getStep() !== AccompanyingPeriod::STEP_DRAFT) ->count(); } @@ -1339,7 +1339,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this->getAccompanyingPeriodParticipations() ->matching($criteria) - ->filter(static fn(AccompanyingPeriodParticipation $app) => AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep()); + ->filter(static fn (AccompanyingPeriodParticipation $app) => AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep()); } public function getOtherPhoneNumbers(): Collection diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index c018eb95f..4ac96aac1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -128,7 +128,7 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface 'placeholder' => 'Select a geographical layer', 'class' => GeographicalUnitLayer::class, 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), - 'choice_label' => fn(GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), + 'choice_label' => fn (GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php index c2923c9e9..3d785b586 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php @@ -147,7 +147,7 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme ]; } - return static fn(string $value): string => $labels[$value]; + return static fn (string $value): string => $labels[$value]; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php index 1ab9f1b78..ff72994ba 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php @@ -100,7 +100,7 @@ class GeographicalUnitAggregator implements AggregatorInterface 'placeholder' => 'Select a geographical layer', 'class' => GeographicalUnitLayer::class, 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), - 'choice_label' => fn(GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), + 'choice_label' => fn (GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php index b91a90000..d7c4097af 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php @@ -141,7 +141,7 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ]; } - return static fn($value): string => $labels[$value]; + return static fn ($value): string => $labels[$value]; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 7cb2e623f..978f88a10 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -64,7 +64,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -89,7 +89,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php index 412890241..122ee14d9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php @@ -63,7 +63,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -88,7 +88,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->em->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 4efd7e246..1613b63d3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -62,7 +62,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -87,7 +87,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index 2b782d1ed..0b693b9d8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -113,7 +113,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php index 528be42c8..60429ae55 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php @@ -62,7 +62,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data) @@ -92,7 +92,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->personRepository->createQueryBuilder('person'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index e58439112..e52cc83b1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -64,7 +64,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -89,7 +89,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 1bfd1870f..045039930 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -290,7 +290,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php index 17c2c4f99..00fa8adb1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php @@ -263,7 +263,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index 0f63d41ca..f0985436b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -241,7 +241,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php index d176f7bb8..24d929c00 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php @@ -146,7 +146,7 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index 322917b02..8145fd658 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -191,7 +191,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php index 35bb8a6c1..7cb066e87 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php @@ -159,7 +159,7 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 0c2fb63f5..31ca41cbb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -112,7 +112,7 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php index 05c883309..e57370f30 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php @@ -59,7 +59,7 @@ class ClosingMotiveFilter implements FilterInterface { $builder->add('accepted_closingmotives', EntityType::class, [ 'class' => ClosingMotive::class, - 'choice_label' => fn(ClosingMotive $cm) => $this->translatableStringHelper->localize($cm->getName()), + 'choice_label' => fn (ClosingMotive $cm) => $this->translatableStringHelper->localize($cm->getName()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index 497068c39..f585cfafb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -61,7 +61,7 @@ class CreatorJobFilter implements FilterInterface $builder->add('creator_job', EntityType::class, [ 'class' => UserJob::class, 'choices' => $this->userJobRepository->findAllActive(), - 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + 'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize( $j->getLabel() ), 'multiple' => true, diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index 7f409c022..ab7f4257e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -69,7 +69,7 @@ class EvaluationFilter implements FilterInterface $builder->add('accepted_evaluations', EntityType::class, [ 'class' => Evaluation::class, 'choices' => $this->evaluationRepository->findAllActive(), - 'choice_label' => fn(Evaluation $ev) => $this->translatableStringHelper->localize($ev->getTitle()), + 'choice_label' => fn (Evaluation $ev) => $this->translatableStringHelper->localize($ev->getTitle()), 'multiple' => true, 'expanded' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index 719029d38..d35565c80 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -107,7 +107,7 @@ class GeographicalUnitStatFilter implements FilterInterface 'placeholder' => 'Select a geographical unit', 'choices' => $this->geographicalUnitRepository->findAll(), 'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id, - 'choice_label' => fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, + 'choice_label' => fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, 'attr' => [ 'class' => 'select2', ], @@ -122,7 +122,7 @@ class GeographicalUnitStatFilter implements FilterInterface '%units' => implode( ', ', array_map( - fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, + fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, $data['units'] ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php index bde641b2d..00febc640 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php @@ -59,7 +59,7 @@ class OriginFilter implements FilterInterface { $builder->add('accepted_origins', EntityType::class, [ 'class' => Origin::class, - 'choice_label' => fn(Origin $o) => $this->translatableStringHelper->localize($o->getLabel()), + 'choice_label' => fn (Origin $o) => $this->translatableStringHelper->localize($o->getLabel()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php index 15be1a52b..6a0c71d55 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php @@ -59,7 +59,7 @@ final class EvaluationTypeFilter implements FilterInterface { $builder->add('accepted_evaluationtype', EntityType::class, [ 'class' => Evaluation::class, - 'choice_label' => fn(Evaluation $ev): string => $this->translatableStringHelper->localize($ev->getTitle()), + 'choice_label' => fn (Evaluation $ev): string => $this->translatableStringHelper->localize($ev->getTitle()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index 7eb00fc2b..22761c158 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -78,7 +78,7 @@ class CompositionFilter implements FilterInterface $builder ->add('accepted_composition', EntityType::class, [ 'class' => HouseholdCompositionType::class, - 'choice_label' => fn(HouseholdCompositionType $type) => $this->translatableStringHelper->localize( + 'choice_label' => fn (HouseholdCompositionType $type) => $this->translatableStringHelper->localize( $type->getLabel() ), 'multiple' => true, diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php index 5ecdc1fda..7580a37a3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php @@ -81,7 +81,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface ->add('ref_statuses', ChoiceType::class, [ 'label' => 'export.filter.person.by_address_ref_status.Status', 'choices' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW, Address::ADDR_REFERENCE_STATUS_REVIEWED, Address::ADDR_REFERENCE_STATUS_MATCH], - 'choice_label' => fn(string $item) => 'export.filter.person.by_address_ref_status.'.$item, + 'choice_label' => fn (string $item) => 'export.filter.person.by_address_ref_status.'.$item, 'multiple' => true, 'expanded' => true, 'data' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW] @@ -97,7 +97,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface '%statuses%' => implode( ', ', array_map( - fn(string $item) => 'export.filter.person.by_address_ref_status.'.$item, + fn (string $item) => 'export.filter.person.by_address_ref_status.'.$item, $data['ref_statuses'] ?? RollingDate::T_TODAY ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php index 92b8ad08b..739945b98 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php @@ -67,7 +67,7 @@ class GenderFilter implements $qb->add('where', $where); $qb->setParameter('person_gender', array_filter( $data['accepted_genders'], - static fn($el) => 'null' !== $el + static fn ($el) => 'null' !== $el )); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php index 15882b705..79f5cb2d4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php @@ -98,7 +98,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface 'placeholder' => 'Select a geographical unit', 'choices' => $this->geographicalUnitRepository->findAll(), 'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id, - 'choice_label' => fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, + 'choice_label' => fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, 'attr' => [ 'class' => 'select2', ], @@ -115,7 +115,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface '%units%' => implode( ', ', array_map( - fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, + fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, $data['units'] ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php index 62b6a34d7..47a75871c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -49,7 +49,7 @@ class MaritalStatusFilter implements FilterInterface { $builder->add('maritalStatus', EntityType::class, [ 'class' => MaritalStatus::class, - 'choice_label' => fn(MaritalStatus $ms) => $this->translatableStringHelper->localize( + 'choice_label' => fn (MaritalStatus $ms) => $this->translatableStringHelper->localize( $ms->getName() ), 'multiple' => true, diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php index 19e5f999c..b1d77d60e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php @@ -72,7 +72,7 @@ class NationalityFilter implements { $countries = $data['nationalities']; - $names = array_map(fn(Country $c) => $this->translatableStringHelper->localize($c->getName()), [$countries]); + $names = array_map(fn (Country $c) => $this->translatableStringHelper->localize($c->getName()), [$countries]); return [ 'Filtered by nationality : %nationalities%', diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index 32dc2a2fb..21bb40947 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -100,7 +100,7 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface $builder->add('thirdparty_cat', EntityType::class, [ 'class' => ThirdPartyCategory::class, 'label' => 'Category', - 'choice_label' => fn(ThirdPartyCategory $tpc) => $this->translatableStringHelper->localize($tpc->getName()), + 'choice_label' => fn (ThirdPartyCategory $tpc) => $this->translatableStringHelper->localize($tpc->getName()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index 1c38a030e..144bf3260 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -69,7 +69,7 @@ class JobFilter implements FilterInterface { $builder->add('job', EntityType::class, [ 'class' => UserJob::class, - 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + 'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize( $j->getLabel() ), 'multiple' => true, diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index 5d8e20832..315025722 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -69,7 +69,7 @@ class ScopeFilter implements FilterInterface { $builder->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize( $s->getName() ), 'multiple' => true, diff --git a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php index fe9a3490f..03db7c156 100644 --- a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php +++ b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php @@ -55,7 +55,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedPersons, - static fn(Person $p) => call_user_func($value, $p) + static fn (Person $p) => call_user_func($value, $p) ); } diff --git a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php index 6e4877b63..a63b008c6 100644 --- a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php +++ b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php @@ -40,7 +40,7 @@ class HouseholdCompositionType extends AbstractType ->add('householdCompositionType', EntityType::class, [ 'class' => \Chill\PersonBundle\Entity\Household\HouseholdCompositionType::class, 'choices' => $types, - 'choice_label' => fn(\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) => $this->translatableStringHelper->localize($type->getLabel()), + 'choice_label' => fn (\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) => $this->translatableStringHelper->localize($type->getLabel()), 'label' => 'household_composition.Household composition', ]) ->add('startDate', ChillDateType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 4752fb628..927812929 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -118,8 +118,8 @@ class PersonType extends AbstractType ]); $builder->get('placeOfBirth')->addModelTransformer(new CallbackTransformer( - static fn($string) => strtoupper((string) $string), - static fn($string) => strtoupper((string) $string) + static fn ($string) => strtoupper((string) $string), + static fn ($string) => strtoupper((string) $string) )); } @@ -163,7 +163,7 @@ class PersonType extends AbstractType 'allow_delete' => true, 'by_reference' => false, 'label' => false, - 'delete_empty' => static fn(?PersonPhone $pp = null) => null === $pp || $pp->isEmpty(), + 'delete_empty' => static fn (?PersonPhone $pp = null) => null === $pp || $pp->isEmpty(), 'error_bubbling' => false, 'empty_collection_explain' => 'No additional phone numbers', ]); diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php index 7a6a7484d..a6f55e917 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php @@ -46,7 +46,7 @@ class GoalType extends AbstractType 'class' => Result::class, 'required' => false, 'multiple' => true, - 'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()), + 'choice_label' => fn (Result $r) => $this->translatableStringHelper->localize($r->getTitle()), 'attr' => ['class' => 'select2 '], ]) ->add('desactivationDate', ChillDateType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php index 7f5b434dd..0b6cbe73d 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php @@ -50,12 +50,12 @@ class SocialActionType extends AbstractType ->add('issue', EntityType::class, [ 'class' => SocialIssue::class, 'label' => 'socialAction.socialIssue', - 'choice_label' => fn(SocialIssue $issue) => $this->translatableStringHelper->localize($issue->getTitle()), + 'choice_label' => fn (SocialIssue $issue) => $this->translatableStringHelper->localize($issue->getTitle()), ]) ->add('parent', EntityType::class, [ 'class' => SocialAction::class, 'required' => false, - 'choice_label' => fn(SocialAction $issue) => $this->translatableStringHelper->localize($issue->getTitle()), + 'choice_label' => fn (SocialAction $issue) => $this->translatableStringHelper->localize($issue->getTitle()), ]) ->add('ordering', NumberType::class, [ 'required' => true, @@ -66,7 +66,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()), + 'choice_label' => fn (Result $r) => $this->translatableStringHelper->localize($r->getTitle()), ]) ->add('goals', EntityType::class, [ @@ -74,7 +74,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => fn(Goal $g) => $this->translatableStringHelper->localize($g->getTitle()), + 'choice_label' => fn (Goal $g) => $this->translatableStringHelper->localize($g->getTitle()), ]) ->add('evaluations', EntityType::class, [ @@ -82,7 +82,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => fn(Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), + 'choice_label' => fn (Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), ]) ->add('defaultNotificationDelay', DateIntervalType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php b/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php index 2b4613376..240bcfbb4 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php @@ -60,13 +60,13 @@ class ClosingMotivePickerType extends AbstractType 'class' => ClosingMotive::class, 'empty_data' => null, 'placeholder' => 'Choose a motive', - 'choice_label' => fn(ClosingMotive $cm) => $this->entityRenderExtension->renderString($cm), + 'choice_label' => fn (ClosingMotive $cm) => $this->entityRenderExtension->renderString($cm), 'only_leaf' => true, ]); $resolver ->setAllowedTypes('only_leaf', 'bool') - ->setNormalizer('choices', fn(Options $options) => $this->repository + ->setNormalizer('choices', fn (Options $options) => $this->repository ->getActiveClosingMotive($options['only_leaf'])); } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php index 3c0a1d5af..026a24bb6 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php @@ -113,9 +113,9 @@ class PickPersonType extends AbstractType // add the default options $resolver->setDefaults([ 'class' => Person::class, - 'choice_label' => static fn(Person $p) => $p->getFirstname() . ' ' . $p->getLastname(), + 'choice_label' => static fn (Person $p) => $p->getFirstname() . ' ' . $p->getLastname(), 'placeholder' => 'Pick a person', - 'choice_attr' => static fn(Person $p) => [ + 'choice_attr' => static fn (Person $p) => [ 'data-center' => $p->getCenter()->getId(), ], 'attr' => ['class' => 'select2 '], @@ -135,7 +135,7 @@ class PickPersonType extends AbstractType protected function filterCentersfom(Options $options) { if (null === $options['role']) { - $centers = array_map(static fn(GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray()); + $centers = array_map(static fn (GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray()); } else { $centers = $this->authorizationHelper ->getReachableCenters($this->user, $options['role']->getRole()); @@ -158,7 +158,7 @@ class PickPersonType extends AbstractType if ( !in_array($c->getId(), array_map( - static fn(Center $c) => $c->getId(), + static fn (Center $c) => $c->getId(), $centers ), true) ) { diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php index 695d3aa12..fd947e9cd 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php @@ -38,7 +38,7 @@ class PickSocialActionType extends AbstractType ->setDefaults([ 'class' => SocialAction::class, 'choices' => $this->actionRepository->findAllActive(), - 'choice_label' => fn(SocialAction $sa) => $this->actionRender->renderString($sa, []), + 'choice_label' => fn (SocialAction $sa) => $this->actionRender->renderString($sa, []), 'placeholder' => 'Pick a social action', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php index 9c02a7905..b560337ac 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php @@ -38,7 +38,7 @@ class PickSocialIssueType extends AbstractType ->setDefaults([ 'class' => SocialIssue::class, 'choices' => $this->issueRepository->findAllActive(), - 'choice_label' => fn(SocialIssue $si) => $this->issueRender->renderString($si, []), + 'choice_label' => fn (SocialIssue $si) => $this->issueRender->renderString($si, []), 'placeholder' => 'Pick a social issue', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php index f83d6faf4..33d01de1b 100644 --- a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php @@ -76,7 +76,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface $involved = $this->getInvolved(); $involved['period_id'] = $event->getPeriod()->getId(); $involved['persons'] = $event->getPeriod()->getPersons() - ->map(static fn(Person $p) => $p->getId()) + ->map(static fn (Person $p) => $p->getId()) ->toArray(); $this->logger->notice( @@ -100,7 +100,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface if ($event->hasPersons()) { $involved['persons'] = array_map( - static fn(Person $p) => $p->getId(), + static fn (Person $p) => $p->getId(), $event->getPersons() ); } diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php index bbe6eed32..30c79147c 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php @@ -322,7 +322,7 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac ), ] ), - array_map(static fn(Center $c) => $c->getId(), $authorizedCenters) + array_map(static fn (Center $c) => $c->getId(), $authorizedCenters) ); } } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php index 3e2308089..6ba1ac1a9 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php @@ -97,7 +97,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi private function checkAssociatedMembersRole(Household $household, string $attribute): bool { - foreach ($household->getCurrentMembers()->map(static fn(HouseholdMember $member) => $member->getPerson()) as $person) { + foreach ($household->getCurrentMembers()->map(static fn (HouseholdMember $member) => $member->getPerson()) as $person) { if ($this->security->isGranted($attribute, $person)) { return true; } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php index bbd068fc9..bc13dec66 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php @@ -150,8 +150,8 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf $this->closingMotiveRender->renderString($period->getClosingMotive(), []) : '', 'ref' => $this->normalizer->normalize($period->getUser(), $format, $userContext), 'hasRef' => $period->getUser() !== null, - 'socialIssuesText' => implode(', ', array_map(fn(SocialIssue $s) => $this->socialIssueRender->renderString($s, []), $period->getSocialIssues()->toArray())), - 'scopesText' => implode(', ', array_map(fn(Scope $s) => $this->translatableStringHelper->localize($s->getName()), $scopes)), + 'socialIssuesText' => implode(', ', array_map(fn (SocialIssue $s) => $this->socialIssueRender->renderString($s, []), $period->getSocialIssues()->toArray())), + 'scopesText' => implode(', ', array_map(fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), $scopes)), 'hasRequestor' => $period->getRequestor() !== null, 'requestorKind' => $period->getRequestorKind(), 'hasLocation' => $period->getLocation() !== null, diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php index a6b13af4e..a0268ae31 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php @@ -48,7 +48,7 @@ class AccompanyingPeriodWorkEvaluationNormalizer implements ContextAwareNormaliz $initial = $this->normalizer->normalize($object, $format, array_merge( $context, [self::IGNORE_EVALUATION => spl_object_hash($object)], - [AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => static fn($object, $format, $context) => $object->getId()] + [AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => static fn ($object, $format, $context) => $object->getId()] )); // due to bug: https://api-platform.com/docs/core/serialization/#collection-relation diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php index 308fe3ba1..7b500e6bb 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php @@ -94,7 +94,7 @@ class PersonDocGenNormalizer implements // we simplify the list of attributes for the embedded persons AbstractNormalizer::GROUPS => ['docgen:read'], // when a person reference the same person... take care of circular references - AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => fn($object, $format, $context) => $this->normalizer->normalize(null, $format, $context), + AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => fn ($object, $format, $context) => $this->normalizer->normalize(null, $format, $context), ]); if (null === $person) { @@ -115,7 +115,7 @@ class PersonDocGenNormalizer implements 'altNames' => implode( ', ', array_map( - static fn(PersonAltName $altName) => $altName->getLabel(), + static fn (PersonAltName $altName) => $altName->getLabel(), $person->getAltNames()->toArray() ) ), diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 29570e532..2cadd0c75 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -257,7 +257,7 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar { return $altNames ->map( - static fn(PersonAltName $personAltName): array => [ + static fn (PersonAltName $personAltName): array => [ 'key' => $personAltName->getKey(), 'label' => $personAltName->getLabel(), ] diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php index 1f8994644..32b1635c4 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php @@ -37,7 +37,7 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz 'type' => 'social_issue', 'id' => $socialIssue->getId(), 'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null, - 'children_ids' => $socialIssue->getChildren()->map(static fn(SocialIssue $si) => $si->getId()), + 'children_ids' => $socialIssue->getChildren()->map(static fn (SocialIssue $si) => $si->getId()), 'title' => $socialIssue->getTitle(), 'text' => $this->render->renderString($socialIssue, []), ]; diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index ed66593c4..a42765c12 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -143,10 +143,10 @@ class AccompanyingPeriodContext implements ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('c') ->where('c.documentClass = :docClass') ->setParameter('docClass', AccompanyingCourseDocument::class), - 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', + 'choice_label' => fn ($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); } @@ -156,7 +156,7 @@ class AccompanyingPeriodContext implements public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, mixed $entity): void { $options = $template->getOptions(); - $persons = new ArrayCollection($entity->getCurrentParticipations()->map(static fn(AccompanyingPeriodParticipation $p) => $p->getPerson())->toArray()); + $persons = new ArrayCollection($entity->getCurrentParticipations()->map(static fn (AccompanyingPeriodParticipation $p) => $p->getPerson())->toArray()); foreach ($entity->getCurrentParticipations() as $p) { foreach ($p->getPerson()->getResources() as $r) { @@ -181,7 +181,7 @@ class AccompanyingPeriodContext implements $builder->add($key, EntityType::class, [ 'class' => Person::class, 'choices' => $persons, - 'choice_label' => fn(Person $p) => $this->personRender->renderString($p, ['addAge' => true]), + 'choice_label' => fn (Person $p) => $this->personRender->renderString($p, ['addAge' => true]), 'multiple' => false, 'expanded' => true, 'required' => false, diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index 325e666b9..34b339822 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -63,7 +63,7 @@ class AccompanyingPeriodWorkEvaluationContext implements $this->accompanyingPeriodWorkContext->adminFormReverseTransform($data), [ 'evaluations' => array_map( - static fn(Evaluation $e) => $e->getId(), + static fn (Evaluation $e) => $e->getId(), $data['evaluations'] ), ] @@ -76,7 +76,7 @@ class AccompanyingPeriodWorkEvaluationContext implements $this->accompanyingPeriodWorkContext->adminFormTransform($data), [ 'evaluations' => array_map( - fn($id) => $this->evaluationRepository->find($id), + fn ($id) => $this->evaluationRepository->find($id), $data['evaluations'] ?? [] ), ] @@ -93,7 +93,7 @@ class AccompanyingPeriodWorkEvaluationContext implements 'class' => Evaluation::class, 'label' => 'Linked evaluations', 'choices' => $this->evaluationRepository->findAll(), - 'choice_label' => fn(Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), + 'choice_label' => fn (Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), 'multiple' => true, 'attr' => ['class' => 'select2'], ]); diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index 8a7b7e2ba..1fdfd23d9 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -126,10 +126,10 @@ final class PersonContext implements PersonContextInterface ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('c') ->where('c.documentClass = :docClass') ->setParameter('docClass', PersonDocument::class), - 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', + 'choice_label' => fn ($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', 'required' => true, ]); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index 53d6a0a93..ac722f2f6 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -342,7 +342,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase // check that the person id is contained $participationsPersonsIds = array_map( - static fn($participation) => $participation->person->id, + static fn ($participation) => $participation->person->id, $data->participations ); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php index cb0587b5e..f01eeeaa9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -161,7 +161,7 @@ final class HouseholdApiControllerTest extends WebTestCase $this->assertArrayHasKey('count', $data); $this->assertArrayHasKey('results', $data); - $householdIds = array_map(static fn($r) => $r['id'], $data['results']); + $householdIds = array_map(static fn ($r) => $r['id'], $data['results']); $this->assertContains($expectedHouseholdId, $householdIds); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php index cf8c134ad..94b618e41 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php @@ -294,23 +294,23 @@ final class PersonControllerUpdateTest extends WebTestCase public function validTextFieldsProvider() { return [ - ['firstName', 'random Value', static fn(Person $person) => $person->getFirstName()], - ['lastName', 'random Value', static fn(Person $person) => $person->getLastName()], + ['firstName', 'random Value', static fn (Person $person) => $person->getFirstName()], + ['lastName', 'random Value', static fn (Person $person) => $person->getLastName()], // reminder: this value is capitalized - ['placeOfBirth', 'A PLACE', static fn(Person $person) => $person->getPlaceOfBirth()], - ['birthdate', '1980-12-15', static fn(Person $person) => $person->getBirthdate()->format('Y-m-d')], + ['placeOfBirth', 'A PLACE', static fn (Person $person) => $person->getPlaceOfBirth()], + ['birthdate', '1980-12-15', static fn (Person $person) => $person->getBirthdate()->format('Y-m-d')], // TODO test on phonenumber update // ['phonenumber', '+32123456789', static function (Person $person) { return $person->getPhonenumber(); }], - ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn(Person $person) => $person->getMemo()], - ['countryOfBirth', 'BE', static fn(Person $person) => $person->getCountryOfBirth()->getCountryCode()], - ['nationality', 'FR', static fn(Person $person) => $person->getNationality()->getCountryCode()], - ['placeOfBirth', '', static fn(Person $person) => $person->getPlaceOfBirth()], - ['birthdate', '', static fn(Person $person) => $person->getBirthdate()], + ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn (Person $person) => $person->getMemo()], + ['countryOfBirth', 'BE', static fn (Person $person) => $person->getCountryOfBirth()->getCountryCode()], + ['nationality', 'FR', static fn (Person $person) => $person->getNationality()->getCountryCode()], + ['placeOfBirth', '', static fn (Person $person) => $person->getPlaceOfBirth()], + ['birthdate', '', static fn (Person $person) => $person->getBirthdate()], //['phonenumber', '', static function (Person $person) { return $person->getPhonenumber(); }], - ['memo', '', static fn(Person $person) => $person->getMemo()], - ['countryOfBirth', null, static fn(Person $person) => $person->getCountryOfBirth()], - ['nationality', null, static fn(Person $person) => $person->getNationality()], - ['gender', Person::FEMALE_GENDER, static fn(Person $person) => $person->getGender()], + ['memo', '', static fn (Person $person) => $person->getMemo()], + ['countryOfBirth', null, static fn (Person $person) => $person->getCountryOfBirth()], + ['nationality', null, static fn (Person $person) => $person->getNationality()], + ['gender', Person::FEMALE_GENDER, static fn (Person $person) => $person->getGender()], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php index d9cf2241a..441358c02 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php @@ -197,12 +197,12 @@ final class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase public function validTextFieldsProvider() { return [ - ['firstName', 'random Value', static fn(Person $person) => $person->getFirstName()], - ['lastName', 'random Value', static fn(Person $person) => $person->getLastName()], - ['birthdate', '15-12-1980', static fn(Person $person) => $person->getBirthdate()->format('d-m-Y')], - ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn(Person $person) => $person->getMemo()], - ['birthdate', '', static fn(Person $person) => $person->getBirthdate()], - ['gender', Person::FEMALE_GENDER, static fn(Person $person) => $person->getGender()], + ['firstName', 'random Value', static fn (Person $person) => $person->getFirstName()], + ['lastName', 'random Value', static fn (Person $person) => $person->getLastName()], + ['birthdate', '15-12-1980', static fn (Person $person) => $person->getBirthdate()->format('d-m-Y')], + ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn (Person $person) => $person->getMemo()], + ['birthdate', '', static fn (Person $person) => $person->getBirthdate()], + ['gender', Person::FEMALE_GENDER, static fn (Person $person) => $person->getGender()], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php index 5ce35317e..0a9c22df1 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php @@ -152,7 +152,7 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase $locations = $period->getLocationHistories()->toArray(); - usort($locations, static fn(AccompanyingPeriod\AccompanyingPeriodLocationHistory $a, AccompanyingPeriod\AccompanyingPeriodLocationHistory $b) => $a->getStartDate() <=> $b->getStartDate()); + usort($locations, static fn (AccompanyingPeriod\AccompanyingPeriodLocationHistory $a, AccompanyingPeriod\AccompanyingPeriodLocationHistory $b) => $a->getStartDate() <=> $b->getStartDate()); $iterator = new ArrayIterator($locations); $iterator->rewind(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php b/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php index 55169757f..8ec7ee573 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php @@ -101,13 +101,13 @@ final class MembersEditorTest extends TestCase $editor = $factory->createEditor($household2 = new Household()); $editor->addMovement(new DateTimeImmutable('yesterday'), $person, $positionNotSharing); - $sharings = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => $m->getShareHousehold()); - $notSharing = $household2->getCurrentMembers()->filter(static fn(HouseholdMember $m) => !$m->getShareHousehold()); + $sharings = $household->getCurrentMembers()->filter(static fn (HouseholdMember $m) => $m->getShareHousehold()); + $notSharing = $household2->getCurrentMembers()->filter(static fn (HouseholdMember $m) => !$m->getShareHousehold()); $this->assertCount(1, $notSharing); $this->assertCount(1, $sharings); - $getPerson = static fn(HouseholdMember $m) => $m->getPerson(); + $getPerson = static fn (HouseholdMember $m) => $m->getPerson(); $this->assertContains($person, $notSharing->map($getPerson)); } @@ -137,13 +137,13 @@ final class MembersEditorTest extends TestCase $editor = $factory->createEditor($household); $editor->addMovement(new DateTimeImmutable('yesterday'), $person, $positionNotSharing); - $sharings = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => $m->getShareHousehold()); - $notSharing = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => !$m->getShareHousehold()); + $sharings = $household->getCurrentMembers()->filter(static fn (HouseholdMember $m) => $m->getShareHousehold()); + $notSharing = $household->getCurrentMembers()->filter(static fn (HouseholdMember $m) => !$m->getShareHousehold()); $this->assertCount(1, $notSharing); $this->assertCount(0, $sharings); - $getPerson = static fn(HouseholdMember $m) => $m->getPerson(); + $getPerson = static fn (HouseholdMember $m) => $m->getPerson(); $this->assertContains($person, $notSharing->map($getPerson)); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php index 6057a29c9..f7a05f7ce 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php @@ -318,7 +318,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase $normalizerManager = $this->prophesize(NormalizerInterface::class); $normalizerManager->supportsNormalization(Argument::any(), 'docgen', Argument::any())->willReturn(true); $normalizerManager->normalize(Argument::type(Person::class), 'docgen', Argument::any()) - ->will(static fn($args) => $normalizer->normalize($args[0], $args[1], $args[2])); + ->will(static fn ($args) => $normalizer->normalize($args[0], $args[1], $args[2])); $normalizerManager->normalize(Argument::any(), 'docgen', Argument::any())->will( static function ($args) { if (is_iterable($args[0])) { diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php index 6d841436e..6b3f49fde 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php @@ -118,7 +118,7 @@ final class RelationshipDocGenNormalizerTest extends TestCase { $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); $translatableStringHelper->localize(Argument::type('array'))->will( - static fn($args) => $args[0][array_keys($args[0])[0]] + static fn ($args) => $args[0][array_keys($args[0])[0]] ); $normalizer = new RelationshipDocGenNormalizer( @@ -128,7 +128,7 @@ final class RelationshipDocGenNormalizerTest extends TestCase $normalizerManager = $this->prophesize(NormalizerInterface::class); $normalizerManager->supportsNormalization(Argument::any(), 'docgen', Argument::any())->willReturn(true); $normalizerManager->normalize(Argument::type(Relationship::class), 'docgen', Argument::any()) - ->will(static fn($args) => $normalizer->normalize($args[0], $args[1], $args[2])); + ->will(static fn ($args) => $normalizer->normalize($args[0], $args[1], $args[2])); $normalizerManager->normalize(Argument::any(), 'docgen', Argument::any())->will( static function ($args) { if (null === $args[0]) { diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php index e84b27813..d0138dc30 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php @@ -263,7 +263,7 @@ final class PersonContextTest extends TestCase if (null === $translatableStringHelper) { $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); // return only the 'fr' key - $translatableStringHelper->localize(Argument::type('array'))->will(static fn($args) => $args[0]['fr']); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn ($args) => $args[0]['fr']); $translatableStringHelper = $translatableStringHelper->reveal(); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php index 753a9f855..70bccfda4 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php @@ -70,7 +70,7 @@ final class PersonContextWithThirdPartyTest extends KernelTestCase { $normalizer = $this->prophesize(NormalizerInterface::class); $normalizer->normalize(Argument::type(ThirdParty::class), 'docgen', Argument::type('array')) - ->will(static fn($args): array => ['class' => '3party', 'hash' => spl_object_hash($args[0])]); + ->will(static fn ($args): array => ['class' => '3party', 'hash' => spl_object_hash($args[0])]); $personContext = $this->prophesize(PersonContextInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php index cae4829f7..ed0337f1f 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php @@ -74,7 +74,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator $periodIssuesWithAncestors = array_merge( $periodIssuesWithAncestors, array_map( - static fn(SocialIssue $si) => spl_object_hash($si), + static fn (SocialIssue $si) => spl_object_hash($si), $si->getAncestors(true) ) ); diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index d957f37e3..9adae0097 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -331,7 +331,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { @@ -503,7 +503,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface private function getCustomFields() { return array_filter($this->customfieldsGroup - ->getCustomFields()->toArray(), static fn(CustomField $cf) => $cf->getType() !== 'title'); + ->getCustomFields()->toArray(), static fn (CustomField $cf) => $cf->getType() !== 'title'); } private function getLabelForCustomField($key, array $values, $data) diff --git a/src/Bundle/ChillReportBundle/Search/ReportSearch.php b/src/Bundle/ChillReportBundle/Search/ReportSearch.php index e0aaa89e1..b08e01ee5 100644 --- a/src/Bundle/ChillReportBundle/Search/ReportSearch.php +++ b/src/Bundle/ChillReportBundle/Search/ReportSearch.php @@ -97,7 +97,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface foreach ($reachableCenters as $center) { $reachableScopesId = array_map( - static fn(Scope $scope) => $scope->getId(), + static fn (Scope $scope) => $scope->getId(), $this->helper->getReachableScopes($this->user, $role, $center) ); $whereElement->add( diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php index 803ecf38f..5c25861b1 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php @@ -68,7 +68,7 @@ final class ReportControllerNextTest extends WebTestCase //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, - static fn(CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) + static fn (CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) ); $this->group = $filteredCustomFieldsGroupHouse[0]; } diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php index cd3b0f185..69ccd3d54 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php @@ -86,7 +86,7 @@ final class ReportControllerTest extends WebTestCase //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, - static fn(CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) + static fn (CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) ); self::$group = $filteredCustomFieldsGroupHouse[0]; diff --git a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php index 253616a84..95f85ed1f 100644 --- a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php @@ -67,7 +67,7 @@ final class TimelineProviderTest extends WebTestCase self::$em ->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(), - static fn(Scope $scope) => $scope->getName()['en'] === 'social' + static fn (Scope $scope) => $scope->getName()['en'] === 'social' ); $report = (new Report()) diff --git a/src/Bundle/ChillTaskBundle/Controller/TaskController.php b/src/Bundle/ChillTaskBundle/Controller/TaskController.php index 2c052619b..435c9eaa2 100644 --- a/src/Bundle/ChillTaskBundle/Controller/TaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/TaskController.php @@ -94,7 +94,7 @@ class TaskController extends AbstractController $transitionInstance = array_values( // array_values needed to reset keys (array_filter preserves keys) array_filter( $workflow->getEnabledTransitions($task), - static fn(Transition $t) => $t->getName() === $transition + static fn (Transition $t) => $t->getName() === $transition ) )[0]; diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php index ec336856e..2af71810d 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php @@ -218,9 +218,9 @@ class SingleTaskListType extends AbstractType $users = $this->getUsersAssigneedToTask($options); $choices = array_combine( // get usernames - array_map(static fn(User $user) => $user->getUsername(), $users), + array_map(static fn (User $user) => $user->getUsername(), $users), // get ids - array_map(static fn(User $user) => $user->getId(), $users) + array_map(static fn (User $user) => $user->getId(), $users) ); $choices['Unassigned'] = '_unassigned'; diff --git a/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php b/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php index 50c360610..2ff7092f0 100644 --- a/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php +++ b/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php @@ -92,7 +92,7 @@ final class SingleTaskControllerTest extends WebTestCase $center = array_filter( $centers, - static fn(Center $c) => $c->getName() === $centerName + static fn (Center $c) => $c->getName() === $centerName )[0]; $ids = $em diff --git a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php index c07fd707e..9a8fcf6bd 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php @@ -86,7 +86,7 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn ->findBy(['id' => $ids]); return array_combine( - array_map(static fn($e) => $e->getId(), $events), + array_map(static fn ($e) => $e->getId(), $events), $events ); } diff --git a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php index e6f98cef9..aa8776aa2 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php @@ -97,7 +97,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface ->findBy(['id' => $ids]); return array_combine( - array_map(static fn($e) => $e->getId(), $events), + array_map(static fn ($e) => $e->getId(), $events), $events ); } diff --git a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php index 8250f7bf0..e813cbd7f 100644 --- a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php @@ -69,7 +69,7 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface private function getCenters(): Iterator { $references = array_map( - static fn($a) => $a['ref'], + static fn ($a) => $a['ref'], LoadCenters::$centers ); $number = random_int(1, count($references)); diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php index 01309a37e..0dd4f16e6 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php @@ -103,8 +103,8 @@ class PickThirdPartyType extends AbstractType $resolver ->setDefault('class', ThirdParty::class) - ->setDefault('choice_label', static fn(ThirdParty $tp) => $tp->getName()) - ->setDefault('choice_loader', fn(Options $options) => new ThirdPartyChoiceLoader( + ->setDefault('choice_label', static fn (ThirdParty $tp) => $tp->getName()) + ->setDefault('choice_loader', fn (Options $options) => new ThirdPartyChoiceLoader( $options['center'], $this->em->getRepository(ThirdParty::class) )); diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php index 6bc83f0f2..26cb0ae2e 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php @@ -77,7 +77,7 @@ class PickThirdPartyTypeCategoryType extends \Symfony\Component\Form\AbstractTyp return self::PREFIX_TYPE . $item; }, - 'choice_value' => fn($item) => $this->reverseTransform($item), + 'choice_value' => fn ($item) => $this->reverseTransform($item), ]); } From 25c033be6176369c6737c579092bdf1df0502b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:47:06 +0200 Subject: [PATCH 10/43] DX: apply rector rules --- src/Bundle/ChillMainBundle/Search/SearchProvider.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index 7ebb5ed87..095b749bc 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -113,9 +113,7 @@ class SearchProvider public function getHasAdvancedFormSearchServices() { //sort the array - uasort($this->hasAdvancedFormSearchServices, static function (HasAdvancedSearchFormInterface $a, HasAdvancedSearchFormInterface $b): int { - return $a->getOrder() <=> $b->getOrder(); - }); + uasort($this->hasAdvancedFormSearchServices, static fn (HasAdvancedSearchFormInterface $a, HasAdvancedSearchFormInterface $b): int => $a->getOrder() <=> $b->getOrder()); return $this->hasAdvancedFormSearchServices; } From b69fb740b1c94956ed6bf12406bb9b6c616c6814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 18 Apr 2023 11:36:46 +0200 Subject: [PATCH 11/43] Fix: make geographical units valid during imports --- .../Service/Import/GeographicalUnitBaseImporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php b/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php index 99f919406..1ec6b70de 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php +++ b/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php @@ -207,7 +207,7 @@ final class GeographicalUnitBaseImporter (id, geom, unitname, layer_id, unitrefid) SELECT nextval('chill_main_geographical_unit_id_seq'), - geom, + st_makevalid(geom), unitName, layer.id, unitKey From a59e84b029442abac632559f13272a5fb96f5892 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 20 Apr 2023 14:54:36 +0200 Subject: [PATCH 12/43] Display too draft periods without creator in periods of a person --- .../Repository/AccompanyingPeriodACLAwareRepository.php | 3 ++- .../views/AccompanyingPeriod/user_draft_periods_list.html.twig | 1 + src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index e28832bf9..9327172ac 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -174,7 +174,8 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC ->andWhere( $qb->expr()->orX( $qb->expr()->neq('ap.step', ':draft'), - $qb->expr()->eq('ap.createdBy', ':creator') + $qb->expr()->orX($qb->expr()->eq('ap.createdBy', ':creator'), + $qb->expr()->isNull('ap.createdBy')) ) ) ->setParameter('draft', AccompanyingPeriod::STEP_DRAFT) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_draft_periods_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_draft_periods_list.html.twig index d7bd8eea6..ef38ee7b9 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_draft_periods_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_draft_periods_list.html.twig @@ -22,6 +22,7 @@

{{ 'My accompanying periods in draft'|trans }}

+

{{ 'Display draft periods created by me'|trans }}

{% for period in accompanyingPeriods %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 18e3ab13f..01634bb21 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -966,6 +966,7 @@ Linked evaluations: Évaluations associées # Accompanying period per user My accompanying periods: Mes parcours My accompanying periods in draft: Mes parcours brouillons +Display draft periods created by me: Affiche les parcours brouillon que j'ai créé (pas ceux dont je suis référent) Number of periods: Nombre de parcours workflow: From dde35be9c3cd29eca96ddc917f20f3300cfe7c66 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 20 Apr 2023 18:05:39 +0200 Subject: [PATCH 13/43] hide pagination if no periods --- .../AccompanyingPeriod/user_draft_periods_list.html.twig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_draft_periods_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_draft_periods_list.html.twig index ef38ee7b9..60f6ae9e0 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_draft_periods_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_draft_periods_list.html.twig @@ -32,7 +32,9 @@ {% endfor %}
- {{ chill_pagination(pagination) }} + {% if accompanyingPeriods|length > 0 %} + {{ chill_pagination(pagination) }} + {% endif %}
From 631d65a57ff28d5fedabd5d5819a58e3c15f31c2 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 20 Apr 2023 18:09:25 +0200 Subject: [PATCH 14/43] improve indentation --- .../Repository/AccompanyingPeriodACLAwareRepository.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 9327172ac..0aaabd05f 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -174,8 +174,10 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC ->andWhere( $qb->expr()->orX( $qb->expr()->neq('ap.step', ':draft'), - $qb->expr()->orX($qb->expr()->eq('ap.createdBy', ':creator'), - $qb->expr()->isNull('ap.createdBy')) + $qb->expr()->orX( + $qb->expr()->eq('ap.createdBy', ':creator'), + $qb->expr()->isNull('ap.createdBy') + ) ) ) ->setParameter('draft', AccompanyingPeriod::STEP_DRAFT) From 7cb7897e1223095cbff702ad9662c5cf1d21a566 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 21 Apr 2023 18:05:29 +0200 Subject: [PATCH 15/43] Align address detail button style with banner context buttons --- .../AddressDetails/AddressDetailsButton.vue | 4 +-- .../Resources/public/chill/chillperson.scss | 36 +++++++++++++------ .../Resources/views/Person/banner.html.twig | 5 +-- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/AddressDetailsButton.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/AddressDetailsButton.vue index 7e060de4c..2bca56379 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/AddressDetailsButton.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/AddressDetailsButton.vue @@ -1,7 +1,7 @@