From 91d12c4a962bd72ee518daa09d9540893682158b Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 30 Nov 2021 11:43:34 +0100 Subject: [PATCH] cs: Enable risky rule `static_lambda`. --- .php_cs.dist.php | 2 +- .../_static/code/exports/CountPerson.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../Export/Export/ListActivity.php | 4 +-- .../ChillActivityBundle/Form/ActivityType.php | 18 +++++------ .../Form/Type/TranslatableActivityReason.php | 2 +- .../TranslatableActivityReasonCategory.php | 2 +- .../Repository/ActivityACLAwareRepository.php | 2 +- .../Controller/ActivityControllerTest.php | 4 +-- .../Tests/Form/ActivityTypeTest.php | 2 +- .../Type/TranslatableActivityReasonTest.php | 2 +- .../src/DependencyInjection/Configuration.php | 2 +- .../src/Form/AsideActivityFormType.php | 6 ++-- .../ChillCalendarBundle/Form/CalendarType.php | 20 ++++++------- .../Command/CreateFieldsOnGroupCommand.php | 4 +-- .../CustomFields/CustomFieldDate.php | 6 ++-- .../CustomFields/CustomFieldLongChoice.php | 4 +-- .../OptionRepository.php | 2 +- .../Form/CustomFieldType.php | 2 +- .../Form/CustomFieldsGroupType.php | 2 +- .../JsonCustomFieldToArrayTransformer.php | 2 +- .../Form/Type/ChoicesListType.php | 2 +- .../Normalizer/DocGenObjectNormalizer.php | 2 +- .../Form/AccompanyingCourseDocumentType.php | 2 +- .../Form/PersonDocumentType.php | 2 +- .../Controller/EventController.php | 2 +- .../Controller/ParticipationController.php | 6 ++-- src/Bundle/ChillEventBundle/Entity/Event.php | 2 +- .../Form/ChoiceLoader/EventChoiceLoader.php | 2 +- .../Form/Type/PickEventType.php | 8 ++--- .../Form/Type/PickEventTypeType.php | 6 ++-- .../Form/Type/PickRoleType.php | 4 +-- .../Form/Type/PickStatusType.php | 4 +-- .../ParticipationControllerTest.php | 8 ++--- .../Tests/Search/EventSearchTest.php | 2 +- .../Timeline/TimelineEventProvider.php | 2 +- .../CRUD/Routing/CRUDRoutesLoader.php | 2 +- .../Command/ChillImportUsersCommand.php | 2 +- .../Controller/PermissionsGroupController.php | 10 +++---- .../Controller/UserController.php | 2 +- .../CompilerPass/MenuCompilerPass.php | 2 +- .../Entity/PermissionsGroup.php | 2 +- .../Export/Formatter/CSVFormatter.php | 4 +-- .../Export/Formatter/CSVListFormatter.php | 2 +- .../Formatter/CSVPivotedListFormatter.php | 2 +- .../Formatter/SpreadsheetListFormatter.php | 2 +- .../ChoiceLoader/PostalCodeChoiceLoader.php | 2 +- .../ChillMainBundle/Form/LocationFormType.php | 2 +- .../Form/Type/AppendScopeChoiceTypeTrait.php | 2 +- .../Form/Type/ComposedGroupCenterType.php | 4 +-- .../Form/Type/ComposedRoleScopeType.php | 4 +-- .../Form/Type/DateIntervalType.php | 2 +- .../Form/Type/Export/PickCenterType.php | 6 ++-- .../Form/Type/Listing/FilterOrderType.php | 2 +- .../Form/Type/PickCenterType.php | 4 +-- .../Form/Type/PostalCodeType.php | 2 +- .../Form/Type/ScopePickerType.php | 2 +- .../Form/Type/UserPickerType.php | 2 +- src/Bundle/ChillMainBundle/Form/UserType.php | 2 +- .../Search/Entity/SearchUserApiProvider.php | 2 +- .../ChillMainBundle/Search/SearchApi.php | 2 +- .../ChillMainBundle/Search/SearchProvider.php | 4 +-- .../Tests/Export/ExportManagerTest.php | 6 ++-- .../Utils/ExtractDateFromPatternTest.php | 2 +- .../Authorization/AuthorizationHelperTest.php | 2 +- .../Tests/Util/DateRangeCoveringTest.php | 2 +- .../ChillMainBundle/Util/CountriesInfo.php | 2 +- .../Command/ImportPeopleFromCSVCommand.php | 6 ++-- .../AccompanyingPeriodController.php | 2 +- .../Controller/HouseholdApiController.php | 2 +- .../Controller/PersonApiController.php | 2 +- .../DataFixtures/ORM/LoadCustomFields.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../Entity/AccompanyingPeriod.php | 4 +-- .../Entity/Household/Household.php | 10 +++---- .../ChillPersonBundle/Entity/Person.php | 4 +-- .../Aggregator/CountryOfBirthAggregator.php | 2 +- .../Aggregator/NationalityAggregator.php | 2 +- .../Export/Export/CountPerson.php | 4 +-- .../Export/Export/ListPerson.php | 4 +-- .../Export/Filter/GenderFilter.php | 2 +- .../Form/ChoiceLoader/PersonChoiceLoader.php | 2 +- .../ChillPersonBundle/Form/PersonType.php | 8 ++--- .../Form/Type/PickPersonType.php | 8 ++--- .../Privacy/PrivacyEventSubscriber.php | 4 +-- .../Repository/PersonACLAwareRepository.php | 2 +- .../ChillPersonBundle/Search/PersonSearch.php | 2 +- .../Search/SearchPersonApiProvider.php | 2 +- .../AccompanyingPeriodWorkDenormalizer.php | 2 +- .../Normalizer/PersonDocGenNormalizer.php | 2 +- .../Normalizer/SocialIssueNormalizer.php | 2 +- .../AccompanyingCourseApiControllerTest.php | 2 +- .../Controller/HouseholdApiControllerTest.php | 2 +- .../Controller/PersonControllerUpdateTest.php | 30 +++++++++---------- ...onControllerUpdateWithHiddenFieldsTest.php | 12 ++++---- .../Person/PersonHasCenterValidatorTest.php | 2 +- .../Export/Export/ReportList.php | 16 +++++----- .../ChillReportBundle/Search/ReportSearch.php | 2 +- .../Controller/ReportControllerNextTest.php | 2 +- .../Tests/Controller/ReportControllerTest.php | 2 +- .../Tests/Timeline/TimelineProviderTest.php | 2 +- .../Controller/SingleTaskController.php | 8 ++--- .../Controller/TaskController.php | 2 +- .../Form/SingleTaskListType.php | 4 +-- .../Controller/SingleTaskControllerTest.php | 2 +- ...TaskTaskLifeCycleEventTimelineProvider.php | 2 +- .../TaskLifeCycleEventTimelineProvider.php | 2 +- .../DataFixtures/ORM/LoadThirdParty.php | 2 +- .../Entity/ThirdParty.php | 8 ++--- .../Form/ThirdPartyType.php | 4 +-- .../Form/Type/PickThirdPartyType.php | 2 +- 111 files changed, 212 insertions(+), 212 deletions(-) diff --git a/.php_cs.dist.php b/.php_cs.dist.php index 162fea55c..e9c6bdb36 100644 --- a/.php_cs.dist.php +++ b/.php_cs.dist.php @@ -63,7 +63,7 @@ $riskyRules = [ 'php_unit_mock' => false, 'php_unit_namespaced' => false, 'random_api_migration' => false, - 'static_lambda' => false, + // 'static_lambda' => false, 'php_unit_construct' => false, // 'psr_autoloading' => false, 'php_unit_dedicate_assert' => false, diff --git a/docs/source/_static/code/exports/CountPerson.php b/docs/source/_static/code/exports/CountPerson.php index 5ea9d6214..343108898 100644 --- a/docs/source/_static/code/exports/CountPerson.php +++ b/docs/source/_static/code/exports/CountPerson.php @@ -89,7 +89,7 @@ class CountPerson implements ExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { // we gather all center the user choose. - $centers = array_map(function ($el) { return $el['center']; }, $acl); + $centers = array_map(static function ($el) { return $el['center']; }, $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php index 037a51c6a..ad9bbac76 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php @@ -56,7 +56,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(function ($data) { + ->ifTrue(static function ($data) { return !is_int($data); })->thenInvalid('The value %s is not a valid integer') ->end() diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php index a3282d534..2dca1b220 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php @@ -75,7 +75,7 @@ class ListActivity implements ListInterface 'choices' => array_combine($this->fields, $this->fields), 'label' => 'Fields to include in export', 'constraints' => [new Callback([ - 'callback' => function ($selected, ExecutionContextInterface $context) { + 'callback' => static function ($selected, ExecutionContextInterface $context) { if (count($selected) === 0) { $context->buildViolation('You must select at least one element') ->atPath('fields') @@ -189,7 +189,7 @@ class ListActivity implements ListInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(function ($el) { return $el['center']; }, $acl); + $centers = array_map(static function ($el) { return $el['center']; }, $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index cd60b5879..9846c9a7d 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -125,7 +125,7 @@ class ActivityType extends AbstractType $builder->add('socialIssues', HiddenType::class); $builder->get('socialIssues') ->addModelTransformer(new CallbackTransformer( - function (iterable $socialIssuesAsIterable): string { + static function (iterable $socialIssuesAsIterable): string { $socialIssueIds = []; foreach ($socialIssuesAsIterable as $value) { @@ -151,7 +151,7 @@ class ActivityType extends AbstractType $builder->add('socialActions', HiddenType::class); $builder->get('socialActions') ->addModelTransformer(new CallbackTransformer( - function (iterable $socialActionsAsIterable): string { + static function (iterable $socialActionsAsIterable): string { $socialActionIds = []; foreach ($socialActionsAsIterable as $value) { @@ -203,7 +203,7 @@ class ActivityType extends AbstractType 'choice_label' => function (ActivityPresence $activityPresence) { return $this->translatableStringHelper->localize($activityPresence->getName()); }, - 'query_builder' => function (EntityRepository $er) { + 'query_builder' => static function (EntityRepository $er) { return $er->createQueryBuilder('a') ->where('a.active = true'); }, @@ -229,7 +229,7 @@ class ActivityType extends AbstractType return $this->translatableStringHelper->localize($activityReason->getName()); }, 'attr' => ['class' => 'select2 '], - 'query_builder' => function (EntityRepository $er) { + 'query_builder' => static function (EntityRepository $er) { return $er->createQueryBuilder('a') ->where('a.active = true'); }, @@ -248,7 +248,7 @@ class ActivityType extends AbstractType $builder->add('persons', HiddenType::class); $builder->get('persons') ->addModelTransformer(new CallbackTransformer( - function (iterable $personsAsIterable): string { + static function (iterable $personsAsIterable): string { $personIds = []; foreach ($personsAsIterable as $value) { @@ -270,7 +270,7 @@ class ActivityType extends AbstractType $builder->add('thirdParties', HiddenType::class); $builder->get('thirdParties') ->addModelTransformer(new CallbackTransformer( - function (iterable $thirdpartyAsIterable): string { + static function (iterable $thirdpartyAsIterable): string { $thirdpartyIds = []; foreach ($thirdpartyAsIterable as $value) { @@ -303,7 +303,7 @@ class ActivityType extends AbstractType $builder->add('users', HiddenType::class); $builder->get('users') ->addModelTransformer(new CallbackTransformer( - function (iterable $usersAsIterable): string { + static function (iterable $usersAsIterable): string { $userIds = []; foreach ($usersAsIterable as $value) { @@ -325,7 +325,7 @@ class ActivityType extends AbstractType $builder->add('location', HiddenType::class) ->get('location') ->addModelTransformer(new CallbackTransformer( - function (?Location $location): string { + static function (?Location $location): string { if (null === $location) { return ''; } @@ -365,7 +365,7 @@ class ActivityType extends AbstractType ->addModelTransformer($durationTimeTransformer); $builder->get($fieldName) - ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $formEvent) use ( + ->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $formEvent) use ( $timeChoices, $builder, $durationTimeTransformer, diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReason.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReason.php index 867c74b10..65350c84c 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReason.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReason.php @@ -55,7 +55,7 @@ class TranslatableActivityReason extends AbstractType return null; }, - 'query_builder' => function (EntityRepository $er) { + 'query_builder' => static function (EntityRepository $er) { return $er->createQueryBuilder('r') ->where('r.active = true'); }, diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategory.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategory.php index b0b064927..79611e425 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategory.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategory.php @@ -37,7 +37,7 @@ class TranslatableActivityReasonCategory extends AbstractType [ 'class' => 'ChillActivityBundle:ActivityReasonCategory', 'choice_label' => 'name[' . $locale . ']', - 'query_builder' => function (EntityRepository $er) { + 'query_builder' => static function (EntityRepository $er) { return $er->createQueryBuilder('c') ->where('c.active = true'); }, diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php index 84763c491..2c92f9e85 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php @@ -167,7 +167,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte $reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center); // we get the ids for those scopes $reachablesScopesId = array_map( - function (Scope $scope) { return $scope->getId(); }, + static function (Scope $scope) { return $scope->getId(); }, $reachableScopes ); diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php index d28012ce4..728a76c26 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php @@ -366,8 +366,8 @@ class ActivityControllerTest extends WebTestCase $center ); $reachableScopesId = array_intersect( - array_map(function ($s) { return $s->getId(); }, $reachableScopesDelete), - array_map(function ($s) { return $s->getId(); }, $reachableScopesUpdate) + array_map(static function ($s) { return $s->getId(); }, $reachableScopesDelete), + array_map(static function ($s) { return $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 2e6d97ea9..6cd46ccbe 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php @@ -186,7 +186,7 @@ class ActivityTypeTest extends KernelTestCase // map all the values in an array $values = array_map( - function ($choice) { return $choice->value; }, + static function ($choice) { return $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 5c7ace286..8e83f5a1d 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php @@ -81,7 +81,7 @@ class TranslatableActivityReasonTest extends TypeTestCase $request->getLocale()->willReturn($fallbackLocale); $requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack'); - $requestStack->getCurrentRequest()->will(function () use ($request) { + $requestStack->getCurrentRequest()->will(static function () use ($request) { return $request; }); diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php index 000a9ad87..599331ab7 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php @@ -125,7 +125,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(function ($data) { + ->ifTrue(static function ($data) { return !is_int($data); })->thenInvalid('The value %s is not a valid integer') ->end() diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php index 05ab3c4be..c5551991c 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php @@ -73,7 +73,7 @@ final class AsideActivityFormType extends AbstractType 'required' => true, 'class' => User::class, 'data' => $this->storage->getToken()->getUser(), - 'query_builder' => function (EntityRepository $er) { + 'query_builder' => static function (EntityRepository $er) { return $er->createQueryBuilder('u')->where('u.enabled = true'); }, 'attr' => ['class' => 'select2 '], @@ -98,7 +98,7 @@ final class AsideActivityFormType extends AbstractType 'required' => true, 'class' => AsideActivityCategory::class, 'placeholder' => 'Choose the activity category', - 'query_builder' => function (EntityRepository $er) { + 'query_builder' => static function (EntityRepository $er) { $qb = $er->createQueryBuilder('ac'); $qb->where($qb->expr()->eq('ac.isActive', 'TRUE')) ->addOrderBy('ac.ordering', 'ASC'); @@ -123,7 +123,7 @@ final class AsideActivityFormType extends AbstractType ->addModelTransformer($durationTimeTransformer); $builder->get($fieldName) - ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $formEvent) use ( + ->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $formEvent) use ( $timeChoices, $builder, $durationTimeTransformer, diff --git a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php index 1ed91894e..a54dfc200 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php @@ -69,7 +69,7 @@ class CalendarType extends AbstractType $builder->add('mainUser', HiddenType::class); $builder->get('mainUser') ->addModelTransformer(new CallbackTransformer( - function (?User $user): int { + static function (?User $user): int { if (null !== $user) { $res = $user->getId(); } else { @@ -86,7 +86,7 @@ class CalendarType extends AbstractType $builder->add('startDate', HiddenType::class); $builder->get('startDate') ->addModelTransformer(new CallbackTransformer( - function (?DateTimeImmutable $dateTimeImmutable): string { + static function (?DateTimeImmutable $dateTimeImmutable): string { if (null !== $dateTimeImmutable) { $res = date_format($dateTimeImmutable, 'Y-m-d H:i:s'); } else { @@ -95,7 +95,7 @@ class CalendarType extends AbstractType return $res; }, - function (?string $dateAsString): DateTimeImmutable { + static function (?string $dateAsString): DateTimeImmutable { dump($dateAsString); return new DateTimeImmutable($dateAsString); @@ -105,7 +105,7 @@ class CalendarType extends AbstractType $builder->add('endDate', HiddenType::class); $builder->get('endDate') ->addModelTransformer(new CallbackTransformer( - function (?DateTimeImmutable $dateTimeImmutable): string { + static function (?DateTimeImmutable $dateTimeImmutable): string { if (null !== $dateTimeImmutable) { $res = date_format($dateTimeImmutable, 'Y-m-d H:i:s'); } else { @@ -114,7 +114,7 @@ class CalendarType extends AbstractType return $res; }, - function (?string $dateAsString): DateTimeImmutable { + static function (?string $dateAsString): DateTimeImmutable { return new DateTimeImmutable($dateAsString); } )); @@ -122,7 +122,7 @@ class CalendarType extends AbstractType $builder->add('persons', HiddenType::class); $builder->get('persons') ->addModelTransformer(new CallbackTransformer( - function (iterable $personsAsIterable): string { + static function (iterable $personsAsIterable): string { $personIds = []; foreach ($personsAsIterable as $value) { @@ -142,7 +142,7 @@ class CalendarType extends AbstractType $builder->add('professionals', HiddenType::class); $builder->get('professionals') ->addModelTransformer(new CallbackTransformer( - function (iterable $thirdpartyAsIterable): string { + static function (iterable $thirdpartyAsIterable): string { $thirdpartyIds = []; foreach ($thirdpartyAsIterable as $value) { @@ -162,7 +162,7 @@ class CalendarType extends AbstractType $builder->add('calendarRange', HiddenType::class); $builder->get('calendarRange') ->addModelTransformer(new CallbackTransformer( - function (?CalendarRange $calendarRange): ?int { + static function (?CalendarRange $calendarRange): ?int { if (null !== $calendarRange) { $res = $calendarRange->getId(); } else { @@ -185,7 +185,7 @@ class CalendarType extends AbstractType $builder->add('location', HiddenType::class) ->get('location') ->addModelTransformer(new CallbackTransformer( - function (?Location $location): string { + static function (?Location $location): string { if (null === $location) { return ''; } @@ -200,7 +200,7 @@ class CalendarType extends AbstractType $builder->add('invites', HiddenType::class); $builder->get('invites') ->addModelTransformer(new CallbackTransformer( - function (iterable $usersAsIterable): string { + static function (iterable $usersAsIterable): string { $userIds = []; foreach ($usersAsIterable as $value) { diff --git a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php index a15f74efb..bb88b30f1 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php +++ b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php @@ -137,7 +137,7 @@ class CreateFieldsOnGroupCommand extends Command "Enter the customfieldGroup's id on which the custom fields should be added: " ); $question->setNormalizer( - function ($answer) use ($customFieldsGroups) { + static function ($answer) use ($customFieldsGroups) { foreach ($customFieldsGroups as $customFieldsGroup) { if ($customFieldsGroup->getId() == $answer) { return $customFieldsGroup; @@ -237,7 +237,7 @@ class CreateFieldsOnGroupCommand extends Command array_walk( $customFieldsGroups, - function (CustomFieldsGroup $customFieldGroup, $key) use ($languages, &$rows, $customizableEntities) { + static function (CustomFieldsGroup $customFieldGroup, $key) use ($languages, &$rows, $customizableEntities) { //set id and entity $row = [ $customFieldGroup->getId(), diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php index 10842c43b..d6a98f62f 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php @@ -77,7 +77,7 @@ class CustomFieldDate extends AbstractCustomField public function buildOptionsForm(FormBuilderInterface $builder) { - $validatorFunction = function ($value, ExecutionContextInterface $context) { + $validatorFunction = static function ($value, ExecutionContextInterface $context) { try { $date = new DateTime($value); } catch (Exception $e) { @@ -179,7 +179,7 @@ class CustomFieldDate extends AbstractCustomField // add constraints if required if (null !== $options[self::MIN]) { $fieldOptions['constraints'][] = new Callback( - function ($timestamp, ExecutionContextInterface $context) use ($options) { + static function ($timestamp, ExecutionContextInterface $context) use ($options) { if (null === $timestamp) { return; } @@ -200,7 +200,7 @@ class CustomFieldDate extends AbstractCustomField if (null !== $options[self::MAX]) { $fieldOptions['constraints'][] = new Callback( - function ($timestamp, ExecutionContextInterface $context) use ($options) { + static function ($timestamp, ExecutionContextInterface $context) use ($options) { if (null === $timestamp) { return; } diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php index 2a5d5d7ee..311df8fad 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php @@ -57,7 +57,7 @@ class CustomFieldLongChoice extends AbstractCustomField $translatableStringHelper = $this->translatableStringHelper; $builder->add($customField->getSlug(), Select2ChoiceType::class, [ 'choices' => $entries, - 'choice_label' => function (Option $option) use ($translatableStringHelper) { + 'choice_label' => static function (Option $option) use ($translatableStringHelper) { return $translatableStringHelper->localize($option->getText()); }, 'choice_value' => static fn (Option $key): ?int => null === $key ? null : $key->getId(), @@ -65,7 +65,7 @@ class CustomFieldLongChoice extends AbstractCustomField 'expanded' => false, 'required' => $customField->isRequired(), 'placeholder' => 'Choose a value', - 'group_by' => function (Option $option) use ($translatableStringHelper) { + 'group_by' => static function (Option $option) use ($translatableStringHelper) { if ($option->hasParent()) { return $translatableStringHelper->localize($option->getParent()->getText()); } diff --git a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php index 134417df6..8e9fd181e 100644 --- a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php +++ b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php @@ -55,7 +55,7 @@ class OptionRepository extends EntityRepository ->getQuery() ->getScalarResult(); - return array_map(function ($r) { + return array_map(static function ($r) { return $r['key']; }, $keys); } diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php index 6e35b33fe..29e249493 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php @@ -88,7 +88,7 @@ class CustomFieldType extends AbstractType 'label' => 'Required field', ]) ->add('type', HiddenType::class, ['data' => $options['type']]) - ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { + ->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $event) { $customField = $event->getData(); $form = $event->getForm(); diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php index ba0192138..e0f7d1410 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php @@ -55,7 +55,7 @@ class CustomFieldsGroupType extends AbstractType $builder->addEventListener( FormEvents::POST_SET_DATA, - function (FormEvent $event) use ($customizableEntities, $builder) { + static function (FormEvent $event) use ($customizableEntities, $builder) { $form = $event->getForm(); $group = $event->getData(); diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php index dd0e32da2..86ac35cee 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php @@ -32,7 +32,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface // @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here? $customFieldsLablels = array_map( - function ($e) { return $e->getLabel(); }, + static function ($e) { return $e->getLabel(); }, $customFields ); diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php b/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php index 7fd4da821..b3ec7f890 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php @@ -30,7 +30,7 @@ class ChoicesListType extends AbstractType 'required' => false, ]) ->add('slug', HiddenType::class) - ->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) { + ->addEventListener(FormEvents::SUBMIT, static function (FormEvent $event) { $form = $event->getForm(); $data = $event->getData(); diff --git a/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php b/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php index b46296550..8da8a6a7b 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php +++ b/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php @@ -59,7 +59,7 @@ class DocGenObjectNormalizer implements NormalizerInterface, NormalizerAwareInte : []; $attributes = array_filter( $metadata->getAttributesMetadata(), - function (AttributeMetadata $a) use ($expectedGroups) { + static function (AttributeMetadata $a) use ($expectedGroups) { foreach ($a->getGroups() as $g) { if (in_array($g, $expectedGroups, true)) { return true; diff --git a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php index aae7c5435..6f03e241a 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php @@ -69,7 +69,7 @@ class AccompanyingCourseDocumentType extends AbstractType ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => 'ChillDocStoreBundle:DocumentCategory', - 'query_builder' => function (EntityRepository $er) { + 'query_builder' => static function (EntityRepository $er) { return $er->createQueryBuilder('c') ->where('c.documentClass = :docClass') ->setParameter('docClass', PersonDocument::class); diff --git a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php index fbd87402c..d41003898 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php @@ -73,7 +73,7 @@ class PersonDocumentType extends AbstractType ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => 'ChillDocStoreBundle:DocumentCategory', - 'query_builder' => function (EntityRepository $er) { + 'query_builder' => static function (EntityRepository $er) { return $er->createQueryBuilder('c') ->where('c.documentClass = :docClass') ->setParameter('docClass', PersonDocument::class); diff --git a/src/Bundle/ChillEventBundle/Controller/EventController.php b/src/Bundle/ChillEventBundle/Controller/EventController.php index 2ea1f58d1..549b5ebac 100644 --- a/src/Bundle/ChillEventBundle/Controller/EventController.php +++ b/src/Bundle/ChillEventBundle/Controller/EventController.php @@ -599,7 +599,7 @@ class EventController extends AbstractController $response->setPrivate(); $response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('must-revalidate', true); - $response->setCallback(function () use ($writer) { + $response->setCallback(static function () use ($writer) { $writer->save('php://output'); }); diff --git a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php index 9941a0ec5..65406e969 100644 --- a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php +++ b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php @@ -110,7 +110,7 @@ class ParticipationController extends AbstractController [ 'event_id' => current($participations)->getEvent()->getId(), 'persons_ids' => implode(',', array_map( - function (Participation $p) { return $p->getPerson()->getId(); }, + static function (Participation $p) { return $p->getPerson()->getId(); }, $participations )), ] @@ -646,13 +646,13 @@ class ParticipationController extends AbstractController /** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */ $peopleParticipating = $peopleParticipating ?? $participation->getEvent()->getParticipations()->map( - function (Participation $p) { return $p->getPerson()->getId(); } + static function (Participation $p) { return $p->getPerson()->getId(); } ); // check that the user is not already in the event if ($peopleParticipating->contains($participation->getPerson()->getId())) { $ignoredParticipations[] = $participation ->getEvent()->getParticipations()->filter( - function (Participation $p) use ($participation) { + static function (Participation $p) use ($participation) { return $p->getPerson()->getId() === $participation->getPerson()->getId(); } )->first(); diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index 639d4f99e..fcf285fd4 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -174,7 +174,7 @@ class Event implements HasCenterInterface, HasScopeInterface { $iterator = $this->participations->getIterator(); - $iterator->uasort(function ($first, $second) { + $iterator->uasort(static function ($first, $second) { return strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName()); }); diff --git a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php index 0e172feb0..c2aaf6de9 100644 --- a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php +++ b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php @@ -59,7 +59,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedEvents, - function (Event $p) use ($value) { + static function (Event $p) use ($value) { return call_user_func($value, $p); } ); diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php index 27210b91e..5a5ab19af 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php @@ -106,14 +106,14 @@ class PickEventType extends AbstractType // add the default options $resolver->setDefaults([ 'class' => Event::class, - 'choice_label' => function (Event $e) { + '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(); }, 'placeholder' => 'Pick an event', 'attr' => ['class' => 'select2 '], - 'choice_attr' => function (Event $e) { + 'choice_attr' => static function (Event $e) { return ['data-center' => $e->getCenter()->getId()]; }, 'choiceloader' => function (Options $options) { @@ -140,7 +140,7 @@ class PickEventType extends AbstractType // option role if (null === $options['role']) { $centers = array_map( - function (GroupCenter $g) { + static function (GroupCenter $g) { return $g->getCenter(); }, $this->user->getGroupCenters()->toArray() @@ -169,7 +169,7 @@ class PickEventType extends AbstractType } if (!in_array($c->getId(), array_map( - function (Center $c) { return $c->getId(); }, + static function (Center $c) { return $c->getId(); }, $centers ))) { throw new AccessDeniedException('The given center is not reachable'); diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php index 0511497ec..66c57a78a 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php @@ -37,14 +37,14 @@ class PickEventTypeType extends AbstractType $resolver->setDefaults( [ 'class' => EventType::class, - 'query_builder' => function (EntityRepository $er) { + 'query_builder' => static function (EntityRepository $er) { return $er->createQueryBuilder('et') ->where('et.active = true'); }, - 'choice_label' => function (EventType $t) use ($helper) { + 'choice_label' => static function (EventType $t) use ($helper) { return $helper->localize($t->getName()); }, - 'choice_attrs' => function (EventType $t) { + 'choice_attrs' => static function (EventType $t) { return ['data-link-category' => $t->getId()]; }, ] diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php b/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php index 56da2cb40..7c8dc773a 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php @@ -109,13 +109,13 @@ class PickRoleType extends AbstractType 'class' => Role::class, 'query_builder' => $qb, 'group_by' => null, - 'choice_attr' => function (Role $r) { + 'choice_attr' => static function (Role $r) { return [ 'data-event-type' => $r->getType()->getId(), 'data-link-category' => $r->getType()->getId(), ]; }, - 'choice_label' => function (Role $r) use ($translatableStringHelper, $translator) { + 'choice_label' => static function (Role $r) use ($translatableStringHelper, $translator) { return $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 f554943b2..026569119 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php @@ -110,13 +110,13 @@ class PickStatusType extends AbstractType 'class' => Status::class, 'query_builder' => $qb, 'group_by' => null, - 'choice_attr' => function (Status $s) { + 'choice_attr' => static function (Status $s) { return [ 'data-event-type' => $s->getType()->getId(), 'data-link-category' => $s->getType()->getId(), ]; }, - 'choice_label' => function (Status $s) use ($translatableStringHelper, $translator) { + 'choice_label' => static function (Status $s) use ($translatableStringHelper, $translator) { return $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 99bc2fbe3..2fcad7fee 100644 --- a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php @@ -237,7 +237,7 @@ class ParticipationControllerTest extends WebTestCase $this->personsIdsCache = array_merge( $this->personsIdsCache, $event->getParticipations()->map( - function ($p) { return $p->getPerson()->getId(); } + static function ($p) { return $p->getPerson()->getId(); } ) ->toArray() ); @@ -301,7 +301,7 @@ class ParticipationControllerTest extends WebTestCase $event = $this->getRandomEventWithMultipleParticipations(); $persons_id = implode(',', $event->getParticipations()->map( - function ($p) { return $p->getPerson()->getId(); } + static function ($p) { return $p->getPerson()->getId(); } )->toArray()); $crawler = $this->client->request( @@ -327,7 +327,7 @@ class ParticipationControllerTest extends WebTestCase $nbParticipations = $event->getParticipations()->count(); // get the persons_id participating on this event $persons_id = $event->getParticipations()->map( - function ($p) { return $p->getPerson()->getId(); } + static function ($p) { return $p->getPerson()->getId(); } )->toArray(); // exclude the existing persons_ids from the new person $this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id); @@ -456,7 +456,7 @@ class ParticipationControllerTest extends WebTestCase $circles = $this->em->getRepository('ChillMainBundle:Scope') ->findAll(); - array_filter($circles, function ($circle) use ($circleName) { + array_filter($circles, static function ($circle) use ($circleName) { return in_array($circleName, $circle->getName()); }); $circle = $circles[0]; diff --git a/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php b/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php index 65096e0d3..16b112825 100644 --- a/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php @@ -365,7 +365,7 @@ class EventSearchTest extends WebTestCase 'décembre' => 12, ]; - $results = $trs->each(function ($tr, $i) use ($months) { + $results = $trs->each(static function ($tr, $i) use ($months) { // we skip the first row if (0 < $i) { // get the second node, which should contains a date diff --git a/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php b/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php index 214b0c376..1c83c8ff9 100644 --- a/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php +++ b/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php @@ -206,7 +206,7 @@ class TimelineEventProvider implements TimelineProviderInterface foreach ($reachableCenters as $center) { $reachableCircleId = array_map( - function (Scope $scope) { return $scope->getId(); }, + static function (Scope $scope) { return $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 5cc1ddd93..5b342b2fa 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php +++ b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php @@ -138,7 +138,7 @@ class CRUDRoutesLoader extends Loader $methods = array_keys(array_filter( $action['methods'], - function ($value, $key) { return $value; }, + static function ($value, $key) { return $value; }, ARRAY_FILTER_USE_BOTH )); diff --git a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php index ca5da3b7f..1f07af303 100644 --- a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php @@ -325,7 +325,7 @@ class ChillImportUsersCommand extends Command $question ->setMultiselect(true) ->setAutocompleterValues(array_keys($permissionGroupsByName)) - ->setNormalizer(function ($value) { + ->setNormalizer(static function ($value) { if (null === $value) { return ''; } diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index 6be3d9927..bd855dafb 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -155,7 +155,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(function ($form) { + 'delete_role_scopes_form' => array_map(static function ($form) { return $form->createView(); }, $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), @@ -302,7 +302,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(function ($form) { + 'delete_role_scopes_form' => array_map(static function ($form) { return $form->createView(); }, $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), @@ -358,7 +358,7 @@ class PermissionsGroupController extends AbstractController // sort $roleScopes by name usort( $roleScopes, - function (RoleScope $a, RoleScope $b) use ($translatableStringHelper) { + static function (RoleScope $a, RoleScope $b) use ($translatableStringHelper) { if ($a->getScope() === null) { return 1; } @@ -446,7 +446,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(function ($form) { + 'delete_role_scopes_form' => array_map(static function ($form) { return $form->createView(); }, $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), @@ -570,7 +570,7 @@ class PermissionsGroupController extends AbstractController if (!array_key_exists($roleScope->getRole(), $expandedRoles)) { $expandedRoles[$roleScope->getRole()] = array_map( - function (Role $role) { + static function (Role $role) { return $role->getRole(); }, $this->roleHierarchy diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 716b13bc5..5b72115b8 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -237,7 +237,7 @@ class UserController extends CRUDController [ 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(), 'delete_groupcenter_form' => array_map( - function (Form $form) { + static function (Form $form) { return $form->createView(); }, iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php index 34cd6246e..68e2d3a16 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php @@ -35,7 +35,7 @@ class MenuCompilerPass implements CompilerPassInterface ]; } - usort($services, function ($a, $b) { + usort($services, static function ($a, $b) { if ($a['priority'] == $b['priority']) { return 0; } diff --git a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php index 150312f42..66a18e8e4 100644 --- a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php +++ b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php @@ -119,7 +119,7 @@ class PermissionsGroup public function isRoleScopePresentOnce(ExecutionContextInterface $context) { $roleScopesId = array_map( - function (RoleScope $roleScope) { + static function (RoleScope $roleScope) { return $roleScope->getId(); }, $this->getRoleScopes()->toArray() diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php index d2435bf50..0320a3fa4 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php @@ -168,7 +168,7 @@ class CSVFormatter implements FormatterInterface // gather data in an array foreach ($keys as $key) { - $values = array_map(function ($row) use ($key, $alias) { + $values = array_map(static function ($row) use ($key, $alias) { if (!array_key_exists($key, $row)) { throw new LogicException("the key '" . $key . "' is declared by " . "the aggregator with alias '" . $alias . "' but is not " @@ -195,7 +195,7 @@ class CSVFormatter implements FormatterInterface $keys = $this->export->getQueryKeys($this->exportData); foreach ($keys as $key) { - $values = array_map(function ($row) use ($key, $export) { + $values = array_map(static function ($row) use ($key, $export) { if (!array_key_exists($key, $row)) { throw new LogicException("the key '" . $key . "' is declared by " . "the export with title '" . $export->getTitle() . "' but is not " diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php index 1d49322a7..d5ded2c31 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php @@ -196,7 +196,7 @@ class CSVListFormatter implements FormatterInterface foreach ($keys as $key) { // get an array with all values for this key if possible - $values = array_map(function ($v) use ($key) { return $v[$key]; }, $this->result); + $values = array_map(static function ($v) use ($key) { return $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 24a4fb7ba..7b1c10709 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php @@ -184,7 +184,7 @@ class CSVPivotedListFormatter implements FormatterInterface foreach ($keys as $key) { // get an array with all values for this key if possible - $values = array_map(function ($v) use ($key) { return $v[$key]; }, $this->result); + $values = array_map(static function ($v) use ($key) { return $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/SpreadsheetListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php index cfcf3acdc..f6fbff62f 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php @@ -255,7 +255,7 @@ class SpreadsheetListFormatter implements FormatterInterface foreach ($keys as $key) { // get an array with all values for this key if possible - $values = array_map(function ($v) use ($key) { return $v[$key]; }, $this->result); + $values = array_map(static function ($v) use ($key) { return $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/Form/ChoiceLoader/PostalCodeChoiceLoader.php b/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php index 9c7b7d414..204f1f7e6 100644 --- a/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php +++ b/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php @@ -45,7 +45,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedPostalCodes, - function (?PostalCode $pc = null) use ($value) { + static function (?PostalCode $pc = null) use ($value) { return call_user_func($value, $pc); } ); diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index 22d3d1702..0ec0f0202 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -33,7 +33,7 @@ final class LocationFormType extends AbstractType $builder ->add('locationType', EntityType::class, [ 'class' => EntityLocationType::class, - 'choice_attr' => function (EntityLocationType $entity) { + 'choice_attr' => static function (EntityLocationType $entity) { return [ 'data-address' => $entity->getAddressRequired(), 'data-contact' => $entity->getContactData(), diff --git a/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php b/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php index 86ffb8e26..d4f82d437 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php +++ b/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php @@ -117,7 +117,7 @@ trait AppendScopeChoiceTypeTrait $builder->addEventListener( FormEvents::PRE_SET_DATA, - function (FormEvent $event) use ($choices, $name, $dataTransformer, $builder) { + static function (FormEvent $event) use ($choices, $name, $dataTransformer, $builder) { $form = $event->getForm(); $form->add( $builder diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php index f7b19f453..ebcd219f2 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 { $builder->add('permissionsgroup', EntityType::class, [ 'class' => 'Chill\MainBundle\Entity\PermissionsGroup', - 'choice_label' => function (PermissionsGroup $group) { + 'choice_label' => static function (PermissionsGroup $group) { return $group->getName(); }, ])->add('center', EntityType::class, [ 'class' => 'Chill\MainBundle\Entity\Center', - 'choice_label' => function (Center $center) { + 'choice_label' => static function (Center $center) { return $center->getName(); }, ]); diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php index 42a57f95a..e87256389 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php @@ -73,7 +73,7 @@ class ComposedRoleScopeType extends AbstractType ->add('role', ChoiceType::class, [ 'choices' => array_combine(array_values($values), array_keys($values)), 'placeholder' => 'Choose amongst roles', - 'choice_attr' => function ($role) use ($rolesWithoutScopes) { + 'choice_attr' => static function ($role) use ($rolesWithoutScopes) { if (in_array($role, $rolesWithoutScopes)) { return ['data-has-scope' => '0']; } @@ -86,7 +86,7 @@ class ComposedRoleScopeType extends AbstractType ]) ->add('scope', EntityType::class, [ 'class' => 'ChillMainBundle:Scope', - 'choice_label' => function (Scope $scope) use ($translatableStringHelper) { + 'choice_label' => static function (Scope $scope) use ($translatableStringHelper) { return $translatableStringHelper->localize($scope->getName()); }, 'required' => false, diff --git a/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php b/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php index 4287337fe..0c81c9084 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php @@ -82,7 +82,7 @@ class DateIntervalType extends AbstractType 'Months' => 'M', 'Years' => 'Y', ]) - ->setAllowedValues('unit_choices', function ($values) { + ->setAllowedValues('unit_choices', static function ($values) { if (false === is_array($values)) { throw new InvalidOptionsException('The value `unit_choice` should be an array'); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index 2d19aede2..08fdc479a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -80,10 +80,10 @@ class PickCenterType extends AbstractType $builder->add(self::CENTERS_IDENTIFIERS, EntityType::class, [ 'class' => 'ChillMainBundle:Center', - 'query_builder' => function (EntityRepository $er) use ($centers) { + 'query_builder' => static function (EntityRepository $er) use ($centers) { $qb = $er->createQueryBuilder('c'); $ids = array_map( - function (Center $el) { return $el->getId(); }, + static function (Center $el) { return $el->getId(); }, $centers ); @@ -91,7 +91,7 @@ class PickCenterType extends AbstractType }, 'multiple' => true, 'expanded' => true, - 'choice_label' => function (Center $c) { return $c->getName(); }, + 'choice_label' => static function (Center $c) { return $c->getName(); }, 'data' => count($this->groupingCenters) > 0 ? null : $centers, ]); diff --git a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php index 1bd4c5d4c..184dbe483 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php @@ -46,7 +46,7 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType foreach ($helper->getCheckboxes() as $name => $c) { $choices = array_combine( - array_map(function ($c, $t) { + array_map(static function ($c, $t) { if (null !== $t) { return $t; } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php index 5c7fa6616..c82f50f0f 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php @@ -80,14 +80,14 @@ class PickCenterType extends AbstractType $builder ->addModelTransformer(new CallbackTransformer( - function ($data) { + static function ($data) { if (null === $data) { return ['center' => null]; } return ['center' => $data]; }, - function ($data) { + static function ($data) { return $data['center']; } )); diff --git a/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php b/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php index 0e80345af..499410c1a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php @@ -75,7 +75,7 @@ class PostalCodeType extends AbstractType $helper = $this->translatableStringHelper; $resolver ->setDefault('class', PostalCode::class) - ->setDefault('choice_label', function (PostalCode $code) use ($helper) { + ->setDefault('choice_label', static function (PostalCode $code) use ($helper) { return $code->getCode() . ' ' . $code->getName() . ' [' . $helper->localize($code->getCountry()->getName()) . ']'; }) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index 44bbb48ef..4344dd52b 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -141,7 +141,7 @@ class ScopePickerType extends AbstractType ->join('pg.groupCenters', 'gc') // add center constraint ->where($qb->expr()->in('IDENTITY(gc.center)', ':centers')) - ->setParameter('centers', array_map(fn (Center $c) => $c->getId(), $centers)) + ->setParameter('centers', array_map(static fn (Center $c) => $c->getId(), $centers)) // role constraints ->andWhere($qb->expr()->in('rs.role', ':roles')) ->setParameter('roles', $roles) diff --git a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php index 57106da07..e4d5422c1 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php @@ -72,7 +72,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) { + ->setDefault('choice_label', static function (User $u) { return $u->getUsername(); }) ->setDefault('scope', null) diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index cf062f1ab..72692ab49 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -49,7 +49,7 @@ class UserType extends AbstractType 'required' => false, 'placeholder' => 'Choose a main center', 'class' => Center::class, - 'query_builder' => function (EntityRepository $er) { + 'query_builder' => static function (EntityRepository $er) { $qb = $er->createQueryBuilder('c'); $qb->addOrderBy('c.name'); diff --git a/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php b/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php index 18e98a0e7..672532763 100644 --- a/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php +++ b/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php @@ -31,7 +31,7 @@ class SearchUserApiProvider implements SearchApiInterface public function prepare(array $metadatas): void { - $ids = array_map(fn ($m) => $m['id'], $metadatas); + $ids = array_map(static fn ($m) => $m['id'], $metadatas); $this->userRepository->findBy(['id' => $ids]); } diff --git a/src/Bundle/ChillMainBundle/Search/SearchApi.php b/src/Bundle/ChillMainBundle/Search/SearchApi.php index a2a65cc96..b0740b383 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchApi.php +++ b/src/Bundle/ChillMainBundle/Search/SearchApi.php @@ -161,7 +161,7 @@ class SearchApi private function findQueries($pattern, array $types, array $parameters): array { return array_map( - fn ($p) => $p->provideQuery($pattern, $parameters), + static fn ($p) => $p->provideQuery($pattern, $parameters), $this->findProviders($pattern, $types, $parameters), ); } diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index 2acb759f1..c4c62e93e 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -88,7 +88,7 @@ class SearchProvider public function getByOrder() { //sort the array - uasort($this->searchServices, function (SearchInterface $a, SearchInterface $b) { + uasort($this->searchServices, static function (SearchInterface $a, SearchInterface $b) { if ($a->getOrder() == $b->getOrder()) { return 0; } @@ -121,7 +121,7 @@ class SearchProvider public function getHasAdvancedFormSearchServices() { //sort the array - uasort($this->hasAdvancedFormSearchServices, function (SearchInterface $a, SearchInterface $b) { + uasort($this->hasAdvancedFormSearchServices, static function (SearchInterface $a, SearchInterface $b) { if ($a->getOrder() == $b->getOrder()) { return 0; } diff --git a/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php b/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php index 21dfefe7f..2cb490ac0 100644 --- a/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php @@ -230,7 +230,7 @@ class ExportManagerTest extends KernelTestCase Argument::Type('array'), Argument::is(['a' => 'b']) ) - ->will(function () use ($em) { + ->will(static function () use ($em) { $qb = $em->createQueryBuilder(); return $qb->addSelect('COUNT(user.id) as export') @@ -254,7 +254,7 @@ class ExportManagerTest extends KernelTestCase Argument::is([0, 1]), Argument::Type('array') ) - ->willReturn(function ($value) { + ->willReturn(static function ($value) { switch ($value) { case 0: case 1: @@ -294,7 +294,7 @@ class ExportManagerTest extends KernelTestCase Argument::is(['cat a', 'cat b']), Argument::is([]) ) - ->willReturn(function ($value) { + ->willReturn(static function ($value) { switch ($value) { case '_header': return 'foo_header'; diff --git a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php index 1fe8b7c01..2c8e895bb 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php @@ -50,7 +50,7 @@ class ExtractDateFromPatternTest extends TestCase $this->assertContainsOnlyInstancesOf(DateTimeImmutable::class, $result->getFound()); $dates = array_map( - function (DateTimeImmutable $d) { + static function (DateTimeImmutable $d) { return $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 8c07e2a8e..65c3829b6 100644 --- a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php @@ -206,7 +206,7 @@ class AuthorizationHelperTest extends KernelTestCase $centerA ); - $usernames = array_map(function (User $u) { return $u->getUsername(); }, $users); + $usernames = array_map(static function (User $u) { return $u->getUsername(); }, $users); $this->assertContains('center a_social', $usernames); } diff --git a/src/Bundle/ChillMainBundle/Tests/Util/DateRangeCoveringTest.php b/src/Bundle/ChillMainBundle/Tests/Util/DateRangeCoveringTest.php index b02e2ea3e..2b4a88676 100644 --- a/src/Bundle/ChillMainBundle/Tests/Util/DateRangeCoveringTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Util/DateRangeCoveringTest.php @@ -77,7 +77,7 @@ class DateRangeCoveringTest extends TestCase $intersections = $cover->getIntersections(); // sort the intersections to compare them in expected order - usort($intersections, function ($a, $b) { + usort($intersections, static function ($a, $b) { if ($a[0] === $b[0]) { return $a[1] <=> $b[1]; } diff --git a/src/Bundle/ChillMainBundle/Util/CountriesInfo.php b/src/Bundle/ChillMainBundle/Util/CountriesInfo.php index 70f1e5fda..dcab6afbb 100644 --- a/src/Bundle/ChillMainBundle/Util/CountriesInfo.php +++ b/src/Bundle/ChillMainBundle/Util/CountriesInfo.php @@ -360,7 +360,7 @@ class CountriesInfo if (null === self::$cacheCountriesCodeByContinent) { $data = self::getArrayCountriesData(); - array_walk($data, function ($item, $key) { + array_walk($data, static function ($item, $key) { self::$cacheCountriesCodeByContinent[$item[0]][] = $item[1]; }); } diff --git a/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php b/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php index a935334c8..f4ffef120 100644 --- a/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php +++ b/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php @@ -526,7 +526,7 @@ final class ImportPeopleFromCSVCommand extends Command } $centersByName = []; - $names = array_map(function (Center $c) use (&$centersByName) { + $names = array_map(static function (Center $c) use (&$centersByName) { $n = $c->getName(); $centersByName[$n] = $c; @@ -609,7 +609,7 @@ final class ImportPeopleFromCSVCommand extends Command } $postalCodeByName = []; - $names = array_map(function (PostalCode $pc) use (&$postalCodeByName) { + $names = array_map(static function (PostalCode $pc) use (&$postalCodeByName) { $n = $pc->getName(); $postalCodeByName[$n] = $pc; @@ -859,7 +859,7 @@ final class ImportPeopleFromCSVCommand extends Command if (!isset($this->cacheAnswersMapping[$cf->getSlug()][$value])) { // try to find the answer (with array_keys and a search value $values = array_keys( - array_map(function ($label) { return trim(strtolower($label)); }, $answers), + array_map(static function ($label) { return trim(strtolower($label)); }, $answers), trim(strtolower($value)), true ); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php index d3780a622..54639b6cf 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php @@ -322,7 +322,7 @@ class AccompanyingPeriodController extends AbstractController /** @var AccompanyingPeriod $period */ $period = array_filter( $person->getAccompanyingPeriods(), - function (AccompanyingPeriod $p) use ($period_id) { + static function (AccompanyingPeriod $p) use ($period_id) { return $p->getId() === ($period_id); } )[0] ?? null; diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php index 9e50cda17..57e19bf75 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php @@ -106,7 +106,7 @@ class HouseholdApiController extends ApiController $actual = $household->getCurrentAddress(); if (null !== $actual) { - $addresses = array_filter($addresses, fn ($a) => $a !== $actual); + $addresses = array_filter($addresses, static fn ($a) => $a !== $actual); } return $this->json( diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 61da76c18..2385eaf39 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -62,7 +62,7 @@ class PersonApiController extends ApiController $actual = $person->getCurrentHouseholdAddress(); if (null !== $actual) { - $addresses = array_filter($addresses, fn ($a) => $a !== $actual); + $addresses = array_filter($addresses, static fn ($a) => $a !== $actual); } return $this->json(array_values($addresses), Response::HTTP_OK, [], ['groups' => ['read']]); diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php index 253a2b1d6..ac1f5eeff 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php @@ -113,7 +113,7 @@ class LoadCustomFields extends AbstractFixture implements // get possible values for cfGroup $choices = array_map( - function ($a) { return $a['slug']; }, + static function ($a) { return $a['slug']; }, $this->customFieldChoice->getOptions()['choices'] ); // create faker diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php index 68a8e1fd5..5fb496b09 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php @@ -44,7 +44,7 @@ class Configuration implements ConfigurationInterface ->info($this->validationBirthdateNotAfterInfos) ->defaultValue('P1D') ->validate() - ->ifTrue(function ($period) { + ->ifTrue(static function ($period) { try { $interval = new DateInterval($period); } catch (Exception $ex) { diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index e9e2f1713..43391cc43 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -520,10 +520,10 @@ class AccompanyingPeriod implements public function getAvailablePersonLocation(): Collection { return $this->getOpenParticipations() - ->filter(function (AccompanyingPeriodParticipation $p) { + ->filter(static function (AccompanyingPeriodParticipation $p) { return $p->getPerson()->hasCurrentHouseholdAddress(); }) - ->map(function (AccompanyingPeriodParticipation $p) { + ->map(static function (AccompanyingPeriodParticipation $p) { return $p->getPerson(); }); } diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php index 3fb4b592a..f561107ca 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php @@ -139,7 +139,7 @@ class Household { $at = null === $at ? new DateTime('today') : $at; - $addrs = $this->getAddresses()->filter(function (Address $a) use ($at) { + $addrs = $this->getAddresses()->filter(static function (Address $a) use ($at) { return $a->getValidFrom() <= $at && ( null === $a->getValidTo() || $a->getValidTo() > $at ); @@ -178,7 +178,7 @@ class Household public function getCurrentMembersIds(?DateTimeImmutable $now = null): Collection { return $this->getCurrentMembers($now)->map( - fn (HouseholdMember $m) => $m->getId() + static fn (HouseholdMember $m) => $m->getId() ); } @@ -191,7 +191,7 @@ class Household $members->getIterator() ->uasort( - function (HouseholdMember $a, HouseholdMember $b) { + static function (HouseholdMember $a, HouseholdMember $b) { if ($a->getPosition() === null) { if ($b->getPosition() === null) { return 0; @@ -247,7 +247,7 @@ class Household public function getCurrentPersons(?DateTimeImmutable $now = null): Collection { return $this->getCurrentMembers($now) - ->map(function (HouseholdMember $m) { return $m->getPerson(); }); + ->map(static function (HouseholdMember $m) { return $m->getPerson(); }); } public function getId(): ?int @@ -269,7 +269,7 @@ class Household $membership->getStartDate(), $membership->getEndDate() )->filter( - function (HouseholdMember $m) use ($membership) { + static function (HouseholdMember $m) use ($membership) { return $m !== $membership; } ); diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index e8dd981bf..d6f9dd436 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -774,7 +774,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI $periods = $this->getAccompanyingPeriods(); //order by date : - usort($periods, function ($a, $b) { + usort($periods, static function ($a, $b) { $dateA = $a->getOpeningDate(); $dateB = $b->getOpeningDate(); @@ -1296,7 +1296,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this->getAccompanyingPeriodParticipations() ->matching($criteria) - ->filter(function (AccompanyingPeriodParticipation $app) { + ->filter(static function (AccompanyingPeriodParticipation $app) { return AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep(); }); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/CountryOfBirthAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/CountryOfBirthAggregator.php index 770812ce5..e6c3f3749 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/CountryOfBirthAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/CountryOfBirthAggregator.php @@ -147,7 +147,7 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme ]; } - return function (string $value) use ($labels): string { + return static function (string $value) use ($labels): string { return $labels[$value]; }; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/NationalityAggregator.php index d6c69b7bc..3f9e71ebc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/NationalityAggregator.php @@ -147,7 +147,7 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ]; } - return function (string $value) use ($labels): string { + return static function (string $value) use ($labels): string { return $labels[$value]; }; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php index c621e8217..4376dde21 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php @@ -56,7 +56,7 @@ class CountPerson implements ExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return function ($value) use ($labels) { + return static function ($value) use ($labels) { return $labels[$value]; }; } @@ -88,7 +88,7 @@ class CountPerson implements ExportInterface */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(function ($el) { return $el['center']; }, $acl); + $centers = array_map(static function ($el) { return $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 6a0783325..d8c11a906 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -102,7 +102,7 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface return []; }, 'constraints' => [new Callback([ - 'callback' => function ($selected, ExecutionContextInterface $context) { + 'callback' => static function ($selected, ExecutionContextInterface $context) { if (count($selected) === 0) { $context->buildViolation('You must select at least one element') ->atPath('fields') @@ -266,7 +266,7 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(function ($el) { return $el['center']; }, $acl); + $centers = array_map(static function ($el) { return $el['center']; }, $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/GenderFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/GenderFilter.php index dc618f1b5..ad03b4e3d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/GenderFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/GenderFilter.php @@ -63,7 +63,7 @@ class GenderFilter implements $qb->add('where', $where); $qb->setParameter('person_gender', array_filter( $data['accepted_genders'], - function ($el) { + static function ($el) { return 'null' !== $el; } )); diff --git a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php index 79e0bb225..618403a7d 100644 --- a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php +++ b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php @@ -52,7 +52,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedPersons, - function (Person $p) use ($value) { + static function (Person $p) use ($value) { return call_user_func($value, $p); } ); diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 2f2ab79a5..7c5200dd3 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -111,10 +111,10 @@ class PersonType extends AbstractType ]); $builder->get('placeOfBirth')->addModelTransformer(new CallbackTransformer( - function ($string) { + static function ($string) { return strtoupper($string); }, - function ($string) { + static function ($string) { return strtoupper($string); } )); @@ -148,7 +148,7 @@ class PersonType extends AbstractType 'allow_delete' => true, 'by_reference' => false, 'label' => false, - 'delete_empty' => function (?PersonPhone $pp = null) { + 'delete_empty' => static function (?PersonPhone $pp = null) { return null === $pp || $pp->isEmpty(); }, 'error_bubbling' => false, @@ -192,7 +192,7 @@ class PersonType extends AbstractType 'choice_label' => function (Civility $civility): string { return $this->translatableStringHelper->localize($civility->getName()); }, - 'query_builder' => function (EntityRepository $er): QueryBuilder { + 'query_builder' => static function (EntityRepository $er): QueryBuilder { return $er->createQueryBuilder('c') ->where('c.active = true'); }, diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php index 414549b1e..7f061bc1c 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php @@ -110,11 +110,11 @@ class PickPersonType extends AbstractType // add the default options $resolver->setDefaults([ 'class' => Person::class, - 'choice_label' => function (Person $p) { + 'choice_label' => static function (Person $p) { return $p->getFirstname() . ' ' . $p->getLastname(); }, 'placeholder' => 'Pick a person', - 'choice_attr' => function (Person $p) { + 'choice_attr' => static function (Person $p) { return [ 'data-center' => $p->getCenter()->getId(), ]; @@ -136,7 +136,7 @@ class PickPersonType extends AbstractType protected function filterCentersfom(Options $options) { if (null === $options['role']) { - $centers = array_map(function (GroupCenter $g) { + $centers = array_map(static function (GroupCenter $g) { return $g->getCenter(); }, $this->user->getGroupCenters()->toArray()); } else { @@ -160,7 +160,7 @@ class PickPersonType extends AbstractType } if (!in_array($c->getId(), array_map( - function (Center $c) { return $c->getId(); }, + static function (Center $c) { return $c->getId(); }, $centers ))) { throw new AccessDeniedException('The given center is not reachable'); diff --git a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php index 958b8424f..111ba355f 100644 --- a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php @@ -73,7 +73,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface $involved = $this->getInvolved(); $involved['period_id'] = $event->getPeriod()->getId(); $involved['persons'] = $event->getPeriod()->getPersons() - ->map(function (Person $p) { return $p->getId(); }) + ->map(static function (Person $p) { return $p->getId(); }) ->toArray(); $this->logger->notice( @@ -97,7 +97,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface if ($event->hasPersons()) { $involved['persons'] = array_map( - function (Person $p) { return $p->getId(); }, + static function (Person $p) { return $p->getId(); }, $event->getPersons() ); } diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php index 60ddc1fa3..72b2da862 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php @@ -314,7 +314,7 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac ), ] ), - array_map(function (Center $c) {return $c->getId(); }, $authorizedCenters) + array_map(static function (Center $c) {return $c->getId(); }, $authorizedCenters) ); } } diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php index 2e0a69a75..456b6fca4 100644 --- a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php +++ b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php @@ -208,7 +208,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf 'persons' => $this->search($terms, $start, $limit, $options), 'pattern' => $this->recomposePattern( $terms, - array_filter(self::POSSIBLE_KEYS, fn ($item) => '_default' !== $item), + array_filter(self::POSSIBLE_KEYS, static fn ($item) => '_default' !== $item), $terms['_domain'] ), 'total' => $total, diff --git a/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php b/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php index 4aa611d23..d0f7f7bba 100644 --- a/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php +++ b/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php @@ -58,7 +58,7 @@ class SearchPersonApiProvider implements SearchApiInterface public function prepare(array $metadatas): void { - $ids = array_map(fn ($m) => $m['id'], $metadatas); + $ids = array_map(static fn ($m) => $m['id'], $metadatas); $this->personRepository->findByIds($ids); } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php index 25bbb924c..cfc5e0566 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php @@ -87,7 +87,7 @@ class AccompanyingPeriodWorkDenormalizer implements DenormalizerAwareInterface, // partition the separate kept evaluations and removed one [$kept, $removed] = $work->getAccompanyingPeriodWorkEvaluations() ->partition( - fn (int $key, AccompanyingPeriodWorkEvaluation $a) => array_key_exists($a->getId(), $dataById) + static fn (int $key, AccompanyingPeriodWorkEvaluation $a) => array_key_exists($a->getId(), $dataById) ); // remove the evaluations from work diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php index 3ad1bf4c1..20366c545 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php @@ -61,7 +61,7 @@ class PersonDocGenNormalizer implements 'altNames' => implode( ', ', array_map( - function (PersonAltName $altName) { + static function (PersonAltName $altName) { return $altName->getLabel(); }, $person->getAltNames()->toArray() diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php index ffbadf50a..dd5577bbc 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php @@ -33,7 +33,7 @@ class SocialIssueNormalizer implements NormalizerInterface, NormalizerAwareInter 'type' => 'social_issue', 'id' => $socialIssue->getId(), 'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null, - 'children_ids' => $socialIssue->getChildren()->map(function (SocialIssue $si) { return $si->getId(); }), + 'children_ids' => $socialIssue->getChildren()->map(static function (SocialIssue $si) { return $si->getId(); }), 'title' => $socialIssue->getTitle(), 'text' => $this->render->renderString($socialIssue, []), ]; diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index d58822f9c..b7f580f55 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -329,7 +329,7 @@ class AccompanyingCourseApiControllerTest extends WebTestCase // check that the person id is contained $participationsPersonsIds = array_map( - function ($participation) { return $participation->person->id; }, + static function ($participation) { return $participation->person->id; }, $data->participations ); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php index e1c78b361..782da23d8 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -151,7 +151,7 @@ class HouseholdApiControllerTest extends WebTestCase $this->assertArrayHasKey('count', $data); $this->assertArrayHasKey('results', $data); - $householdIds = array_map(function ($r) { + $householdIds = array_map(static function ($r) { return $r['id']; }, $data['results']); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php index 5ee30c6a6..f57c30529 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php @@ -290,22 +290,22 @@ class PersonControllerUpdateTest extends WebTestCase public function validTextFieldsProvider() { return [ - ['firstName', 'random Value', function (Person $person) { return $person->getFirstName(); }], - ['lastName', 'random Value', function (Person $person) { return $person->getLastName(); }], + ['firstName', 'random Value', static function (Person $person) { return $person->getFirstName(); }], + ['lastName', 'random Value', static function (Person $person) { return $person->getLastName(); }], // reminder: this value is capitalized - ['placeOfBirth', 'A PLACE', function (Person $person) { return $person->getPlaceOfBirth(); }], - ['birthdate', '1980-12-15', function (Person $person) { return $person->getBirthdate()->format('Y-m-d'); }], - ['phonenumber', '+32123456789', function (Person $person) { return $person->getPhonenumber(); }], - ['memo', 'jfkdlmq jkfldmsq jkmfdsq', function (Person $person) { return $person->getMemo(); }], - ['countryOfBirth', 'BE', function (Person $person) { return $person->getCountryOfBirth()->getCountryCode(); }], - ['nationality', 'FR', function (Person $person) { return $person->getNationality()->getCountryCode(); }], - ['placeOfBirth', '', function (Person $person) { return $person->getPlaceOfBirth(); }], - ['birthdate', '', function (Person $person) { return $person->getBirthdate(); }], - ['phonenumber', '', function (Person $person) { return $person->getPhonenumber(); }], - ['memo', '', function (Person $person) { return $person->getMemo(); }], - ['countryOfBirth', null, function (Person $person) { return $person->getCountryOfBirth(); }], - ['nationality', null, function (Person $person) { return $person->getNationality(); }], - ['gender', Person::FEMALE_GENDER, function (Person $person) { return $person->getGender(); }], + ['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'); }], + ['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(); }], + ['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(); }], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php index 907883362..73ff514c2 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php @@ -195,12 +195,12 @@ class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase public function validTextFieldsProvider() { return [ - ['firstName', 'random Value', function (Person $person) { return $person->getFirstName(); }], - ['lastName', 'random Value', function (Person $person) { return $person->getLastName(); }], - ['birthdate', '15-12-1980', function (Person $person) { return $person->getBirthdate()->format('d-m-Y'); }], - ['memo', 'jfkdlmq jkfldmsq jkmfdsq', function (Person $person) { return $person->getMemo(); }], - ['birthdate', '', function (Person $person) { return $person->getBirthdate(); }], - ['gender', Person::FEMALE_GENDER, function (Person $person) { return $person->getGender(); }], + ['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(); }], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Validator/Person/PersonHasCenterValidatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Validator/Person/PersonHasCenterValidatorTest.php index 6603ca795..383b14e31 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Validator/Person/PersonHasCenterValidatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Validator/Person/PersonHasCenterValidatorTest.php @@ -55,7 +55,7 @@ class PersonHasCenterValidatorTest extends ConstraintValidatorTestCase $prophecy = $this->prophesize(CenterResolverManagerInterface::class); - $prophecy->resolveCenters(Argument::type(Person::class), Argument::any())->will(function ($args) { + $prophecy->resolveCenters(Argument::type(Person::class), Argument::any())->will(static function ($args) { $center = $args[0]->getCenter(); if ($center instanceof Center) { diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 85c233992..edd49e2f3 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -100,7 +100,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface 'expanded' => true, 'choices' => $choices, 'label' => 'Fields to include in export', - 'choice_attr' => function ($val, $key, $index) { + 'choice_attr' => static function ($val, $key, $index) { // add a 'data-display-target' for address fields if (substr($val, 0, 8) === 'address_') { return ['data-display-target' => 'address_date']; @@ -124,7 +124,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface } }, 'constraints' => [new Callback([ - 'callback' => function ($selected, ExecutionContextInterface $context) { + 'callback' => static function ($selected, ExecutionContextInterface $context) { if (count($selected) === 0) { $context->buildViolation('You must select at least one element') ->atPath('fields') @@ -165,7 +165,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface case 'report_date': // for birthdate or report date, we have to transform the string into a date // to format the date correctly. - return function ($value) use ($key) { + return static function ($value) use ($key) { if ('_header' === $value) { return 'person_birthdate' === $key ? 'birthdate' : 'report_date'; } @@ -202,7 +202,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface $scopes[$row['id']] = $this->translatableStringHelper->localize($row['name']); } - return function ($value) use ($scopes): string { + return static function ($value) use ($scopes): string { if ('_header' === $value) { return 'circle'; } @@ -224,7 +224,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface $users[$row['id']] = $row['username']; } - return function ($value) use ($users): string { + return static function ($value) use ($users): string { if ('_header' === $value) { return 'user'; } @@ -282,7 +282,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface default: // for fields which are associated with person if (in_array($key, $this->fields)) { - return function ($value) use ($key) { + return static function ($value) use ($key) { if ('_header' === $value) { return strtolower($key); } @@ -331,7 +331,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(function ($el) { return $el['center']; }, $acl); + $centers = array_map(static function ($el) { return $el['center']; }, $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { @@ -503,7 +503,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface private function getCustomFields() { return array_filter($this->customfieldsGroup - ->getCustomFields()->toArray(), function (CustomField $cf) { + ->getCustomFields()->toArray(), static function (CustomField $cf) { return $cf->getType() !== 'title'; }); } diff --git a/src/Bundle/ChillReportBundle/Search/ReportSearch.php b/src/Bundle/ChillReportBundle/Search/ReportSearch.php index 69ad91a24..82b453812 100644 --- a/src/Bundle/ChillReportBundle/Search/ReportSearch.php +++ b/src/Bundle/ChillReportBundle/Search/ReportSearch.php @@ -94,7 +94,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface foreach ($reachableCenters as $center) { $reachableScopesId = array_map( - function (Scope $scope) { return $scope->getId(); }, + static function (Scope $scope) { return $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 d5bfb781e..6b6186196 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php @@ -66,7 +66,7 @@ class ReportControllerNextTest extends WebTestCase //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, - function (CustomFieldsGroup $group) { + static function (CustomFieldsGroup $group) { return in_array('Situation de logement', $group->getName()); } ); diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php index 626f6ae44..2bb723b37 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php @@ -84,7 +84,7 @@ class ReportControllerTest extends WebTestCase //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, - function (CustomFieldsGroup $group) { + static function (CustomFieldsGroup $group) { return in_array('Situation de logement', $group->getName()); } ); diff --git a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php index d0b1595d3..af1d234c7 100644 --- a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php @@ -65,7 +65,7 @@ class TimelineProviderTest extends WebTestCase static::$em ->getRepository('ChillMainBundle:Scope') ->findAll(), - function (Scope $scope) { return $scope->getName()['en'] === 'social'; } + static function (Scope $scope) { return $scope->getName()['en'] === 'social'; } ); $report = (new Report()) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 396a2960d..22513580c 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -296,7 +296,7 @@ final class SingleTaskController extends AbstractController $filterOrder = $this->buildFilterOrder(); $flags = array_merge( $filterOrder->getCheckboxData('status'), - array_map(fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) + array_map(static fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) ); $nb = $this->singleTaskAclAwareRepository->countByAllViewable( $filterOrder->getQueryString(), @@ -341,7 +341,7 @@ final class SingleTaskController extends AbstractController $filterOrder = $this->buildFilterOrder(); $flags = array_merge( $filterOrder->getCheckboxData('status'), - array_map(fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) + array_map(static fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) ); $nb = $this->singleTaskAclAwareRepository->countByCourse( $course, @@ -390,7 +390,7 @@ final class SingleTaskController extends AbstractController $filterOrder = $this->buildFilterOrder(); $flags = array_merge( $filterOrder->getCheckboxData('status'), - array_map(fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) + array_map(static fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) ); $nb = $this->singleTaskAclAwareRepository->countByPerson( $person, @@ -440,7 +440,7 @@ final class SingleTaskController extends AbstractController $filterOrder = $this->buildFilterOrder(); $flags = array_merge( $filterOrder->getCheckboxData('status'), - array_map(fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) + array_map(static fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) ); $nb = $this->singleTaskAclAwareRepository->countByCurrentUsersTasks( $filterOrder->getQueryString(), diff --git a/src/Bundle/ChillTaskBundle/Controller/TaskController.php b/src/Bundle/ChillTaskBundle/Controller/TaskController.php index 498997abc..13fab75d5 100644 --- a/src/Bundle/ChillTaskBundle/Controller/TaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/TaskController.php @@ -91,7 +91,7 @@ class TaskController extends AbstractController $transitionInstance = array_values( // array_values needed to reset keys (array_filter preserves keys) array_filter( $workflow->getEnabledTransitions($task), - function (Transition $t) use ($transition) { + static function (Transition $t) use ($transition) { return $t->getName() === $transition; } ))[0]; diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php index b6b90f4ee..3613f03c8 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php @@ -215,9 +215,9 @@ class SingleTaskListType extends AbstractType $users = $this->getUsersAssigneedToTask($options); $choices = array_combine( // get usernames - array_map(function (User $user) { return $user->getUsername(); }, $users), + array_map(static function (User $user) { return $user->getUsername(); }, $users), // get ids - array_map(function (User $user) { return $user->getId(); }, $users) + array_map(static function (User $user) { return $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 19a2e9cd7..8060d18aa 100644 --- a/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php +++ b/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php @@ -90,7 +90,7 @@ class SingleTaskControllerTest extends WebTestCase $center = array_filter( $centers, - function (Center $c) use ($centerName) { + static function (Center $c) use ($centerName) { return $c->getName() === $centerName; } )[0]; diff --git a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php index cb1fab15f..4644efb40 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php @@ -83,7 +83,7 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn ->findBy(['id' => $ids]); return array_combine( - array_map(function ($e) { return $e->getId(); }, $events), + array_map(static function ($e) { return $e->getId(); }, $events), $events ); } diff --git a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php index 5884d073a..7478e67cf 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php @@ -94,7 +94,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface ->findBy(['id' => $ids]); return array_combine( - array_map(function ($e) { return $e->getId(); }, $events), + array_map(static function ($e) { return $e->getId(); }, $events), $events ); } diff --git a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php index d7feba8c5..6977641af 100644 --- a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php @@ -74,7 +74,7 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface private function getCenters(): Iterator { $references = array_map( - function ($a) { return $a['ref']; }, + static function ($a) { return $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 fa4dd34e9..15252927c 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -351,7 +351,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface */ public function getActiveChildren(): Collection { - return $this->children->filter(fn (ThirdParty $tp) => $tp->getActive()); + return $this->children->filter(static fn (ThirdParty $tp) => $tp->getActive()); } public function getAddress(): ?Address @@ -806,7 +806,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface public function setTypesAndCategories(array $typesAndCategories): self { - $types = array_filter($typesAndCategories, fn ($item) => !$item instanceof ThirdPartyCategory); + $types = array_filter($typesAndCategories, static fn ($item) => !$item instanceof ThirdPartyCategory); $this->setTypes($types); // handle categories @@ -814,8 +814,8 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface $this->addTypesAndCategories($t); } - $categories = array_filter($typesAndCategories, fn ($item) => $item instanceof ThirdPartyCategory); - $categoriesHashes = array_map(fn (ThirdPartyCategory $c) => spl_object_hash($c), $categories); + $categories = array_filter($typesAndCategories, static fn ($item) => $item instanceof ThirdPartyCategory); + $categoriesHashes = array_map(static fn (ThirdPartyCategory $c) => spl_object_hash($c), $categories); foreach ($categories as $c) { $this->addCategory($c); diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 416dbd95c..556343d56 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -104,7 +104,7 @@ class ThirdPartyType extends AbstractType 'choice_label' => function (Civility $civility): string { return $this->translatableStringHelper->localize($civility->getName()); }, - 'query_builder' => function (EntityRepository $er): QueryBuilder { + 'query_builder' => static function (EntityRepository $er): QueryBuilder { return $er->createQueryBuilder('c') ->where('c.active = true'); }, @@ -117,7 +117,7 @@ class ThirdPartyType extends AbstractType 'choice_label' => function (ThirdPartyProfession $profession): string { return $this->translatableStringHelper->localize($profession->getName()); }, - 'query_builder' => function (EntityRepository $er): QueryBuilder { + 'query_builder' => static function (EntityRepository $er): QueryBuilder { return $er->createQueryBuilder('p') ->where('p.active = true'); }, diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php index cf0edc754..59499dc52 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php @@ -96,7 +96,7 @@ class PickThirdPartyType extends AbstractType $resolver ->setDefault('class', ThirdParty::class) - ->setDefault('choice_label', function (ThirdParty $tp) { + ->setDefault('choice_label', static function (ThirdParty $tp) { return $tp->getName(); }) ->setDefault('choice_loader', function (Options $options) {