cs: Enable risky rule static_lambda.

This commit is contained in:
Pol Dellaiera 2021-11-30 11:43:34 +01:00
parent a9188355c5
commit 91d12c4a96
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA
111 changed files with 212 additions and 212 deletions

View File

@ -63,7 +63,7 @@ $riskyRules = [
'php_unit_mock' => false, 'php_unit_mock' => false,
'php_unit_namespaced' => false, 'php_unit_namespaced' => false,
'random_api_migration' => false, 'random_api_migration' => false,
'static_lambda' => false, // 'static_lambda' => false,
'php_unit_construct' => false, 'php_unit_construct' => false,
// 'psr_autoloading' => false, // 'psr_autoloading' => false,
'php_unit_dedicate_assert' => false, 'php_unit_dedicate_assert' => false,

View File

@ -89,7 +89,7 @@ class CountPerson implements ExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
// we gather all center the user choose. // 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(); $qb = $this->entityManager->createQueryBuilder();

View File

@ -56,7 +56,7 @@ class Configuration implements ConfigurationInterface
->info('The number of seconds of this duration. Must be an integer.') ->info('The number of seconds of this duration. Must be an integer.')
->cannotBeEmpty() ->cannotBeEmpty()
->validate() ->validate()
->ifTrue(function ($data) { ->ifTrue(static function ($data) {
return !is_int($data); return !is_int($data);
})->thenInvalid('The value %s is not a valid integer') })->thenInvalid('The value %s is not a valid integer')
->end() ->end()

View File

@ -75,7 +75,7 @@ class ListActivity implements ListInterface
'choices' => array_combine($this->fields, $this->fields), 'choices' => array_combine($this->fields, $this->fields),
'label' => 'Fields to include in export', 'label' => 'Fields to include in export',
'constraints' => [new Callback([ 'constraints' => [new Callback([
'callback' => function ($selected, ExecutionContextInterface $context) { 'callback' => static function ($selected, ExecutionContextInterface $context) {
if (count($selected) === 0) { if (count($selected) === 0) {
$context->buildViolation('You must select at least one element') $context->buildViolation('You must select at least one element')
->atPath('fields') ->atPath('fields')
@ -189,7 +189,7 @@ class ListActivity implements ListInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) 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 // throw an error if any fields are present
if (!array_key_exists('fields', $data)) { if (!array_key_exists('fields', $data)) {

View File

@ -125,7 +125,7 @@ class ActivityType extends AbstractType
$builder->add('socialIssues', HiddenType::class); $builder->add('socialIssues', HiddenType::class);
$builder->get('socialIssues') $builder->get('socialIssues')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (iterable $socialIssuesAsIterable): string { static function (iterable $socialIssuesAsIterable): string {
$socialIssueIds = []; $socialIssueIds = [];
foreach ($socialIssuesAsIterable as $value) { foreach ($socialIssuesAsIterable as $value) {
@ -151,7 +151,7 @@ class ActivityType extends AbstractType
$builder->add('socialActions', HiddenType::class); $builder->add('socialActions', HiddenType::class);
$builder->get('socialActions') $builder->get('socialActions')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (iterable $socialActionsAsIterable): string { static function (iterable $socialActionsAsIterable): string {
$socialActionIds = []; $socialActionIds = [];
foreach ($socialActionsAsIterable as $value) { foreach ($socialActionsAsIterable as $value) {
@ -203,7 +203,7 @@ class ActivityType extends AbstractType
'choice_label' => function (ActivityPresence $activityPresence) { 'choice_label' => function (ActivityPresence $activityPresence) {
return $this->translatableStringHelper->localize($activityPresence->getName()); return $this->translatableStringHelper->localize($activityPresence->getName());
}, },
'query_builder' => function (EntityRepository $er) { 'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('a') return $er->createQueryBuilder('a')
->where('a.active = true'); ->where('a.active = true');
}, },
@ -229,7 +229,7 @@ class ActivityType extends AbstractType
return $this->translatableStringHelper->localize($activityReason->getName()); return $this->translatableStringHelper->localize($activityReason->getName());
}, },
'attr' => ['class' => 'select2 '], 'attr' => ['class' => 'select2 '],
'query_builder' => function (EntityRepository $er) { 'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('a') return $er->createQueryBuilder('a')
->where('a.active = true'); ->where('a.active = true');
}, },
@ -248,7 +248,7 @@ class ActivityType extends AbstractType
$builder->add('persons', HiddenType::class); $builder->add('persons', HiddenType::class);
$builder->get('persons') $builder->get('persons')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (iterable $personsAsIterable): string { static function (iterable $personsAsIterable): string {
$personIds = []; $personIds = [];
foreach ($personsAsIterable as $value) { foreach ($personsAsIterable as $value) {
@ -270,7 +270,7 @@ class ActivityType extends AbstractType
$builder->add('thirdParties', HiddenType::class); $builder->add('thirdParties', HiddenType::class);
$builder->get('thirdParties') $builder->get('thirdParties')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (iterable $thirdpartyAsIterable): string { static function (iterable $thirdpartyAsIterable): string {
$thirdpartyIds = []; $thirdpartyIds = [];
foreach ($thirdpartyAsIterable as $value) { foreach ($thirdpartyAsIterable as $value) {
@ -303,7 +303,7 @@ class ActivityType extends AbstractType
$builder->add('users', HiddenType::class); $builder->add('users', HiddenType::class);
$builder->get('users') $builder->get('users')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (iterable $usersAsIterable): string { static function (iterable $usersAsIterable): string {
$userIds = []; $userIds = [];
foreach ($usersAsIterable as $value) { foreach ($usersAsIterable as $value) {
@ -325,7 +325,7 @@ class ActivityType extends AbstractType
$builder->add('location', HiddenType::class) $builder->add('location', HiddenType::class)
->get('location') ->get('location')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (?Location $location): string { static function (?Location $location): string {
if (null === $location) { if (null === $location) {
return ''; return '';
} }
@ -365,7 +365,7 @@ class ActivityType extends AbstractType
->addModelTransformer($durationTimeTransformer); ->addModelTransformer($durationTimeTransformer);
$builder->get($fieldName) $builder->get($fieldName)
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $formEvent) use ( ->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $formEvent) use (
$timeChoices, $timeChoices,
$builder, $builder,
$durationTimeTransformer, $durationTimeTransformer,

View File

@ -55,7 +55,7 @@ class TranslatableActivityReason extends AbstractType
return null; return null;
}, },
'query_builder' => function (EntityRepository $er) { 'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('r') return $er->createQueryBuilder('r')
->where('r.active = true'); ->where('r.active = true');
}, },

View File

@ -37,7 +37,7 @@ class TranslatableActivityReasonCategory extends AbstractType
[ [
'class' => 'ChillActivityBundle:ActivityReasonCategory', 'class' => 'ChillActivityBundle:ActivityReasonCategory',
'choice_label' => 'name[' . $locale . ']', 'choice_label' => 'name[' . $locale . ']',
'query_builder' => function (EntityRepository $er) { 'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('c') return $er->createQueryBuilder('c')
->where('c.active = true'); ->where('c.active = true');
}, },

View File

@ -167,7 +167,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center); $reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center);
// we get the ids for those scopes // we get the ids for those scopes
$reachablesScopesId = array_map( $reachablesScopesId = array_map(
function (Scope $scope) { return $scope->getId(); }, static function (Scope $scope) { return $scope->getId(); },
$reachableScopes $reachableScopes
); );

View File

@ -366,8 +366,8 @@ class ActivityControllerTest extends WebTestCase
$center $center
); );
$reachableScopesId = array_intersect( $reachableScopesId = array_intersect(
array_map(function ($s) { return $s->getId(); }, $reachableScopesDelete), array_map(static function ($s) { return $s->getId(); }, $reachableScopesDelete),
array_map(function ($s) { return $s->getId(); }, $reachableScopesUpdate) array_map(static function ($s) { return $s->getId(); }, $reachableScopesUpdate)
); );
if (count($reachableScopesId) === 0) { if (count($reachableScopesId) === 0) {

View File

@ -186,7 +186,7 @@ class ActivityTypeTest extends KernelTestCase
// map all the values in an array // map all the values in an array
$values = array_map( $values = array_map(
function ($choice) { return $choice->value; }, static function ($choice) { return $choice->value; },
$view['activity']['durationTime']->vars['choices'] $view['activity']['durationTime']->vars['choices']
); );

View File

@ -81,7 +81,7 @@ class TranslatableActivityReasonTest extends TypeTestCase
$request->getLocale()->willReturn($fallbackLocale); $request->getLocale()->willReturn($fallbackLocale);
$requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack'); $requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack');
$requestStack->getCurrentRequest()->will(function () use ($request) { $requestStack->getCurrentRequest()->will(static function () use ($request) {
return $request; return $request;
}); });

View File

@ -125,7 +125,7 @@ class Configuration implements ConfigurationInterface
->info('The number of seconds of this duration. Must be an integer.') ->info('The number of seconds of this duration. Must be an integer.')
->cannotBeEmpty() ->cannotBeEmpty()
->validate() ->validate()
->ifTrue(function ($data) { ->ifTrue(static function ($data) {
return !is_int($data); return !is_int($data);
})->thenInvalid('The value %s is not a valid integer') })->thenInvalid('The value %s is not a valid integer')
->end() ->end()

View File

@ -73,7 +73,7 @@ final class AsideActivityFormType extends AbstractType
'required' => true, 'required' => true,
'class' => User::class, 'class' => User::class,
'data' => $this->storage->getToken()->getUser(), 'data' => $this->storage->getToken()->getUser(),
'query_builder' => function (EntityRepository $er) { 'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('u')->where('u.enabled = true'); return $er->createQueryBuilder('u')->where('u.enabled = true');
}, },
'attr' => ['class' => 'select2 '], 'attr' => ['class' => 'select2 '],
@ -98,7 +98,7 @@ final class AsideActivityFormType extends AbstractType
'required' => true, 'required' => true,
'class' => AsideActivityCategory::class, 'class' => AsideActivityCategory::class,
'placeholder' => 'Choose the activity category', 'placeholder' => 'Choose the activity category',
'query_builder' => function (EntityRepository $er) { 'query_builder' => static function (EntityRepository $er) {
$qb = $er->createQueryBuilder('ac'); $qb = $er->createQueryBuilder('ac');
$qb->where($qb->expr()->eq('ac.isActive', 'TRUE')) $qb->where($qb->expr()->eq('ac.isActive', 'TRUE'))
->addOrderBy('ac.ordering', 'ASC'); ->addOrderBy('ac.ordering', 'ASC');
@ -123,7 +123,7 @@ final class AsideActivityFormType extends AbstractType
->addModelTransformer($durationTimeTransformer); ->addModelTransformer($durationTimeTransformer);
$builder->get($fieldName) $builder->get($fieldName)
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $formEvent) use ( ->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $formEvent) use (
$timeChoices, $timeChoices,
$builder, $builder,
$durationTimeTransformer, $durationTimeTransformer,

View File

@ -69,7 +69,7 @@ class CalendarType extends AbstractType
$builder->add('mainUser', HiddenType::class); $builder->add('mainUser', HiddenType::class);
$builder->get('mainUser') $builder->get('mainUser')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (?User $user): int { static function (?User $user): int {
if (null !== $user) { if (null !== $user) {
$res = $user->getId(); $res = $user->getId();
} else { } else {
@ -86,7 +86,7 @@ class CalendarType extends AbstractType
$builder->add('startDate', HiddenType::class); $builder->add('startDate', HiddenType::class);
$builder->get('startDate') $builder->get('startDate')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (?DateTimeImmutable $dateTimeImmutable): string { static function (?DateTimeImmutable $dateTimeImmutable): string {
if (null !== $dateTimeImmutable) { if (null !== $dateTimeImmutable) {
$res = date_format($dateTimeImmutable, 'Y-m-d H:i:s'); $res = date_format($dateTimeImmutable, 'Y-m-d H:i:s');
} else { } else {
@ -95,7 +95,7 @@ class CalendarType extends AbstractType
return $res; return $res;
}, },
function (?string $dateAsString): DateTimeImmutable { static function (?string $dateAsString): DateTimeImmutable {
dump($dateAsString); dump($dateAsString);
return new DateTimeImmutable($dateAsString); return new DateTimeImmutable($dateAsString);
@ -105,7 +105,7 @@ class CalendarType extends AbstractType
$builder->add('endDate', HiddenType::class); $builder->add('endDate', HiddenType::class);
$builder->get('endDate') $builder->get('endDate')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (?DateTimeImmutable $dateTimeImmutable): string { static function (?DateTimeImmutable $dateTimeImmutable): string {
if (null !== $dateTimeImmutable) { if (null !== $dateTimeImmutable) {
$res = date_format($dateTimeImmutable, 'Y-m-d H:i:s'); $res = date_format($dateTimeImmutable, 'Y-m-d H:i:s');
} else { } else {
@ -114,7 +114,7 @@ class CalendarType extends AbstractType
return $res; return $res;
}, },
function (?string $dateAsString): DateTimeImmutable { static function (?string $dateAsString): DateTimeImmutable {
return new DateTimeImmutable($dateAsString); return new DateTimeImmutable($dateAsString);
} }
)); ));
@ -122,7 +122,7 @@ class CalendarType extends AbstractType
$builder->add('persons', HiddenType::class); $builder->add('persons', HiddenType::class);
$builder->get('persons') $builder->get('persons')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (iterable $personsAsIterable): string { static function (iterable $personsAsIterable): string {
$personIds = []; $personIds = [];
foreach ($personsAsIterable as $value) { foreach ($personsAsIterable as $value) {
@ -142,7 +142,7 @@ class CalendarType extends AbstractType
$builder->add('professionals', HiddenType::class); $builder->add('professionals', HiddenType::class);
$builder->get('professionals') $builder->get('professionals')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (iterable $thirdpartyAsIterable): string { static function (iterable $thirdpartyAsIterable): string {
$thirdpartyIds = []; $thirdpartyIds = [];
foreach ($thirdpartyAsIterable as $value) { foreach ($thirdpartyAsIterable as $value) {
@ -162,7 +162,7 @@ class CalendarType extends AbstractType
$builder->add('calendarRange', HiddenType::class); $builder->add('calendarRange', HiddenType::class);
$builder->get('calendarRange') $builder->get('calendarRange')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (?CalendarRange $calendarRange): ?int { static function (?CalendarRange $calendarRange): ?int {
if (null !== $calendarRange) { if (null !== $calendarRange) {
$res = $calendarRange->getId(); $res = $calendarRange->getId();
} else { } else {
@ -185,7 +185,7 @@ class CalendarType extends AbstractType
$builder->add('location', HiddenType::class) $builder->add('location', HiddenType::class)
->get('location') ->get('location')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (?Location $location): string { static function (?Location $location): string {
if (null === $location) { if (null === $location) {
return ''; return '';
} }
@ -200,7 +200,7 @@ class CalendarType extends AbstractType
$builder->add('invites', HiddenType::class); $builder->add('invites', HiddenType::class);
$builder->get('invites') $builder->get('invites')
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function (iterable $usersAsIterable): string { static function (iterable $usersAsIterable): string {
$userIds = []; $userIds = [];
foreach ($usersAsIterable as $value) { foreach ($usersAsIterable as $value) {

View File

@ -137,7 +137,7 @@ class CreateFieldsOnGroupCommand extends Command
"Enter the customfieldGroup's id on which the custom fields should be added: " "Enter the customfieldGroup's id on which the custom fields should be added: "
); );
$question->setNormalizer( $question->setNormalizer(
function ($answer) use ($customFieldsGroups) { static function ($answer) use ($customFieldsGroups) {
foreach ($customFieldsGroups as $customFieldsGroup) { foreach ($customFieldsGroups as $customFieldsGroup) {
if ($customFieldsGroup->getId() == $answer) { if ($customFieldsGroup->getId() == $answer) {
return $customFieldsGroup; return $customFieldsGroup;
@ -237,7 +237,7 @@ class CreateFieldsOnGroupCommand extends Command
array_walk( array_walk(
$customFieldsGroups, $customFieldsGroups,
function (CustomFieldsGroup $customFieldGroup, $key) use ($languages, &$rows, $customizableEntities) { static function (CustomFieldsGroup $customFieldGroup, $key) use ($languages, &$rows, $customizableEntities) {
//set id and entity //set id and entity
$row = [ $row = [
$customFieldGroup->getId(), $customFieldGroup->getId(),

View File

@ -77,7 +77,7 @@ class CustomFieldDate extends AbstractCustomField
public function buildOptionsForm(FormBuilderInterface $builder) public function buildOptionsForm(FormBuilderInterface $builder)
{ {
$validatorFunction = function ($value, ExecutionContextInterface $context) { $validatorFunction = static function ($value, ExecutionContextInterface $context) {
try { try {
$date = new DateTime($value); $date = new DateTime($value);
} catch (Exception $e) { } catch (Exception $e) {
@ -179,7 +179,7 @@ class CustomFieldDate extends AbstractCustomField
// add constraints if required // add constraints if required
if (null !== $options[self::MIN]) { if (null !== $options[self::MIN]) {
$fieldOptions['constraints'][] = new Callback( $fieldOptions['constraints'][] = new Callback(
function ($timestamp, ExecutionContextInterface $context) use ($options) { static function ($timestamp, ExecutionContextInterface $context) use ($options) {
if (null === $timestamp) { if (null === $timestamp) {
return; return;
} }
@ -200,7 +200,7 @@ class CustomFieldDate extends AbstractCustomField
if (null !== $options[self::MAX]) { if (null !== $options[self::MAX]) {
$fieldOptions['constraints'][] = new Callback( $fieldOptions['constraints'][] = new Callback(
function ($timestamp, ExecutionContextInterface $context) use ($options) { static function ($timestamp, ExecutionContextInterface $context) use ($options) {
if (null === $timestamp) { if (null === $timestamp) {
return; return;
} }

View File

@ -57,7 +57,7 @@ class CustomFieldLongChoice extends AbstractCustomField
$translatableStringHelper = $this->translatableStringHelper; $translatableStringHelper = $this->translatableStringHelper;
$builder->add($customField->getSlug(), Select2ChoiceType::class, [ $builder->add($customField->getSlug(), Select2ChoiceType::class, [
'choices' => $entries, 'choices' => $entries,
'choice_label' => function (Option $option) use ($translatableStringHelper) { 'choice_label' => static function (Option $option) use ($translatableStringHelper) {
return $translatableStringHelper->localize($option->getText()); return $translatableStringHelper->localize($option->getText());
}, },
'choice_value' => static fn (Option $key): ?int => null === $key ? null : $key->getId(), 'choice_value' => static fn (Option $key): ?int => null === $key ? null : $key->getId(),
@ -65,7 +65,7 @@ class CustomFieldLongChoice extends AbstractCustomField
'expanded' => false, 'expanded' => false,
'required' => $customField->isRequired(), 'required' => $customField->isRequired(),
'placeholder' => 'Choose a value', 'placeholder' => 'Choose a value',
'group_by' => function (Option $option) use ($translatableStringHelper) { 'group_by' => static function (Option $option) use ($translatableStringHelper) {
if ($option->hasParent()) { if ($option->hasParent()) {
return $translatableStringHelper->localize($option->getParent()->getText()); return $translatableStringHelper->localize($option->getParent()->getText());
} }

View File

@ -55,7 +55,7 @@ class OptionRepository extends EntityRepository
->getQuery() ->getQuery()
->getScalarResult(); ->getScalarResult();
return array_map(function ($r) { return array_map(static function ($r) {
return $r['key']; return $r['key'];
}, $keys); }, $keys);
} }

View File

@ -88,7 +88,7 @@ class CustomFieldType extends AbstractType
'label' => 'Required field', 'label' => 'Required field',
]) ])
->add('type', HiddenType::class, ['data' => $options['type']]) ->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(); $customField = $event->getData();
$form = $event->getForm(); $form = $event->getForm();

View File

@ -55,7 +55,7 @@ class CustomFieldsGroupType extends AbstractType
$builder->addEventListener( $builder->addEventListener(
FormEvents::POST_SET_DATA, FormEvents::POST_SET_DATA,
function (FormEvent $event) use ($customizableEntities, $builder) { static function (FormEvent $event) use ($customizableEntities, $builder) {
$form = $event->getForm(); $form = $event->getForm();
$group = $event->getData(); $group = $event->getData();

View File

@ -32,7 +32,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
// @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here? // @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here?
$customFieldsLablels = array_map( $customFieldsLablels = array_map(
function ($e) { return $e->getLabel(); }, static function ($e) { return $e->getLabel(); },
$customFields $customFields
); );

View File

@ -30,7 +30,7 @@ class ChoicesListType extends AbstractType
'required' => false, 'required' => false,
]) ])
->add('slug', HiddenType::class) ->add('slug', HiddenType::class)
->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) { ->addEventListener(FormEvents::SUBMIT, static function (FormEvent $event) {
$form = $event->getForm(); $form = $event->getForm();
$data = $event->getData(); $data = $event->getData();

View File

@ -59,7 +59,7 @@ class DocGenObjectNormalizer implements NormalizerInterface, NormalizerAwareInte
: []; : [];
$attributes = array_filter( $attributes = array_filter(
$metadata->getAttributesMetadata(), $metadata->getAttributesMetadata(),
function (AttributeMetadata $a) use ($expectedGroups) { static function (AttributeMetadata $a) use ($expectedGroups) {
foreach ($a->getGroups() as $g) { foreach ($a->getGroups() as $g) {
if (in_array($g, $expectedGroups, true)) { if (in_array($g, $expectedGroups, true)) {
return true; return true;

View File

@ -69,7 +69,7 @@ class AccompanyingCourseDocumentType extends AbstractType
->add('category', EntityType::class, [ ->add('category', EntityType::class, [
'placeholder' => 'Choose a document category', 'placeholder' => 'Choose a document category',
'class' => 'ChillDocStoreBundle:DocumentCategory', 'class' => 'ChillDocStoreBundle:DocumentCategory',
'query_builder' => function (EntityRepository $er) { 'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('c') return $er->createQueryBuilder('c')
->where('c.documentClass = :docClass') ->where('c.documentClass = :docClass')
->setParameter('docClass', PersonDocument::class); ->setParameter('docClass', PersonDocument::class);

View File

@ -73,7 +73,7 @@ class PersonDocumentType extends AbstractType
->add('category', EntityType::class, [ ->add('category', EntityType::class, [
'placeholder' => 'Choose a document category', 'placeholder' => 'Choose a document category',
'class' => 'ChillDocStoreBundle:DocumentCategory', 'class' => 'ChillDocStoreBundle:DocumentCategory',
'query_builder' => function (EntityRepository $er) { 'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('c') return $er->createQueryBuilder('c')
->where('c.documentClass = :docClass') ->where('c.documentClass = :docClass')
->setParameter('docClass', PersonDocument::class); ->setParameter('docClass', PersonDocument::class);

View File

@ -599,7 +599,7 @@ class EventController extends AbstractController
$response->setPrivate(); $response->setPrivate();
$response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('must-revalidate', true);
$response->setCallback(function () use ($writer) { $response->setCallback(static function () use ($writer) {
$writer->save('php://output'); $writer->save('php://output');
}); });

View File

@ -110,7 +110,7 @@ class ParticipationController extends AbstractController
[ [
'event_id' => current($participations)->getEvent()->getId(), 'event_id' => current($participations)->getEvent()->getId(),
'persons_ids' => implode(',', array_map( 'persons_ids' => implode(',', array_map(
function (Participation $p) { return $p->getPerson()->getId(); }, static function (Participation $p) { return $p->getPerson()->getId(); },
$participations $participations
)), )),
] ]
@ -646,13 +646,13 @@ class ParticipationController extends AbstractController
/** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */ /** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */
$peopleParticipating = $peopleParticipating ?? $peopleParticipating = $peopleParticipating ??
$participation->getEvent()->getParticipations()->map( $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 // check that the user is not already in the event
if ($peopleParticipating->contains($participation->getPerson()->getId())) { if ($peopleParticipating->contains($participation->getPerson()->getId())) {
$ignoredParticipations[] = $participation $ignoredParticipations[] = $participation
->getEvent()->getParticipations()->filter( ->getEvent()->getParticipations()->filter(
function (Participation $p) use ($participation) { static function (Participation $p) use ($participation) {
return $p->getPerson()->getId() === $participation->getPerson()->getId(); return $p->getPerson()->getId() === $participation->getPerson()->getId();
} }
)->first(); )->first();

View File

@ -174,7 +174,7 @@ class Event implements HasCenterInterface, HasScopeInterface
{ {
$iterator = $this->participations->getIterator(); $iterator = $this->participations->getIterator();
$iterator->uasort(function ($first, $second) { $iterator->uasort(static function ($first, $second) {
return strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName()); return strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName());
}); });

View File

@ -59,7 +59,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface
{ {
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
$this->lazyLoadedEvents, $this->lazyLoadedEvents,
function (Event $p) use ($value) { static function (Event $p) use ($value) {
return call_user_func($value, $p); return call_user_func($value, $p);
} }
); );

View File

@ -106,14 +106,14 @@ class PickEventType extends AbstractType
// add the default options // add the default options
$resolver->setDefaults([ $resolver->setDefaults([
'class' => Event::class, 'class' => Event::class,
'choice_label' => function (Event $e) { 'choice_label' => static function (Event $e) {
return $e->getDate()->format('d/m/Y, H:i') . ' → ' . return $e->getDate()->format('d/m/Y, H:i') . ' → ' .
// $e->getType()->getName()['fr'] . ': ' . // display the type of event // $e->getType()->getName()['fr'] . ': ' . // display the type of event
$e->getName(); $e->getName();
}, },
'placeholder' => 'Pick an event', 'placeholder' => 'Pick an event',
'attr' => ['class' => 'select2 '], 'attr' => ['class' => 'select2 '],
'choice_attr' => function (Event $e) { 'choice_attr' => static function (Event $e) {
return ['data-center' => $e->getCenter()->getId()]; return ['data-center' => $e->getCenter()->getId()];
}, },
'choiceloader' => function (Options $options) { 'choiceloader' => function (Options $options) {
@ -140,7 +140,7 @@ class PickEventType extends AbstractType
// option role // option role
if (null === $options['role']) { if (null === $options['role']) {
$centers = array_map( $centers = array_map(
function (GroupCenter $g) { static function (GroupCenter $g) {
return $g->getCenter(); return $g->getCenter();
}, },
$this->user->getGroupCenters()->toArray() $this->user->getGroupCenters()->toArray()
@ -169,7 +169,7 @@ class PickEventType extends AbstractType
} }
if (!in_array($c->getId(), array_map( if (!in_array($c->getId(), array_map(
function (Center $c) { return $c->getId(); }, static function (Center $c) { return $c->getId(); },
$centers $centers
))) { ))) {
throw new AccessDeniedException('The given center is not reachable'); throw new AccessDeniedException('The given center is not reachable');

View File

@ -37,14 +37,14 @@ class PickEventTypeType extends AbstractType
$resolver->setDefaults( $resolver->setDefaults(
[ [
'class' => EventType::class, 'class' => EventType::class,
'query_builder' => function (EntityRepository $er) { 'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('et') return $er->createQueryBuilder('et')
->where('et.active = true'); ->where('et.active = true');
}, },
'choice_label' => function (EventType $t) use ($helper) { 'choice_label' => static function (EventType $t) use ($helper) {
return $helper->localize($t->getName()); return $helper->localize($t->getName());
}, },
'choice_attrs' => function (EventType $t) { 'choice_attrs' => static function (EventType $t) {
return ['data-link-category' => $t->getId()]; return ['data-link-category' => $t->getId()];
}, },
] ]

View File

@ -109,13 +109,13 @@ class PickRoleType extends AbstractType
'class' => Role::class, 'class' => Role::class,
'query_builder' => $qb, 'query_builder' => $qb,
'group_by' => null, 'group_by' => null,
'choice_attr' => function (Role $r) { 'choice_attr' => static function (Role $r) {
return [ return [
'data-event-type' => $r->getType()->getId(), 'data-event-type' => $r->getType()->getId(),
'data-link-category' => $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()) . return $translatableStringHelper->localize($r->getName()) .
($r->getActive() === true ? '' : ($r->getActive() === true ? '' :
' (' . $translator->trans('unactive') . ')'); ' (' . $translator->trans('unactive') . ')');

View File

@ -110,13 +110,13 @@ class PickStatusType extends AbstractType
'class' => Status::class, 'class' => Status::class,
'query_builder' => $qb, 'query_builder' => $qb,
'group_by' => null, 'group_by' => null,
'choice_attr' => function (Status $s) { 'choice_attr' => static function (Status $s) {
return [ return [
'data-event-type' => $s->getType()->getId(), 'data-event-type' => $s->getType()->getId(),
'data-link-category' => $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()) . return $translatableStringHelper->localize($s->getName()) .
($s->getActive() === true ? '' : ($s->getActive() === true ? '' :
' (' . $translator->trans('unactive') . ')'); ' (' . $translator->trans('unactive') . ')');

View File

@ -237,7 +237,7 @@ class ParticipationControllerTest extends WebTestCase
$this->personsIdsCache = array_merge( $this->personsIdsCache = array_merge(
$this->personsIdsCache, $this->personsIdsCache,
$event->getParticipations()->map( $event->getParticipations()->map(
function ($p) { return $p->getPerson()->getId(); } static function ($p) { return $p->getPerson()->getId(); }
) )
->toArray() ->toArray()
); );
@ -301,7 +301,7 @@ class ParticipationControllerTest extends WebTestCase
$event = $this->getRandomEventWithMultipleParticipations(); $event = $this->getRandomEventWithMultipleParticipations();
$persons_id = implode(',', $event->getParticipations()->map( $persons_id = implode(',', $event->getParticipations()->map(
function ($p) { return $p->getPerson()->getId(); } static function ($p) { return $p->getPerson()->getId(); }
)->toArray()); )->toArray());
$crawler = $this->client->request( $crawler = $this->client->request(
@ -327,7 +327,7 @@ class ParticipationControllerTest extends WebTestCase
$nbParticipations = $event->getParticipations()->count(); $nbParticipations = $event->getParticipations()->count();
// get the persons_id participating on this event // get the persons_id participating on this event
$persons_id = $event->getParticipations()->map( $persons_id = $event->getParticipations()->map(
function ($p) { return $p->getPerson()->getId(); } static function ($p) { return $p->getPerson()->getId(); }
)->toArray(); )->toArray();
// exclude the existing persons_ids from the new person // exclude the existing persons_ids from the new person
$this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id); $this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id);
@ -456,7 +456,7 @@ class ParticipationControllerTest extends WebTestCase
$circles = $this->em->getRepository('ChillMainBundle:Scope') $circles = $this->em->getRepository('ChillMainBundle:Scope')
->findAll(); ->findAll();
array_filter($circles, function ($circle) use ($circleName) { array_filter($circles, static function ($circle) use ($circleName) {
return in_array($circleName, $circle->getName()); return in_array($circleName, $circle->getName());
}); });
$circle = $circles[0]; $circle = $circles[0];

View File

@ -365,7 +365,7 @@ class EventSearchTest extends WebTestCase
'décembre' => 12, '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 // we skip the first row
if (0 < $i) { if (0 < $i) {
// get the second node, which should contains a date // get the second node, which should contains a date

View File

@ -206,7 +206,7 @@ class TimelineEventProvider implements TimelineProviderInterface
foreach ($reachableCenters as $center) { foreach ($reachableCenters as $center) {
$reachableCircleId = array_map( $reachableCircleId = array_map(
function (Scope $scope) { return $scope->getId(); }, static function (Scope $scope) { return $scope->getId(); },
$this->helper->getReachableCircles($this->user, $role, $person->getCenter()) $this->helper->getReachableCircles($this->user, $role, $person->getCenter())
); );
$centerAndScopeLines[] = sprintf( $centerAndScopeLines[] = sprintf(

View File

@ -138,7 +138,7 @@ class CRUDRoutesLoader extends Loader
$methods = array_keys(array_filter( $methods = array_keys(array_filter(
$action['methods'], $action['methods'],
function ($value, $key) { return $value; }, static function ($value, $key) { return $value; },
ARRAY_FILTER_USE_BOTH ARRAY_FILTER_USE_BOTH
)); ));

View File

@ -325,7 +325,7 @@ class ChillImportUsersCommand extends Command
$question $question
->setMultiselect(true) ->setMultiselect(true)
->setAutocompleterValues(array_keys($permissionGroupsByName)) ->setAutocompleterValues(array_keys($permissionGroupsByName))
->setNormalizer(function ($value) { ->setNormalizer(static function ($value) {
if (null === $value) { if (null === $value) {
return ''; return '';
} }

View File

@ -155,7 +155,7 @@ class PermissionsGroupController extends AbstractController
'edit_form' => $editForm->createView(), 'edit_form' => $editForm->createView(),
'role_scopes_sorted' => $roleScopesSorted, 'role_scopes_sorted' => $roleScopesSorted,
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), '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(); return $form->createView();
}, $deleteRoleScopesForm), }, $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView(), 'add_role_scopes_form' => $addRoleScopesForm->createView(),
@ -302,7 +302,7 @@ class PermissionsGroupController extends AbstractController
'role_scopes_sorted' => $roleScopesSorted, 'role_scopes_sorted' => $roleScopesSorted,
'edit_form' => $editForm->createView(), 'edit_form' => $editForm->createView(),
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), '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(); return $form->createView();
}, $deleteRoleScopesForm), }, $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView(), 'add_role_scopes_form' => $addRoleScopesForm->createView(),
@ -358,7 +358,7 @@ class PermissionsGroupController extends AbstractController
// sort $roleScopes by name // sort $roleScopes by name
usort( usort(
$roleScopes, $roleScopes,
function (RoleScope $a, RoleScope $b) use ($translatableStringHelper) { static function (RoleScope $a, RoleScope $b) use ($translatableStringHelper) {
if ($a->getScope() === null) { if ($a->getScope() === null) {
return 1; return 1;
} }
@ -446,7 +446,7 @@ class PermissionsGroupController extends AbstractController
'role_scopes_sorted' => $roleScopesSorted, 'role_scopes_sorted' => $roleScopesSorted,
'edit_form' => $editForm->createView(), 'edit_form' => $editForm->createView(),
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), '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(); return $form->createView();
}, $deleteRoleScopesForm), }, $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView(), 'add_role_scopes_form' => $addRoleScopesForm->createView(),
@ -570,7 +570,7 @@ class PermissionsGroupController extends AbstractController
if (!array_key_exists($roleScope->getRole(), $expandedRoles)) { if (!array_key_exists($roleScope->getRole(), $expandedRoles)) {
$expandedRoles[$roleScope->getRole()] = $expandedRoles[$roleScope->getRole()] =
array_map( array_map(
function (Role $role) { static function (Role $role) {
return $role->getRole(); return $role->getRole();
}, },
$this->roleHierarchy $this->roleHierarchy

View File

@ -237,7 +237,7 @@ class UserController extends CRUDController
[ [
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(), 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(),
'delete_groupcenter_form' => array_map( 'delete_groupcenter_form' => array_map(
function (Form $form) { static function (Form $form) {
return $form->createView(); return $form->createView();
}, },
iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true) iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true)

View File

@ -35,7 +35,7 @@ class MenuCompilerPass implements CompilerPassInterface
]; ];
} }
usort($services, function ($a, $b) { usort($services, static function ($a, $b) {
if ($a['priority'] == $b['priority']) { if ($a['priority'] == $b['priority']) {
return 0; return 0;
} }

View File

@ -119,7 +119,7 @@ class PermissionsGroup
public function isRoleScopePresentOnce(ExecutionContextInterface $context) public function isRoleScopePresentOnce(ExecutionContextInterface $context)
{ {
$roleScopesId = array_map( $roleScopesId = array_map(
function (RoleScope $roleScope) { static function (RoleScope $roleScope) {
return $roleScope->getId(); return $roleScope->getId();
}, },
$this->getRoleScopes()->toArray() $this->getRoleScopes()->toArray()

View File

@ -168,7 +168,7 @@ class CSVFormatter implements FormatterInterface
// gather data in an array // gather data in an array
foreach ($keys as $key) { 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)) { if (!array_key_exists($key, $row)) {
throw new LogicException("the key '" . $key . "' is declared by " throw new LogicException("the key '" . $key . "' is declared by "
. "the aggregator with alias '" . $alias . "' but is not " . "the aggregator with alias '" . $alias . "' but is not "
@ -195,7 +195,7 @@ class CSVFormatter implements FormatterInterface
$keys = $this->export->getQueryKeys($this->exportData); $keys = $this->export->getQueryKeys($this->exportData);
foreach ($keys as $key) { 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)) { if (!array_key_exists($key, $row)) {
throw new LogicException("the key '" . $key . "' is declared by " throw new LogicException("the key '" . $key . "' is declared by "
. "the export with title '" . $export->getTitle() . "' but is not " . "the export with title '" . $export->getTitle() . "' but is not "

View File

@ -196,7 +196,7 @@ class CSVListFormatter implements FormatterInterface
foreach ($keys as $key) { foreach ($keys as $key) {
// get an array with all values for this key if possible // 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 // store the label in the labelsCache property
$this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData); $this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData);
} }

View File

@ -184,7 +184,7 @@ class CSVPivotedListFormatter implements FormatterInterface
foreach ($keys as $key) { foreach ($keys as $key) {
// get an array with all values for this key if possible // 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 // store the label in the labelsCache property
$this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData); $this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData);
} }

View File

@ -255,7 +255,7 @@ class SpreadsheetListFormatter implements FormatterInterface
foreach ($keys as $key) { foreach ($keys as $key) {
// get an array with all values for this key if possible // 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 // store the label in the labelsCache property
$this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData); $this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData);
} }

View File

@ -45,7 +45,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface
{ {
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
$this->lazyLoadedPostalCodes, $this->lazyLoadedPostalCodes,
function (?PostalCode $pc = null) use ($value) { static function (?PostalCode $pc = null) use ($value) {
return call_user_func($value, $pc); return call_user_func($value, $pc);
} }
); );

View File

@ -33,7 +33,7 @@ final class LocationFormType extends AbstractType
$builder $builder
->add('locationType', EntityType::class, [ ->add('locationType', EntityType::class, [
'class' => EntityLocationType::class, 'class' => EntityLocationType::class,
'choice_attr' => function (EntityLocationType $entity) { 'choice_attr' => static function (EntityLocationType $entity) {
return [ return [
'data-address' => $entity->getAddressRequired(), 'data-address' => $entity->getAddressRequired(),
'data-contact' => $entity->getContactData(), 'data-contact' => $entity->getContactData(),

View File

@ -117,7 +117,7 @@ trait AppendScopeChoiceTypeTrait
$builder->addEventListener( $builder->addEventListener(
FormEvents::PRE_SET_DATA, 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 = $event->getForm();
$form->add( $form->add(
$builder $builder

View File

@ -23,12 +23,12 @@ class ComposedGroupCenterType extends AbstractType
{ {
$builder->add('permissionsgroup', EntityType::class, [ $builder->add('permissionsgroup', EntityType::class, [
'class' => 'Chill\MainBundle\Entity\PermissionsGroup', 'class' => 'Chill\MainBundle\Entity\PermissionsGroup',
'choice_label' => function (PermissionsGroup $group) { 'choice_label' => static function (PermissionsGroup $group) {
return $group->getName(); return $group->getName();
}, },
])->add('center', EntityType::class, [ ])->add('center', EntityType::class, [
'class' => 'Chill\MainBundle\Entity\Center', 'class' => 'Chill\MainBundle\Entity\Center',
'choice_label' => function (Center $center) { 'choice_label' => static function (Center $center) {
return $center->getName(); return $center->getName();
}, },
]); ]);

View File

@ -73,7 +73,7 @@ class ComposedRoleScopeType extends AbstractType
->add('role', ChoiceType::class, [ ->add('role', ChoiceType::class, [
'choices' => array_combine(array_values($values), array_keys($values)), 'choices' => array_combine(array_values($values), array_keys($values)),
'placeholder' => 'Choose amongst roles', 'placeholder' => 'Choose amongst roles',
'choice_attr' => function ($role) use ($rolesWithoutScopes) { 'choice_attr' => static function ($role) use ($rolesWithoutScopes) {
if (in_array($role, $rolesWithoutScopes)) { if (in_array($role, $rolesWithoutScopes)) {
return ['data-has-scope' => '0']; return ['data-has-scope' => '0'];
} }
@ -86,7 +86,7 @@ class ComposedRoleScopeType extends AbstractType
]) ])
->add('scope', EntityType::class, [ ->add('scope', EntityType::class, [
'class' => 'ChillMainBundle:Scope', 'class' => 'ChillMainBundle:Scope',
'choice_label' => function (Scope $scope) use ($translatableStringHelper) { 'choice_label' => static function (Scope $scope) use ($translatableStringHelper) {
return $translatableStringHelper->localize($scope->getName()); return $translatableStringHelper->localize($scope->getName());
}, },
'required' => false, 'required' => false,

View File

@ -82,7 +82,7 @@ class DateIntervalType extends AbstractType
'Months' => 'M', 'Months' => 'M',
'Years' => 'Y', 'Years' => 'Y',
]) ])
->setAllowedValues('unit_choices', function ($values) { ->setAllowedValues('unit_choices', static function ($values) {
if (false === is_array($values)) { if (false === is_array($values)) {
throw new InvalidOptionsException('The value `unit_choice` should be an array'); throw new InvalidOptionsException('The value `unit_choice` should be an array');
} }

View File

@ -80,10 +80,10 @@ class PickCenterType extends AbstractType
$builder->add(self::CENTERS_IDENTIFIERS, EntityType::class, [ $builder->add(self::CENTERS_IDENTIFIERS, EntityType::class, [
'class' => 'ChillMainBundle:Center', 'class' => 'ChillMainBundle:Center',
'query_builder' => function (EntityRepository $er) use ($centers) { 'query_builder' => static function (EntityRepository $er) use ($centers) {
$qb = $er->createQueryBuilder('c'); $qb = $er->createQueryBuilder('c');
$ids = array_map( $ids = array_map(
function (Center $el) { return $el->getId(); }, static function (Center $el) { return $el->getId(); },
$centers $centers
); );
@ -91,7 +91,7 @@ class PickCenterType extends AbstractType
}, },
'multiple' => true, 'multiple' => true,
'expanded' => 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, 'data' => count($this->groupingCenters) > 0 ? null : $centers,
]); ]);

View File

@ -46,7 +46,7 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType
foreach ($helper->getCheckboxes() as $name => $c) { foreach ($helper->getCheckboxes() as $name => $c) {
$choices = array_combine( $choices = array_combine(
array_map(function ($c, $t) { array_map(static function ($c, $t) {
if (null !== $t) { if (null !== $t) {
return $t; return $t;
} }

View File

@ -80,14 +80,14 @@ class PickCenterType extends AbstractType
$builder $builder
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
function ($data) { static function ($data) {
if (null === $data) { if (null === $data) {
return ['center' => null]; return ['center' => null];
} }
return ['center' => $data]; return ['center' => $data];
}, },
function ($data) { static function ($data) {
return $data['center']; return $data['center'];
} }
)); ));

View File

@ -75,7 +75,7 @@ class PostalCodeType extends AbstractType
$helper = $this->translatableStringHelper; $helper = $this->translatableStringHelper;
$resolver $resolver
->setDefault('class', PostalCode::class) ->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() . ' [' . return $code->getCode() . ' ' . $code->getName() . ' [' .
$helper->localize($code->getCountry()->getName()) . ']'; $helper->localize($code->getCountry()->getName()) . ']';
}) })

View File

@ -141,7 +141,7 @@ class ScopePickerType extends AbstractType
->join('pg.groupCenters', 'gc') ->join('pg.groupCenters', 'gc')
// add center constraint // add center constraint
->where($qb->expr()->in('IDENTITY(gc.center)', ':centers')) ->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 // role constraints
->andWhere($qb->expr()->in('rs.role', ':roles')) ->andWhere($qb->expr()->in('rs.role', ':roles'))
->setParameter('roles', $roles) ->setParameter('roles', $roles)

View File

@ -72,7 +72,7 @@ class UserPickerType extends AbstractType
->setAllowedTypes('having_permissions_group_flag', ['string', 'null']) ->setAllowedTypes('having_permissions_group_flag', ['string', 'null'])
->setDefault('class', User::class) ->setDefault('class', User::class)
->setDefault('placeholder', 'Choose an user') ->setDefault('placeholder', 'Choose an user')
->setDefault('choice_label', function (User $u) { ->setDefault('choice_label', static function (User $u) {
return $u->getUsername(); return $u->getUsername();
}) })
->setDefault('scope', null) ->setDefault('scope', null)

View File

@ -49,7 +49,7 @@ class UserType extends AbstractType
'required' => false, 'required' => false,
'placeholder' => 'Choose a main center', 'placeholder' => 'Choose a main center',
'class' => Center::class, 'class' => Center::class,
'query_builder' => function (EntityRepository $er) { 'query_builder' => static function (EntityRepository $er) {
$qb = $er->createQueryBuilder('c'); $qb = $er->createQueryBuilder('c');
$qb->addOrderBy('c.name'); $qb->addOrderBy('c.name');

View File

@ -31,7 +31,7 @@ class SearchUserApiProvider implements SearchApiInterface
public function prepare(array $metadatas): void 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]); $this->userRepository->findBy(['id' => $ids]);
} }

View File

@ -161,7 +161,7 @@ class SearchApi
private function findQueries($pattern, array $types, array $parameters): array private function findQueries($pattern, array $types, array $parameters): array
{ {
return array_map( return array_map(
fn ($p) => $p->provideQuery($pattern, $parameters), static fn ($p) => $p->provideQuery($pattern, $parameters),
$this->findProviders($pattern, $types, $parameters), $this->findProviders($pattern, $types, $parameters),
); );
} }

View File

@ -88,7 +88,7 @@ class SearchProvider
public function getByOrder() public function getByOrder()
{ {
//sort the array //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()) { if ($a->getOrder() == $b->getOrder()) {
return 0; return 0;
} }
@ -121,7 +121,7 @@ class SearchProvider
public function getHasAdvancedFormSearchServices() public function getHasAdvancedFormSearchServices()
{ {
//sort the array //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()) { if ($a->getOrder() == $b->getOrder()) {
return 0; return 0;
} }

View File

@ -230,7 +230,7 @@ class ExportManagerTest extends KernelTestCase
Argument::Type('array'), Argument::Type('array'),
Argument::is(['a' => 'b']) Argument::is(['a' => 'b'])
) )
->will(function () use ($em) { ->will(static function () use ($em) {
$qb = $em->createQueryBuilder(); $qb = $em->createQueryBuilder();
return $qb->addSelect('COUNT(user.id) as export') return $qb->addSelect('COUNT(user.id) as export')
@ -254,7 +254,7 @@ class ExportManagerTest extends KernelTestCase
Argument::is([0, 1]), Argument::is([0, 1]),
Argument::Type('array') Argument::Type('array')
) )
->willReturn(function ($value) { ->willReturn(static function ($value) {
switch ($value) { switch ($value) {
case 0: case 0:
case 1: case 1:
@ -294,7 +294,7 @@ class ExportManagerTest extends KernelTestCase
Argument::is(['cat a', 'cat b']), Argument::is(['cat a', 'cat b']),
Argument::is([]) Argument::is([])
) )
->willReturn(function ($value) { ->willReturn(static function ($value) {
switch ($value) { switch ($value) {
case '_header': return 'foo_header'; case '_header': return 'foo_header';

View File

@ -50,7 +50,7 @@ class ExtractDateFromPatternTest extends TestCase
$this->assertContainsOnlyInstancesOf(DateTimeImmutable::class, $result->getFound()); $this->assertContainsOnlyInstancesOf(DateTimeImmutable::class, $result->getFound());
$dates = array_map( $dates = array_map(
function (DateTimeImmutable $d) { static function (DateTimeImmutable $d) {
return $d->format('Y-m-d'); return $d->format('Y-m-d');
}, },
$result->getFound() $result->getFound()

View File

@ -206,7 +206,7 @@ class AuthorizationHelperTest extends KernelTestCase
$centerA $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); $this->assertContains('center a_social', $usernames);
} }

View File

@ -77,7 +77,7 @@ class DateRangeCoveringTest extends TestCase
$intersections = $cover->getIntersections(); $intersections = $cover->getIntersections();
// sort the intersections to compare them in expected order // 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]) { if ($a[0] === $b[0]) {
return $a[1] <=> $b[1]; return $a[1] <=> $b[1];
} }

View File

@ -360,7 +360,7 @@ class CountriesInfo
if (null === self::$cacheCountriesCodeByContinent) { if (null === self::$cacheCountriesCodeByContinent) {
$data = self::getArrayCountriesData(); $data = self::getArrayCountriesData();
array_walk($data, function ($item, $key) { array_walk($data, static function ($item, $key) {
self::$cacheCountriesCodeByContinent[$item[0]][] = $item[1]; self::$cacheCountriesCodeByContinent[$item[0]][] = $item[1];
}); });
} }

View File

@ -526,7 +526,7 @@ final class ImportPeopleFromCSVCommand extends Command
} }
$centersByName = []; $centersByName = [];
$names = array_map(function (Center $c) use (&$centersByName) { $names = array_map(static function (Center $c) use (&$centersByName) {
$n = $c->getName(); $n = $c->getName();
$centersByName[$n] = $c; $centersByName[$n] = $c;
@ -609,7 +609,7 @@ final class ImportPeopleFromCSVCommand extends Command
} }
$postalCodeByName = []; $postalCodeByName = [];
$names = array_map(function (PostalCode $pc) use (&$postalCodeByName) { $names = array_map(static function (PostalCode $pc) use (&$postalCodeByName) {
$n = $pc->getName(); $n = $pc->getName();
$postalCodeByName[$n] = $pc; $postalCodeByName[$n] = $pc;
@ -859,7 +859,7 @@ final class ImportPeopleFromCSVCommand extends Command
if (!isset($this->cacheAnswersMapping[$cf->getSlug()][$value])) { if (!isset($this->cacheAnswersMapping[$cf->getSlug()][$value])) {
// try to find the answer (with array_keys and a search value // try to find the answer (with array_keys and a search value
$values = array_keys( $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)), trim(strtolower($value)),
true true
); );

View File

@ -322,7 +322,7 @@ class AccompanyingPeriodController extends AbstractController
/** @var AccompanyingPeriod $period */ /** @var AccompanyingPeriod $period */
$period = array_filter( $period = array_filter(
$person->getAccompanyingPeriods(), $person->getAccompanyingPeriods(),
function (AccompanyingPeriod $p) use ($period_id) { static function (AccompanyingPeriod $p) use ($period_id) {
return $p->getId() === ($period_id); return $p->getId() === ($period_id);
} }
)[0] ?? null; )[0] ?? null;

View File

@ -106,7 +106,7 @@ class HouseholdApiController extends ApiController
$actual = $household->getCurrentAddress(); $actual = $household->getCurrentAddress();
if (null !== $actual) { if (null !== $actual) {
$addresses = array_filter($addresses, fn ($a) => $a !== $actual); $addresses = array_filter($addresses, static fn ($a) => $a !== $actual);
} }
return $this->json( return $this->json(

View File

@ -62,7 +62,7 @@ class PersonApiController extends ApiController
$actual = $person->getCurrentHouseholdAddress(); $actual = $person->getCurrentHouseholdAddress();
if (null !== $actual) { 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']]); return $this->json(array_values($addresses), Response::HTTP_OK, [], ['groups' => ['read']]);

View File

@ -113,7 +113,7 @@ class LoadCustomFields extends AbstractFixture implements
// get possible values for cfGroup // get possible values for cfGroup
$choices = array_map( $choices = array_map(
function ($a) { return $a['slug']; }, static function ($a) { return $a['slug']; },
$this->customFieldChoice->getOptions()['choices'] $this->customFieldChoice->getOptions()['choices']
); );
// create faker // create faker

View File

@ -44,7 +44,7 @@ class Configuration implements ConfigurationInterface
->info($this->validationBirthdateNotAfterInfos) ->info($this->validationBirthdateNotAfterInfos)
->defaultValue('P1D') ->defaultValue('P1D')
->validate() ->validate()
->ifTrue(function ($period) { ->ifTrue(static function ($period) {
try { try {
$interval = new DateInterval($period); $interval = new DateInterval($period);
} catch (Exception $ex) { } catch (Exception $ex) {

View File

@ -520,10 +520,10 @@ class AccompanyingPeriod implements
public function getAvailablePersonLocation(): Collection public function getAvailablePersonLocation(): Collection
{ {
return $this->getOpenParticipations() return $this->getOpenParticipations()
->filter(function (AccompanyingPeriodParticipation $p) { ->filter(static function (AccompanyingPeriodParticipation $p) {
return $p->getPerson()->hasCurrentHouseholdAddress(); return $p->getPerson()->hasCurrentHouseholdAddress();
}) })
->map(function (AccompanyingPeriodParticipation $p) { ->map(static function (AccompanyingPeriodParticipation $p) {
return $p->getPerson(); return $p->getPerson();
}); });
} }

View File

@ -139,7 +139,7 @@ class Household
{ {
$at = null === $at ? new DateTime('today') : $at; $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 && ( return $a->getValidFrom() <= $at && (
null === $a->getValidTo() || $a->getValidTo() > $at null === $a->getValidTo() || $a->getValidTo() > $at
); );
@ -178,7 +178,7 @@ class Household
public function getCurrentMembersIds(?DateTimeImmutable $now = null): Collection public function getCurrentMembersIds(?DateTimeImmutable $now = null): Collection
{ {
return $this->getCurrentMembers($now)->map( return $this->getCurrentMembers($now)->map(
fn (HouseholdMember $m) => $m->getId() static fn (HouseholdMember $m) => $m->getId()
); );
} }
@ -191,7 +191,7 @@ class Household
$members->getIterator() $members->getIterator()
->uasort( ->uasort(
function (HouseholdMember $a, HouseholdMember $b) { static function (HouseholdMember $a, HouseholdMember $b) {
if ($a->getPosition() === null) { if ($a->getPosition() === null) {
if ($b->getPosition() === null) { if ($b->getPosition() === null) {
return 0; return 0;
@ -247,7 +247,7 @@ class Household
public function getCurrentPersons(?DateTimeImmutable $now = null): Collection public function getCurrentPersons(?DateTimeImmutable $now = null): Collection
{ {
return $this->getCurrentMembers($now) return $this->getCurrentMembers($now)
->map(function (HouseholdMember $m) { return $m->getPerson(); }); ->map(static function (HouseholdMember $m) { return $m->getPerson(); });
} }
public function getId(): ?int public function getId(): ?int
@ -269,7 +269,7 @@ class Household
$membership->getStartDate(), $membership->getStartDate(),
$membership->getEndDate() $membership->getEndDate()
)->filter( )->filter(
function (HouseholdMember $m) use ($membership) { static function (HouseholdMember $m) use ($membership) {
return $m !== $membership; return $m !== $membership;
} }
); );

View File

@ -774,7 +774,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
$periods = $this->getAccompanyingPeriods(); $periods = $this->getAccompanyingPeriods();
//order by date : //order by date :
usort($periods, function ($a, $b) { usort($periods, static function ($a, $b) {
$dateA = $a->getOpeningDate(); $dateA = $a->getOpeningDate();
$dateB = $b->getOpeningDate(); $dateB = $b->getOpeningDate();
@ -1296,7 +1296,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->getAccompanyingPeriodParticipations() return $this->getAccompanyingPeriodParticipations()
->matching($criteria) ->matching($criteria)
->filter(function (AccompanyingPeriodParticipation $app) { ->filter(static function (AccompanyingPeriodParticipation $app) {
return AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep(); return AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep();
}); });
} }

View File

@ -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]; return $labels[$value];
}; };
} }

View File

@ -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]; return $labels[$value];
}; };
} }

View File

@ -56,7 +56,7 @@ class CountPerson implements ExportInterface
$labels = array_combine($values, $values); $labels = array_combine($values, $values);
$labels['_header'] = $this->getTitle(); $labels['_header'] = $this->getTitle();
return function ($value) use ($labels) { return static function ($value) use ($labels) {
return $labels[$value]; return $labels[$value];
}; };
} }
@ -88,7 +88,7 @@ class CountPerson implements ExportInterface
*/ */
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) 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(); $qb = $this->entityManager->createQueryBuilder();

View File

@ -102,7 +102,7 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
return []; return [];
}, },
'constraints' => [new Callback([ 'constraints' => [new Callback([
'callback' => function ($selected, ExecutionContextInterface $context) { 'callback' => static function ($selected, ExecutionContextInterface $context) {
if (count($selected) === 0) { if (count($selected) === 0) {
$context->buildViolation('You must select at least one element') $context->buildViolation('You must select at least one element')
->atPath('fields') ->atPath('fields')
@ -266,7 +266,7 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) 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 // throw an error if any fields are present
if (!array_key_exists('fields', $data)) { if (!array_key_exists('fields', $data)) {

View File

@ -63,7 +63,7 @@ class GenderFilter implements
$qb->add('where', $where); $qb->add('where', $where);
$qb->setParameter('person_gender', array_filter( $qb->setParameter('person_gender', array_filter(
$data['accepted_genders'], $data['accepted_genders'],
function ($el) { static function ($el) {
return 'null' !== $el; return 'null' !== $el;
} }
)); ));

View File

@ -52,7 +52,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
{ {
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
$this->lazyLoadedPersons, $this->lazyLoadedPersons,
function (Person $p) use ($value) { static function (Person $p) use ($value) {
return call_user_func($value, $p); return call_user_func($value, $p);
} }
); );

View File

@ -111,10 +111,10 @@ class PersonType extends AbstractType
]); ]);
$builder->get('placeOfBirth')->addModelTransformer(new CallbackTransformer( $builder->get('placeOfBirth')->addModelTransformer(new CallbackTransformer(
function ($string) { static function ($string) {
return strtoupper($string); return strtoupper($string);
}, },
function ($string) { static function ($string) {
return strtoupper($string); return strtoupper($string);
} }
)); ));
@ -148,7 +148,7 @@ class PersonType extends AbstractType
'allow_delete' => true, 'allow_delete' => true,
'by_reference' => false, 'by_reference' => false,
'label' => false, 'label' => false,
'delete_empty' => function (?PersonPhone $pp = null) { 'delete_empty' => static function (?PersonPhone $pp = null) {
return null === $pp || $pp->isEmpty(); return null === $pp || $pp->isEmpty();
}, },
'error_bubbling' => false, 'error_bubbling' => false,
@ -192,7 +192,7 @@ class PersonType extends AbstractType
'choice_label' => function (Civility $civility): string { 'choice_label' => function (Civility $civility): string {
return $this->translatableStringHelper->localize($civility->getName()); return $this->translatableStringHelper->localize($civility->getName());
}, },
'query_builder' => function (EntityRepository $er): QueryBuilder { 'query_builder' => static function (EntityRepository $er): QueryBuilder {
return $er->createQueryBuilder('c') return $er->createQueryBuilder('c')
->where('c.active = true'); ->where('c.active = true');
}, },

View File

@ -110,11 +110,11 @@ class PickPersonType extends AbstractType
// add the default options // add the default options
$resolver->setDefaults([ $resolver->setDefaults([
'class' => Person::class, 'class' => Person::class,
'choice_label' => function (Person $p) { 'choice_label' => static function (Person $p) {
return $p->getFirstname() . ' ' . $p->getLastname(); return $p->getFirstname() . ' ' . $p->getLastname();
}, },
'placeholder' => 'Pick a person', 'placeholder' => 'Pick a person',
'choice_attr' => function (Person $p) { 'choice_attr' => static function (Person $p) {
return [ return [
'data-center' => $p->getCenter()->getId(), 'data-center' => $p->getCenter()->getId(),
]; ];
@ -136,7 +136,7 @@ class PickPersonType extends AbstractType
protected function filterCentersfom(Options $options) protected function filterCentersfom(Options $options)
{ {
if (null === $options['role']) { if (null === $options['role']) {
$centers = array_map(function (GroupCenter $g) { $centers = array_map(static function (GroupCenter $g) {
return $g->getCenter(); return $g->getCenter();
}, $this->user->getGroupCenters()->toArray()); }, $this->user->getGroupCenters()->toArray());
} else { } else {
@ -160,7 +160,7 @@ class PickPersonType extends AbstractType
} }
if (!in_array($c->getId(), array_map( if (!in_array($c->getId(), array_map(
function (Center $c) { return $c->getId(); }, static function (Center $c) { return $c->getId(); },
$centers $centers
))) { ))) {
throw new AccessDeniedException('The given center is not reachable'); throw new AccessDeniedException('The given center is not reachable');

View File

@ -73,7 +73,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
$involved = $this->getInvolved(); $involved = $this->getInvolved();
$involved['period_id'] = $event->getPeriod()->getId(); $involved['period_id'] = $event->getPeriod()->getId();
$involved['persons'] = $event->getPeriod()->getPersons() $involved['persons'] = $event->getPeriod()->getPersons()
->map(function (Person $p) { return $p->getId(); }) ->map(static function (Person $p) { return $p->getId(); })
->toArray(); ->toArray();
$this->logger->notice( $this->logger->notice(
@ -97,7 +97,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
if ($event->hasPersons()) { if ($event->hasPersons()) {
$involved['persons'] = array_map( $involved['persons'] = array_map(
function (Person $p) { return $p->getId(); }, static function (Person $p) { return $p->getId(); },
$event->getPersons() $event->getPersons()
); );
} }

View File

@ -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)
); );
} }
} }

View File

@ -208,7 +208,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
'persons' => $this->search($terms, $start, $limit, $options), 'persons' => $this->search($terms, $start, $limit, $options),
'pattern' => $this->recomposePattern( 'pattern' => $this->recomposePattern(
$terms, $terms,
array_filter(self::POSSIBLE_KEYS, fn ($item) => '_default' !== $item), array_filter(self::POSSIBLE_KEYS, static fn ($item) => '_default' !== $item),
$terms['_domain'] $terms['_domain']
), ),
'total' => $total, 'total' => $total,

View File

@ -58,7 +58,7 @@ class SearchPersonApiProvider implements SearchApiInterface
public function prepare(array $metadatas): void 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); $this->personRepository->findByIds($ids);
} }

View File

@ -87,7 +87,7 @@ class AccompanyingPeriodWorkDenormalizer implements DenormalizerAwareInterface,
// partition the separate kept evaluations and removed one // partition the separate kept evaluations and removed one
[$kept, $removed] = $work->getAccompanyingPeriodWorkEvaluations() [$kept, $removed] = $work->getAccompanyingPeriodWorkEvaluations()
->partition( ->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 // remove the evaluations from work

View File

@ -61,7 +61,7 @@ class PersonDocGenNormalizer implements
'altNames' => implode( 'altNames' => implode(
', ', ', ',
array_map( array_map(
function (PersonAltName $altName) { static function (PersonAltName $altName) {
return $altName->getLabel(); return $altName->getLabel();
}, },
$person->getAltNames()->toArray() $person->getAltNames()->toArray()

View File

@ -33,7 +33,7 @@ class SocialIssueNormalizer implements NormalizerInterface, NormalizerAwareInter
'type' => 'social_issue', 'type' => 'social_issue',
'id' => $socialIssue->getId(), 'id' => $socialIssue->getId(),
'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null, '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(), 'title' => $socialIssue->getTitle(),
'text' => $this->render->renderString($socialIssue, []), 'text' => $this->render->renderString($socialIssue, []),
]; ];

View File

@ -329,7 +329,7 @@ class AccompanyingCourseApiControllerTest extends WebTestCase
// check that the person id is contained // check that the person id is contained
$participationsPersonsIds = array_map( $participationsPersonsIds = array_map(
function ($participation) { return $participation->person->id; }, static function ($participation) { return $participation->person->id; },
$data->participations $data->participations
); );

View File

@ -151,7 +151,7 @@ class HouseholdApiControllerTest extends WebTestCase
$this->assertArrayHasKey('count', $data); $this->assertArrayHasKey('count', $data);
$this->assertArrayHasKey('results', $data); $this->assertArrayHasKey('results', $data);
$householdIds = array_map(function ($r) { $householdIds = array_map(static function ($r) {
return $r['id']; return $r['id'];
}, $data['results']); }, $data['results']);

View File

@ -290,22 +290,22 @@ class PersonControllerUpdateTest extends WebTestCase
public function validTextFieldsProvider() public function validTextFieldsProvider()
{ {
return [ return [
['firstName', 'random Value', function (Person $person) { return $person->getFirstName(); }], ['firstName', 'random Value', static function (Person $person) { return $person->getFirstName(); }],
['lastName', 'random Value', function (Person $person) { return $person->getLastName(); }], ['lastName', 'random Value', static function (Person $person) { return $person->getLastName(); }],
// reminder: this value is capitalized // reminder: this value is capitalized
['placeOfBirth', 'A PLACE', function (Person $person) { return $person->getPlaceOfBirth(); }], ['placeOfBirth', 'A PLACE', static function (Person $person) { return $person->getPlaceOfBirth(); }],
['birthdate', '1980-12-15', function (Person $person) { return $person->getBirthdate()->format('Y-m-d'); }], ['birthdate', '1980-12-15', static function (Person $person) { return $person->getBirthdate()->format('Y-m-d'); }],
['phonenumber', '+32123456789', function (Person $person) { return $person->getPhonenumber(); }], ['phonenumber', '+32123456789', static function (Person $person) { return $person->getPhonenumber(); }],
['memo', 'jfkdlmq jkfldmsq jkmfdsq', function (Person $person) { return $person->getMemo(); }], ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) { return $person->getMemo(); }],
['countryOfBirth', 'BE', function (Person $person) { return $person->getCountryOfBirth()->getCountryCode(); }], ['countryOfBirth', 'BE', static function (Person $person) { return $person->getCountryOfBirth()->getCountryCode(); }],
['nationality', 'FR', function (Person $person) { return $person->getNationality()->getCountryCode(); }], ['nationality', 'FR', static function (Person $person) { return $person->getNationality()->getCountryCode(); }],
['placeOfBirth', '', function (Person $person) { return $person->getPlaceOfBirth(); }], ['placeOfBirth', '', static function (Person $person) { return $person->getPlaceOfBirth(); }],
['birthdate', '', function (Person $person) { return $person->getBirthdate(); }], ['birthdate', '', static function (Person $person) { return $person->getBirthdate(); }],
['phonenumber', '', function (Person $person) { return $person->getPhonenumber(); }], ['phonenumber', '', static function (Person $person) { return $person->getPhonenumber(); }],
['memo', '', function (Person $person) { return $person->getMemo(); }], ['memo', '', static function (Person $person) { return $person->getMemo(); }],
['countryOfBirth', null, function (Person $person) { return $person->getCountryOfBirth(); }], ['countryOfBirth', null, static function (Person $person) { return $person->getCountryOfBirth(); }],
['nationality', null, function (Person $person) { return $person->getNationality(); }], ['nationality', null, static function (Person $person) { return $person->getNationality(); }],
['gender', Person::FEMALE_GENDER, function (Person $person) { return $person->getGender(); }], ['gender', Person::FEMALE_GENDER, static function (Person $person) { return $person->getGender(); }],
]; ];
} }

View File

@ -195,12 +195,12 @@ class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase
public function validTextFieldsProvider() public function validTextFieldsProvider()
{ {
return [ return [
['firstName', 'random Value', function (Person $person) { return $person->getFirstName(); }], ['firstName', 'random Value', static function (Person $person) { return $person->getFirstName(); }],
['lastName', 'random Value', function (Person $person) { return $person->getLastName(); }], ['lastName', 'random Value', static function (Person $person) { return $person->getLastName(); }],
['birthdate', '15-12-1980', function (Person $person) { return $person->getBirthdate()->format('d-m-Y'); }], ['birthdate', '15-12-1980', static function (Person $person) { return $person->getBirthdate()->format('d-m-Y'); }],
['memo', 'jfkdlmq jkfldmsq jkmfdsq', function (Person $person) { return $person->getMemo(); }], ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) { return $person->getMemo(); }],
['birthdate', '', function (Person $person) { return $person->getBirthdate(); }], ['birthdate', '', static function (Person $person) { return $person->getBirthdate(); }],
['gender', Person::FEMALE_GENDER, function (Person $person) { return $person->getGender(); }], ['gender', Person::FEMALE_GENDER, static function (Person $person) { return $person->getGender(); }],
]; ];
} }

View File

@ -55,7 +55,7 @@ class PersonHasCenterValidatorTest extends ConstraintValidatorTestCase
$prophecy = $this->prophesize(CenterResolverManagerInterface::class); $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(); $center = $args[0]->getCenter();
if ($center instanceof Center) { if ($center instanceof Center) {

View File

@ -100,7 +100,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
'expanded' => true, 'expanded' => true,
'choices' => $choices, 'choices' => $choices,
'label' => 'Fields to include in export', '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 // add a 'data-display-target' for address fields
if (substr($val, 0, 8) === 'address_') { if (substr($val, 0, 8) === 'address_') {
return ['data-display-target' => 'address_date']; return ['data-display-target' => 'address_date'];
@ -124,7 +124,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
} }
}, },
'constraints' => [new Callback([ 'constraints' => [new Callback([
'callback' => function ($selected, ExecutionContextInterface $context) { 'callback' => static function ($selected, ExecutionContextInterface $context) {
if (count($selected) === 0) { if (count($selected) === 0) {
$context->buildViolation('You must select at least one element') $context->buildViolation('You must select at least one element')
->atPath('fields') ->atPath('fields')
@ -165,7 +165,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
case 'report_date': case 'report_date':
// for birthdate or report date, we have to transform the string into a date // for birthdate or report date, we have to transform the string into a date
// to format the date correctly. // to format the date correctly.
return function ($value) use ($key) { return static function ($value) use ($key) {
if ('_header' === $value) { if ('_header' === $value) {
return 'person_birthdate' === $key ? 'birthdate' : 'report_date'; return 'person_birthdate' === $key ? 'birthdate' : 'report_date';
} }
@ -202,7 +202,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
$scopes[$row['id']] = $this->translatableStringHelper->localize($row['name']); $scopes[$row['id']] = $this->translatableStringHelper->localize($row['name']);
} }
return function ($value) use ($scopes): string { return static function ($value) use ($scopes): string {
if ('_header' === $value) { if ('_header' === $value) {
return 'circle'; return 'circle';
} }
@ -224,7 +224,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
$users[$row['id']] = $row['username']; $users[$row['id']] = $row['username'];
} }
return function ($value) use ($users): string { return static function ($value) use ($users): string {
if ('_header' === $value) { if ('_header' === $value) {
return 'user'; return 'user';
} }
@ -282,7 +282,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
default: default:
// for fields which are associated with person // for fields which are associated with person
if (in_array($key, $this->fields)) { if (in_array($key, $this->fields)) {
return function ($value) use ($key) { return static function ($value) use ($key) {
if ('_header' === $value) { if ('_header' === $value) {
return strtolower($key); return strtolower($key);
} }
@ -331,7 +331,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) 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 // throw an error if any fields are present
if (!array_key_exists('fields', $data)) { if (!array_key_exists('fields', $data)) {
@ -503,7 +503,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
private function getCustomFields() private function getCustomFields()
{ {
return array_filter($this->customfieldsGroup return array_filter($this->customfieldsGroup
->getCustomFields()->toArray(), function (CustomField $cf) { ->getCustomFields()->toArray(), static function (CustomField $cf) {
return $cf->getType() !== 'title'; return $cf->getType() !== 'title';
}); });
} }

View File

@ -94,7 +94,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface
foreach ($reachableCenters as $center) { foreach ($reachableCenters as $center) {
$reachableScopesId = array_map( $reachableScopesId = array_map(
function (Scope $scope) { return $scope->getId(); }, static function (Scope $scope) { return $scope->getId(); },
$this->helper->getReachableScopes($this->user, $role, $center) $this->helper->getReachableScopes($this->user, $role, $center)
); );
$whereElement->add( $whereElement->add(

View File

@ -66,7 +66,7 @@ class ReportControllerNextTest extends WebTestCase
//filter customFieldsGroup to get only "situation de logement" //filter customFieldsGroup to get only "situation de logement"
$filteredCustomFieldsGroupHouse = array_filter( $filteredCustomFieldsGroupHouse = array_filter(
$customFieldsGroups, $customFieldsGroups,
function (CustomFieldsGroup $group) { static function (CustomFieldsGroup $group) {
return in_array('Situation de logement', $group->getName()); return in_array('Situation de logement', $group->getName());
} }
); );

View File

@ -84,7 +84,7 @@ class ReportControllerTest extends WebTestCase
//filter customFieldsGroup to get only "situation de logement" //filter customFieldsGroup to get only "situation de logement"
$filteredCustomFieldsGroupHouse = array_filter( $filteredCustomFieldsGroupHouse = array_filter(
$customFieldsGroups, $customFieldsGroups,
function (CustomFieldsGroup $group) { static function (CustomFieldsGroup $group) {
return in_array('Situation de logement', $group->getName()); return in_array('Situation de logement', $group->getName());
} }
); );

Some files were not shown because too many files have changed in this diff Show More