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

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

View File

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

View File

@@ -117,7 +117,7 @@ trait AppendScopeChoiceTypeTrait
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) use ($choices, $name, $dataTransformer, $builder) {
static function (FormEvent $event) use ($choices, $name, $dataTransformer, $builder) {
$form = $event->getForm();
$form->add(
$builder

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -75,7 +75,7 @@ class PostalCodeType extends AbstractType
$helper = $this->translatableStringHelper;
$resolver
->setDefault('class', PostalCode::class)
->setDefault('choice_label', function (PostalCode $code) use ($helper) {
->setDefault('choice_label', static function (PostalCode $code) use ($helper) {
return $code->getCode() . ' ' . $code->getName() . ' [' .
$helper->localize($code->getCountry()->getName()) . ']';
})

View File

@@ -141,7 +141,7 @@ class ScopePickerType extends AbstractType
->join('pg.groupCenters', 'gc')
// add center constraint
->where($qb->expr()->in('IDENTITY(gc.center)', ':centers'))
->setParameter('centers', array_map(fn (Center $c) => $c->getId(), $centers))
->setParameter('centers', array_map(static fn (Center $c) => $c->getId(), $centers))
// role constraints
->andWhere($qb->expr()->in('rs.role', ':roles'))
->setParameter('roles', $roles)

View File

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

View File

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