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
111 changed files with 212 additions and 212 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -365,7 +365,7 @@ class EventSearchTest extends WebTestCase
'décembre' => 12,
];
$results = $trs->each(function ($tr, $i) use ($months) {
$results = $trs->each(static function ($tr, $i) use ($months) {
// we skip the first row
if (0 < $i) {
// get the second node, which should contains a date

View File

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