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

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

View File

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

View File

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

View File

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

View File

@@ -88,7 +88,7 @@ class CustomFieldType extends AbstractType
'label' => 'Required field',
])
->add('type', HiddenType::class, ['data' => $options['type']])
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $event) {
$customField = $event->getData();
$form = $event->getForm();

View File

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

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?
$customFieldsLablels = array_map(
function ($e) { return $e->getLabel(); },
static function ($e) { return $e->getLabel(); },
$customFields
);

View File

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