DX: fix cs

This commit is contained in:
2023-04-15 00:43:55 +02:00
parent 80647147ee
commit 746ed4f5e5
188 changed files with 309 additions and 308 deletions

View File

@@ -113,7 +113,7 @@ class ParticipationController extends AbstractController
[
'event_id' => current($participations)->getEvent()->getId(),
'persons_ids' => implode(',', array_map(
static fn(Participation $p) => $p->getPerson()->getId(),
static fn (Participation $p) => $p->getPerson()->getId(),
$participations
)),
]
@@ -648,13 +648,13 @@ class ParticipationController extends AbstractController
// create a collection of person's id participating to the event
/** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */
$peopleParticipating ??= $participation->getEvent()->getParticipations()->map(
static fn(Participation $p) => $p->getPerson()->getId()
static fn (Participation $p) => $p->getPerson()->getId()
);
// check that the user is not already in the event
if ($peopleParticipating->contains($participation->getPerson()->getId())) {
$ignoredParticipations[] = $participation
->getEvent()->getParticipations()->filter(
static fn(Participation $p) => $p->getPerson()->getId() === $participation->getPerson()->getId()
static fn (Participation $p) => $p->getPerson()->getId() === $participation->getPerson()->getId()
)->first();
} else {
$newParticipations[] = $participation;

View File

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

View File

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

View File

@@ -38,7 +38,7 @@ class RoleType extends AbstractType
->add('active')
->add('type', EntityType::class, [
'class' => EventType::class,
'choice_label' => fn(EventType $e) => $this->translatableStringHelper->localize($e->getName()),
'choice_label' => fn (EventType $e) => $this->translatableStringHelper->localize($e->getName()),
]);
}

View File

@@ -109,12 +109,12 @@ class PickEventType extends AbstractType
// add the default options
$resolver->setDefaults([
'class' => Event::class,
'choice_label' => static fn(Event $e) => $e->getDate()->format('d/m/Y, H:i') . ' → ' .
'choice_label' => static fn (Event $e) => $e->getDate()->format('d/m/Y, H:i') . ' → ' .
// $e->getType()->getName()['fr'] . ': ' . // display the type of event
$e->getName(),
'placeholder' => 'Pick an event',
'attr' => ['class' => 'select2 '],
'choice_attr' => static fn(Event $e) => ['data-center' => $e->getCenter()->getId()],
'choice_attr' => static fn (Event $e) => ['data-center' => $e->getCenter()->getId()],
'choiceloader' => function (Options $options) {
$centers = $this->filterCenters($options);
@@ -139,7 +139,7 @@ class PickEventType extends AbstractType
// option role
if (null === $options['role']) {
$centers = array_map(
static fn(GroupCenter $g) => $g->getCenter(),
static fn (GroupCenter $g) => $g->getCenter(),
$this->user->getGroupCenters()->toArray()
);
} else {
@@ -167,7 +167,7 @@ class PickEventType extends AbstractType
if (
!in_array($c->getId(), array_map(
static fn(Center $c) => $c->getId(),
static fn (Center $c) => $c->getId(),
$centers
), true)
) {

View File

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

View File

@@ -80,7 +80,7 @@ class PickRoleType extends AbstractType
$options = $config->getOptions();
$form->getParent()->add($name, $type, array_replace($options, [
'group_by' => fn(Role $r) => $this->translatableStringHelper->localize($r->getType()->getName()),
'group_by' => fn (Role $r) => $this->translatableStringHelper->localize($r->getType()->getName()),
]));
}
}
@@ -109,11 +109,11 @@ class PickRoleType extends AbstractType
'class' => Role::class,
'query_builder' => $qb,
'group_by' => null,
'choice_attr' => static fn(Role $r) => [
'choice_attr' => static fn (Role $r) => [
'data-event-type' => $r->getType()->getId(),
'data-link-category' => $r->getType()->getId(),
],
'choice_label' => static fn(Role $r) => $translatableStringHelper->localize($r->getName()) .
'choice_label' => static fn (Role $r) => $translatableStringHelper->localize($r->getName()) .
($r->getActive() === true ? '' :
' (' . $translator->trans('unactive') . ')'),
]);

View File

@@ -82,7 +82,7 @@ class PickStatusType extends AbstractType
$type = $config->getType()->getName();
$options = $config->getOptions();
$form->getParent()->add($name, $type, array_replace($options, [
'group_by' => fn(Status $s) => $this->translatableStringHelper->localize($s->getType()->getName()),
'group_by' => fn (Status $s) => $this->translatableStringHelper->localize($s->getType()->getName()),
]));
}
);
@@ -110,11 +110,11 @@ class PickStatusType extends AbstractType
'class' => Status::class,
'query_builder' => $qb,
'group_by' => null,
'choice_attr' => static fn(Status $s) => [
'choice_attr' => static fn (Status $s) => [
'data-event-type' => $s->getType()->getId(),
'data-link-category' => $s->getType()->getId(),
],
'choice_label' => static fn(Status $s) => $translatableStringHelper->localize($s->getName()) .
'choice_label' => static fn (Status $s) => $translatableStringHelper->localize($s->getName()) .
($s->getActive() === true ? '' :
' (' . $translator->trans('unactive') . ')'),
]);

View File

@@ -239,7 +239,7 @@ final class ParticipationControllerTest extends WebTestCase
$this->personsIdsCache = array_merge(
$this->personsIdsCache,
$event->getParticipations()->map(
static fn($p) => $p->getPerson()->getId()
static fn ($p) => $p->getPerson()->getId()
)
->toArray()
);
@@ -303,7 +303,7 @@ final class ParticipationControllerTest extends WebTestCase
$event = $this->getRandomEventWithMultipleParticipations();
$persons_id = implode(',', $event->getParticipations()->map(
static fn($p) => $p->getPerson()->getId()
static fn ($p) => $p->getPerson()->getId()
)->toArray());
$crawler = $this->client->request(
@@ -329,7 +329,7 @@ final class ParticipationControllerTest extends WebTestCase
$nbParticipations = $event->getParticipations()->count();
// get the persons_id participating on this event
$persons_id = $event->getParticipations()->map(
static fn($p) => $p->getPerson()->getId()
static fn ($p) => $p->getPerson()->getId()
)->toArray();
// exclude the existing persons_ids from the new person
$this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id);
@@ -458,7 +458,7 @@ final class ParticipationControllerTest extends WebTestCase
$circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class)
->findAll();
array_filter($circles, static fn($circle) => in_array($circleName, $circle->getName(), true));
array_filter($circles, static fn ($circle) => in_array($circleName, $circle->getName(), true));
$circle = $circles[0];
$events = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class)

View File

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