Merge branch 'rector/rules-up-to-php74' into 'master'

Rector/rules up to php74

See merge request Chill-Projet/chill-bundles!522
This commit is contained in:
Julien Fastré 2023-04-27 21:42:31 +00:00
commit 7e3295c71f
214 changed files with 436 additions and 1054 deletions

View File

@ -21,7 +21,7 @@ return static function (RectorConfig $rectorConfig): void {
//define sets of rules //define sets of rules
$rectorConfig->sets([ $rectorConfig->sets([
LevelSetList::UP_TO_PHP_73 LevelSetList::UP_TO_PHP_74
]); ]);
// skip some path... // skip some path...

View File

@ -59,9 +59,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(static function ($data) { ->ifTrue(static fn ($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer')
return !is_int($data);
})->thenInvalid('The value %s is not a valid integer')
->end() ->end()
->end() ->end()
->scalarNode('label') ->scalarNode('label')

View File

@ -195,7 +195,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
* @Groups({"docgen:read"}) * @Groups({"docgen:read"})
*/ */
private ?User $user; private ?User $user = null;
/** /**
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User") * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User")

View File

@ -34,7 +34,7 @@ class ActivityPresence
* @ORM\GeneratedValue(strategy="AUTO") * @ORM\GeneratedValue(strategy="AUTO")
* @Serializer\Groups({"docgen:read"}) * @Serializer\Groups({"docgen:read"})
*/ */
private ?int $id; private ?int $id = null;
/** /**
* @ORM\Column(type="json") * @ORM\Column(type="json")

View File

@ -122,7 +122,7 @@ class ActivityType
* @ORM\GeneratedValue(strategy="AUTO") * @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"docgen:read"}) * @Groups({"docgen:read"})
*/ */
private ?int $id; private ?int $id = null;
/** /**
* @ORM\Column(type="string", nullable=false, options={"default": ""}) * @ORM\Column(type="string", nullable=false, options={"default": ""})

View File

@ -86,9 +86,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
$centers = array_map(static function ($el) { $centers = array_map(static fn ($el) => $el['center'], $acl);
return $el['center'];
}, $acl);
$qb = $this->repository->createQueryBuilder('activity'); $qb = $this->repository->createQueryBuilder('activity');

View File

@ -87,9 +87,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
$centers = array_map(static function ($el) { $centers = array_map(static fn ($el) => $el['center'], $acl);
return $el['center'];
}, $acl);
$qb = $this->repository->createQueryBuilder('activity'); $qb = $this->repository->createQueryBuilder('activity');

View File

@ -86,9 +86,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
$centers = array_map(static function ($el) { $centers = array_map(static fn ($el) => $el['center'], $acl);
return $el['center'];
}, $acl);
$qb = $this->repository $qb = $this->repository
->createQueryBuilder('activity') ->createQueryBuilder('activity')

View File

@ -109,9 +109,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
$centers = array_map(static function ($el) { $centers = array_map(static fn ($el) => $el['center'], $acl);
return $el['center'];
}, $acl);
$qb = $this->entityManager->createQueryBuilder(); $qb = $this->entityManager->createQueryBuilder();

View File

@ -87,9 +87,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
$centers = array_map(static function ($el) { $centers = array_map(static fn ($el) => $el['center'], $acl);
return $el['center'];
}, $acl);
$qb = $this->repository $qb = $this->repository
->createQueryBuilder('activity') ->createQueryBuilder('activity')

View File

@ -87,9 +87,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
$centers = array_map(static function ($el) { $centers = array_map(static fn ($el) => $el['center'], $acl);
return $el['center'];
}, $acl);
$qb = $this->repository $qb = $this->repository
->createQueryBuilder('activity') ->createQueryBuilder('activity')

View File

@ -137,13 +137,11 @@ class ListActivity implements ListInterface, GroupedExportInterface
$activity = $activityRepository->find($value); $activity = $activityRepository->find($value);
return implode(', ', array_map(function (ActivityReason $r) { return implode(', ', array_map(fn (ActivityReason $r) => '"' .
return '"' . $this->translatableStringHelper->localize($r->getCategory()->getName())
$this->translatableStringHelper->localize($r->getCategory()->getName()) . ' > ' .
. ' > ' . $this->translatableStringHelper->localize($r->getName())
$this->translatableStringHelper->localize($r->getName()) . '"', $activity->getReasons()->toArray()));
. '"';
}, $activity->getReasons()->toArray()));
}; };
case 'circle_name': case 'circle_name':
@ -197,9 +195,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
$centers = array_map(static function ($el) { $centers = array_map(static fn ($el) => $el['center'], $acl);
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

@ -61,12 +61,9 @@ class ActivityTypeFilter implements FilterInterface
$builder->add('accepted_activitytypes', EntityType::class, [ $builder->add('accepted_activitytypes', EntityType::class, [
'class' => ActivityType::class, 'class' => ActivityType::class,
'choices' => $this->activityTypeRepository->findAllActive(), 'choices' => $this->activityTypeRepository->findAllActive(),
'choice_label' => function (ActivityType $aty) { 'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '')
return .
($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') $this->translatableStringHelper->localize($aty->getName()),
.
$this->translatableStringHelper->localize($aty->getName());
},
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,
]); ]);

View File

@ -64,11 +64,9 @@ class UserScopeFilter implements FilterInterface
{ {
$builder->add('accepted_userscope', EntityType::class, [ $builder->add('accepted_userscope', EntityType::class, [
'class' => Scope::class, 'class' => Scope::class,
'choice_label' => function (Scope $s) { 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
return $this->translatableStringHelper->localize( $s->getName()
$s->getName() ),
);
},
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,
]); ]);

View File

@ -61,12 +61,9 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter
$builder->add('types', EntityType::class, [ $builder->add('types', EntityType::class, [
'choices' => $this->activityTypeRepository->findAllActive(), 'choices' => $this->activityTypeRepository->findAllActive(),
'class' => ActivityType::class, 'class' => ActivityType::class,
'choice_label' => function (ActivityType $aty) { 'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '')
return .
($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') $this->translatableStringHelper->localize($aty->getName()),
.
$this->translatableStringHelper->localize($aty->getName());
},
'group_by' => function (ActivityType $type) { 'group_by' => function (ActivityType $type) {
if (!$type->hasCategory()) { if (!$type->hasCategory()) {
return null; return null;

View File

@ -211,13 +211,9 @@ class ActivityType extends AbstractType
'required' => $activityType->isRequired('attendee'), 'required' => $activityType->isRequired('attendee'),
'expanded' => true, 'expanded' => true,
'class' => ActivityPresence::class, 'class' => ActivityPresence::class,
'choice_label' => function (ActivityPresence $activityPresence) { 'choice_label' => fn (ActivityPresence $activityPresence) => $this->translatableStringHelper->localize($activityPresence->getName()),
return $this->translatableStringHelper->localize($activityPresence->getName()); 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('a')
}, ->where('a.active = true'),
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('a')
->where('a.active = true');
},
]); ]);
} }
@ -357,9 +353,7 @@ class ActivityType extends AbstractType
return (string) $location->getId(); return (string) $location->getId();
}, },
function (?string $id): ?Location { fn (?string $id): ?Location => $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id])
return $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id]);
}
)); ));
} }

View File

@ -45,9 +45,7 @@ class ActivityTypeType extends AbstractType
]) ])
->add('category', EntityType::class, [ ->add('category', EntityType::class, [
'class' => ActivityTypeCategory::class, 'class' => ActivityTypeCategory::class,
'choice_label' => function (ActivityTypeCategory $activityTypeCategory) { 'choice_label' => fn (ActivityTypeCategory $activityTypeCategory) => $this->translatableStringHelper->localize($activityTypeCategory->getName()),
return $this->translatableStringHelper->localize($activityTypeCategory->getName());
},
]) ])
->add('ordering', NumberType::class, [ ->add('ordering', NumberType::class, [
'required' => true, 'required' => true,

View File

@ -45,9 +45,7 @@ class PickActivityReasonType extends AbstractType
$resolver->setDefaults( $resolver->setDefaults(
[ [
'class' => ActivityReason::class, 'class' => ActivityReason::class,
'choice_label' => function (ActivityReason $choice) { 'choice_label' => fn (ActivityReason $choice) => $this->reasonRender->renderString($choice, []),
return $this->reasonRender->renderString($choice, []);
},
'group_by' => function (ActivityReason $choice): ?string { 'group_by' => function (ActivityReason $choice): ?string {
if (null !== $category = $choice->getCategory()) { if (null !== $category = $choice->getCategory()) {
return $this->translatableStringHelper->localize($category->getName()); return $this->translatableStringHelper->localize($category->getName());

View File

@ -38,10 +38,8 @@ class TranslatableActivityReasonCategoryType extends AbstractType
$resolver->setDefaults( $resolver->setDefaults(
[ [
'class' => ActivityReasonCategory::class, 'class' => ActivityReasonCategory::class,
'choice_label' => function (ActivityReasonCategory $category) { 'choice_label' => fn (ActivityReasonCategory $category) => $this->translatableStringHelper->localize($category->getName())
return $this->translatableStringHelper->localize($category->getName()) . (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : ''),
. (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : '');
},
] ]
); );
} }

View File

@ -39,9 +39,7 @@ class TranslatableActivityType extends AbstractType
'class' => ActivityType::class, 'class' => ActivityType::class,
'active_only' => true, 'active_only' => true,
'choices' => $this->activityTypeRepository->findAllActive(), 'choices' => $this->activityTypeRepository->findAllActive(),
'choice_label' => function (ActivityType $type) { 'choice_label' => fn (ActivityType $type) => $this->translatableStringHelper->localize($type->getName()),
return $this->translatableStringHelper->localize($type->getName());
},
] ]
); );
} }

View File

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

View File

@ -134,9 +134,7 @@ class ActivityContext implements
$builder->add($key, EntityType::class, [ $builder->add($key, EntityType::class, [
'class' => Person::class, 'class' => Person::class,
'choices' => $persons, 'choices' => $persons,
'choice_label' => function (Person $p) { 'choice_label' => fn (Person $p) => $this->personRender->renderString($p, []),
return $this->personRender->renderString($p, []);
},
'multiple' => false, 'multiple' => false,
'required' => false, 'required' => false,
'expanded' => true, 'expanded' => true,

View File

@ -145,9 +145,7 @@ class ListActivitiesByAccompanyingPeriodContext implements
return array_filter( return array_filter(
$activities, $activities,
function ($activity) use ($user) { function ($activity) use ($user) {
$activityUsernames = array_map(static function ($user) { $activityUsernames = array_map(static fn ($user) => $user['username'], $activity['users'] ?? []);
return $user['username'];
}, $activity['users'] ?? []);
return in_array($user->getUsername(), $activityUsernames, true); return in_array($user->getUsername(), $activityUsernames, true);
} }
); );
@ -158,9 +156,7 @@ class ListActivitiesByAccompanyingPeriodContext implements
return array_filter( return array_filter(
$works, $works,
function ($work) use ($user) { function ($work) use ($user) {
$workUsernames = array_map(static function ($user) { $workUsernames = array_map(static fn ($user) => $user['username'], $work['referrers'] ?? []);
return $user['username'];
}, $work['referrers'] ?? []);
return in_array($user->getUsername(), $workUsernames, true); return in_array($user->getUsername(), $workUsernames, true);
} }

View File

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

View File

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

View File

@ -83,9 +83,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase
$request->getLocale()->willReturn($fallbackLocale); $request->getLocale()->willReturn($fallbackLocale);
$requestStack->willExtend(\Symfony\Component\HttpFoundation\RequestStack::class); $requestStack->willExtend(\Symfony\Component\HttpFoundation\RequestStack::class);
$requestStack->getCurrentRequest()->will(static function () use ($request) { $requestStack->getCurrentRequest()->will(static fn () => $request);
return $request;
});
$translator->willExtend(\Symfony\Component\Translation\Translator::class); $translator->willExtend(\Symfony\Component\Translation\Translator::class);
$translator->getFallbackLocales()->willReturn($locale); $translator->getFallbackLocales()->willReturn($locale);

View File

@ -132,9 +132,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(static function ($data) { ->ifTrue(static fn ($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer')
return !is_int($data);
})->thenInvalid('The value %s is not a valid integer')
->end() ->end()
->end() ->end()
->scalarNode('label') ->scalarNode('label')

View File

@ -57,7 +57,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
*/ */
private ?int $id; private ?int $id = null;
/** /**
* @ORM\Column(type="string", length=100, nullable=true) * @ORM\Column(type="string", length=100, nullable=true)

View File

@ -59,9 +59,7 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface
$labels = array_combine($values, $values); $labels = array_combine($values, $values);
$labels['_header'] = $this->getTitle(); $labels['_header'] = $this->getTitle();
return static function ($value) use ($labels) { return static fn ($value) => $labels[$value];
return $labels[$value];
};
} }
public function getQueryKeys($data): array public function getQueryKeys($data): array

View File

@ -41,7 +41,7 @@ abstract class AbstractElement
/** /**
* @ORM\Column(name="comment", type="text", nullable=true) * @ORM\Column(name="comment", type="text", nullable=true)
*/ */
private ?string $comment; private ?string $comment = null;
/** /**
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true) * @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
@ -50,7 +50,7 @@ abstract class AbstractElement
* message="The budget element's end date must be after the start date" * message="The budget element's end date must be after the start date"
* ) * )
*/ */
private ?DateTimeImmutable $endDate; private ?DateTimeImmutable $endDate = null;
/** /**
* @ORM\ManyToOne( * @ORM\ManyToOne(

View File

@ -52,9 +52,7 @@ class ChargeType extends AbstractType
'label' => 'Charge type', 'label' => 'Charge type',
'required' => true, 'required' => true,
'placeholder' => $this->translator->trans('admin.form.Choose the type of charge'), 'placeholder' => $this->translator->trans('admin.form.Choose the type of charge'),
'choice_label' => function (ChargeKind $resource) { 'choice_label' => fn (ChargeKind $resource) => $this->translatableStringHelper->localize($resource->getName()),
return $this->translatableStringHelper->localize($resource->getName());
},
'attr' => ['class' => 'select2'], 'attr' => ['class' => 'select2'],
]) ])
->add('amount', MoneyType::class) ->add('amount', MoneyType::class)

View File

@ -51,9 +51,7 @@ class ResourceType extends AbstractType
'label' => 'Resource type', 'label' => 'Resource type',
'required' => true, 'required' => true,
'placeholder' => $this->translator->trans('admin.form.Choose the type of resource'), 'placeholder' => $this->translator->trans('admin.form.Choose the type of resource'),
'choice_label' => function (ResourceKind $resource) { 'choice_label' => fn (ResourceKind $resource) => $this->translatableStringHelper->localize($resource->getName()),
return $this->translatableStringHelper->localize($resource->getName());
},
'attr' => ['class' => 'select2'], 'attr' => ['class' => 'select2'],
]) ])
->add('amount', MoneyType::class) ->add('amount', MoneyType::class)

View File

@ -66,9 +66,7 @@ final class SummaryBudget implements SummaryBudgetInterface
]; ];
} }
$personIds = $household->getCurrentPersons()->map(static function (Person $p) { $personIds = $household->getCurrentPersons()->map(static fn (Person $p) => $p->getId());
return $p->getId();
});
$ids = implode(', ', array_fill(0, count($personIds), '?')); $ids = implode(', ', array_fill(0, count($personIds), '?'));
$parameters = [...$personIds, $household->getId()]; $parameters = [...$personIds, $household->getId()];
@ -127,18 +125,14 @@ final class SummaryBudget implements SummaryBudgetInterface
{ {
$keys = array_map(static fn (ChargeKind $kind) => $kind->getKind(), $this->chargeKindRepository->findAll()); $keys = array_map(static fn (ChargeKind $kind) => $kind->getKind(), $this->chargeKindRepository->findAll());
return array_combine($keys, array_map(function ($kind) { return array_combine($keys, array_map(fn ($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys));
return ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => ''];
}, $keys));
} }
private function getEmptyResourceArray(): array private function getEmptyResourceArray(): array
{ {
$keys = array_map(static fn (ResourceKind $kind) => $kind->getKind(), $this->resourceKindRepository->findAll()); $keys = array_map(static fn (ResourceKind $kind) => $kind->getKind(), $this->resourceKindRepository->findAll());
return array_combine($keys, array_map(function ($kind) { return array_combine($keys, array_map(fn ($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys));
return ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => ''];
}, $keys));
} }
private function rowToArray(array $rows, string $kind): array private function rowToArray(array $rows, string $kind): array

View File

@ -50,9 +50,7 @@ final class SummaryBudgetTest extends TestCase
], ],
]); ]);
$queryCharges->setParameters(Argument::type('array')) $queryCharges->setParameters(Argument::type('array'))
->will(static function ($args, $query) { ->will(static fn ($args, $query) => $query);
return $query;
});
$queryResources = $this->prophesize(AbstractQuery::class); $queryResources = $this->prophesize(AbstractQuery::class);
$queryResources->getResult()->willReturn([ $queryResources->getResult()->willReturn([
@ -63,9 +61,7 @@ final class SummaryBudgetTest extends TestCase
], ],
]); ]);
$queryResources->setParameters(Argument::type('array')) $queryResources->setParameters(Argument::type('array'))
->will(static function ($args, $query) { ->will(static fn ($args, $query) => $query);
return $query;
});
$em = $this->prophesize(EntityManagerInterface::class); $em = $this->prophesize(EntityManagerInterface::class);
$em->createNativeQuery(Argument::type('string'), Argument::type(Query\ResultSetMapping::class)) $em->createNativeQuery(Argument::type('string'), Argument::type(Query\ResultSetMapping::class))
@ -100,9 +96,7 @@ final class SummaryBudgetTest extends TestCase
$resourceRepository->findOneByKind('misc')->willReturn($misc); $resourceRepository->findOneByKind('misc')->willReturn($misc);
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
$translatableStringHelper->localize(Argument::type('array'))->will(static function ($arg) { $translatableStringHelper->localize(Argument::type('array'))->will(static fn ($arg) => $arg[0]['fr']);
return $arg[0]['fr'];
});
$person = new Person(); $person = new Person();
$personReflection = new ReflectionClass($person); $personReflection = new ReflectionClass($person);

View File

@ -514,9 +514,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
*/ */
public function getUsers(): ReadableCollection public function getUsers(): ReadableCollection
{ {
return $this->getInvites()->map(static function (Invite $i) { return $this->getInvites()->map(static fn (Invite $i) => $i->getUser());
return $i->getUser();
});
} }
public function hasCalendarRange(): bool public function hasCalendarRange(): bool
@ -601,9 +599,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
} }
$invite = $this->invites $invite = $this->invites
->filter(static function (Invite $invite) use ($user) { ->filter(static fn (Invite $invite) => $invite->getUser() === $user)
return $invite->getUser() === $user;
})
->first(); ->first();
$this->removeInvite($invite); $this->removeInvite($invite);

View File

@ -63,7 +63,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
* @Groups({"read", "write", "calendar:read"}) * @Groups({"read", "write", "calendar:read"})
* @Assert\NotNull * @Assert\NotNull
*/ */
private ?Location $location; private ?Location $location = null;
/** /**
* @ORM\Column(type="datetime_immutable", nullable=false) * @ORM\Column(type="datetime_immutable", nullable=false)

View File

@ -61,9 +61,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface
$labels = array_combine($values, $values); $labels = array_combine($values, $values);
$labels['_header'] = $this->getTitle(); $labels['_header'] = $this->getTitle();
return static function ($value) use ($labels) { return static fn ($value) => $labels[$value];
return $labels[$value];
};
} }
public function getQueryKeys($data): array public function getQueryKeys($data): array
@ -91,9 +89,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface
*/ */
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
{ {
$centers = array_map(static function ($el) { $centers = array_map(static fn ($el) => $el['center'], $acl);
return $el['center'];
}, $acl);
$qb = $this->calendarRepository->createQueryBuilder('cal'); $qb = $this->calendarRepository->createQueryBuilder('cal');

View File

@ -61,9 +61,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
$labels = array_combine($values, $values); $labels = array_combine($values, $values);
$labels['_header'] = $this->getTitle(); $labels['_header'] = $this->getTitle();
return static function ($value) use ($labels) { return static fn ($value) => $labels[$value];
return $labels[$value];
};
} }
public function getQueryKeys($data): array public function getQueryKeys($data): array

View File

@ -61,9 +61,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
$labels = array_combine($values, $values); $labels = array_combine($values, $values);
$labels['_header'] = $this->getTitle(); $labels['_header'] = $this->getTitle();
return static function ($value) use ($labels) { return static fn ($value) => $labels[$value];
return $labels[$value];
};
} }
public function getQueryKeys($data): array public function getQueryKeys($data): array

View File

@ -58,9 +58,7 @@ class AgentFilter implements FilterInterface
{ {
$builder->add('accepted_agents', EntityType::class, [ $builder->add('accepted_agents', EntityType::class, [
'class' => User::class, 'class' => User::class,
'choice_label' => function (User $u) { 'choice_label' => fn (User $u) => $this->userRender->renderString($u, []),
return $this->userRender->renderString($u, []);
},
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,
]); ]);

View File

@ -69,11 +69,9 @@ class JobFilter implements FilterInterface
{ {
$builder->add('job', EntityType::class, [ $builder->add('job', EntityType::class, [
'class' => UserJob::class, 'class' => UserJob::class,
'choice_label' => function (UserJob $j) { 'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize(
return $this->translatableStringHelper->localize( $j->getLabel()
$j->getLabel() ),
);
},
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,
]); ]);

View File

@ -69,11 +69,9 @@ class ScopeFilter implements FilterInterface
{ {
$builder->add('scope', EntityType::class, [ $builder->add('scope', EntityType::class, [
'class' => Scope::class, 'class' => Scope::class,
'choice_label' => function (Scope $s) { 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
return $this->translatableStringHelper->localize( $s->getName()
$s->getName() ),
);
},
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,
]); ]);

View File

@ -89,14 +89,10 @@ class CalendarToRemoteHandler implements MessageHandlerInterface
$newInvites = array_filter( $newInvites = array_filter(
array_map( array_map(
function ($id) { fn ($id) => $this->inviteRepository->find($id),
return $this->inviteRepository->find($id);
},
$calendarMessage->getNewInvitesIds(), $calendarMessage->getNewInvitesIds(),
), ),
static function (?Invite $invite) { static fn (?Invite $invite) => null !== $invite
return null !== $invite;
}
); );
$this->calendarConnector->syncCalendar( $this->calendarConnector->syncCalendar(

View File

@ -58,14 +58,12 @@ class CalendarMessage
$this->previousMainUserId = null !== $calendar->previousMainUser ? $this->previousMainUserId = null !== $calendar->previousMainUser ?
$calendar->previousMainUser->getId() : null; $calendar->previousMainUser->getId() : null;
$this->newInvitesIds = array_map(static fn (Invite $i) => $i->getId(), $calendar->newInvites); $this->newInvitesIds = array_map(static fn (Invite $i) => $i->getId(), $calendar->newInvites);
$this->oldInvites = array_map(static function (Invite $i) { $this->oldInvites = array_map(static fn (Invite $i) => [
return [ 'inviteId' => $i->getId(),
'inviteId' => $i->getId(), 'userId' => $i->getUser()->getId(),
'userId' => $i->getUser()->getId(), 'userEmail' => $i->getUser()->getEmail(),
'userEmail' => $i->getUser()->getEmail(), 'userLabel' => $i->getUser()->getLabel(),
'userLabel' => $i->getUser()->getLabel(), ], $calendar->oldInvites);
];
}, $calendar->oldInvites);
} }
public function getAction(): string public function getAction(): string

View File

@ -121,9 +121,7 @@ class RemoteEventConverter
'subject' => '[Chill] ' . 'subject' => '[Chill] ' .
implode( implode(
', ', ', ',
$calendar->getPersons()->map(function (Person $p) { $calendar->getPersons()->map(fn (Person $p) => $this->personRender->renderString($p, []))->toArray()
return $this->personRender->renderString($p, []);
})->toArray()
), ),
'start' => [ 'start' => [
'dateTime' => $calendar->getStartDate()->setTimezone($this->remoteDateTimeZone) 'dateTime' => $calendar->getStartDate()->setTimezone($this->remoteDateTimeZone)
@ -161,9 +159,7 @@ class RemoteEventConverter
{ {
return [ return [
'attendees' => $calendar->getInvites()->map( 'attendees' => $calendar->getInvites()->map(
function (Invite $i) { fn (Invite $i) => $this->buildInviteToAttendee($i)
return $this->buildInviteToAttendee($i);
}
)->toArray(), )->toArray(),
]; ];
} }

View File

@ -190,23 +190,17 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
] ]
)->toArray(); )->toArray();
$ids = array_map(static function ($item) { $ids = array_map(static fn ($item) => $item['id'], $bareEvents['value']);
return $item['id'];
}, $bareEvents['value']);
$existingIdsInRange = $this->calendarRangeRepository->findRemoteIdsPresent($ids); $existingIdsInRange = $this->calendarRangeRepository->findRemoteIdsPresent($ids);
$existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids); $existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids);
return array_values( return array_values(
array_map( array_map(
function ($item) { fn ($item) => $this->remoteEventConverter->convertToRemote($item),
return $this->remoteEventConverter->convertToRemote($item);
},
// filter all event to keep only the one not in range // filter all event to keep only the one not in range
array_filter( array_filter(
$bareEvents['value'], $bareEvents['value'],
static function ($item) use ($existingIdsInRange, $existingIdsInCalendar) { static fn ($item) => ((!$existingIdsInRange[$item['id']]) ?? true) && ((!$existingIdsInCalendar[$item['id']]) ?? true)
return ((!$existingIdsInRange[$item['id']]) ?? true) && ((!$existingIdsInCalendar[$item['id']]) ?? true);
}
) )
) )
); );
@ -604,9 +598,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
} }
$this->cacheScheduleTimeForUser[$userId] = array_map( $this->cacheScheduleTimeForUser[$userId] = array_map(
function ($item) { fn ($item) => $this->remoteEventConverter->convertAvailabilityToRemoteEvent($item),
return $this->remoteEventConverter->convertAvailabilityToRemoteEvent($item);
},
$response['value'][0]['scheduleItems'] $response['value'][0]['scheduleItems']
); );

View File

@ -114,12 +114,8 @@ final class CalendarTypeTest extends TypeTestCase
$this->assertEquals(8, $calendar->getCalendarRange()->getId()); $this->assertEquals(8, $calendar->getCalendarRange()->getId());
$this->assertEquals(9, $calendar->getLocation()->getId()); $this->assertEquals(9, $calendar->getLocation()->getId());
$this->assertEquals(true, $calendar->getSendSMS()); $this->assertEquals(true, $calendar->getSendSMS());
$this->assertContains(2, $calendar->getUsers()->map(static function (User $u) { $this->assertContains(2, $calendar->getUsers()->map(static fn (User $u) => $u->getId()));
return $u->getId(); $this->assertContains(3, $calendar->getUsers()->map(static fn (User $u) => $u->getId()));
}));
$this->assertContains(3, $calendar->getUsers()->map(static function (User $u) {
return $u->getId();
}));
} }
protected function getExtensions() protected function getExtensions()
@ -148,25 +144,17 @@ final class CalendarTypeTest extends TypeTestCase
) { ) {
$transformer = $this->prophesize($classTransformer); $transformer = $this->prophesize($classTransformer);
$transformer->transform(Argument::type('array')) $transformer->transform(Argument::type('array'))
->will(static function ($args) { ->will(static fn ($args) => implode(
return implode( ',',
',', array_map(static fn ($p) => $p->getId(), $args[0])
array_map(static function ($p) { ));
return $p->getId();
}, $args[0])
);
});
$transformer->transform(Argument::exact(null)) $transformer->transform(Argument::exact(null))
->willReturn([]); ->willReturn([]);
$transformer->transform(Argument::type(Collection::class)) $transformer->transform(Argument::type(Collection::class))
->will(static function ($args) { ->will(static fn ($args) => implode(
return implode( ',',
',', array_map(static fn ($p) => $p->getId(), $args[0]->toArray())
array_map(static function ($p) { ));
return $p->getId();
}, $args[0]->toArray())
);
});
$transformer->reverseTransform(Argument::type('string')) $transformer->reverseTransform(Argument::type('string'))
->will(static function ($args) use ($objClass) { ->will(static function ($args) use ($objClass) {
if (null === $args[0]) { if (null === $args[0]) {
@ -195,9 +183,7 @@ final class CalendarTypeTest extends TypeTestCase
) { ) {
$transformer = $this->prophesize($classTransformer); $transformer = $this->prophesize($classTransformer);
$transformer->transform(Argument::type('object')) $transformer->transform(Argument::type('object'))
->will(static function ($args) { ->will(static fn ($args) => (string) $args[0]->getId());
return (string) $args[0]->getId();
});
$transformer->transform(Argument::exact(null)) $transformer->transform(Argument::exact(null))
->willReturn(''); ->willReturn('');
$transformer->reverseTransform(Argument::type('string')) $transformer->reverseTransform(Argument::type('string'))

View File

@ -63,9 +63,7 @@ final class AddressConverterTest extends TestCase
{ {
$engine = $this->prophesize(EngineInterface::class); $engine = $this->prophesize(EngineInterface::class);
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
$translatableStringHelper->localize(Argument::type('array'))->will(static function ($args): string { $translatableStringHelper->localize(Argument::type('array'))->will(static fn ($args): string => ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided');
return ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided';
});
$addressRender = new AddressRender($engine->reveal(), $translatableStringHelper->reveal()); $addressRender = new AddressRender($engine->reveal(), $translatableStringHelper->reveal());

View File

@ -72,17 +72,13 @@ final class CalendarForShortMessageProviderTest extends TestCase
Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class),
Argument::type('int'), Argument::type('int'),
Argument::exact(0) Argument::exact(0)
)->will(static function ($args) { )->will(static fn ($args) => array_fill(0, $args[2], new Calendar()))->shouldBeCalledTimes(1);
return array_fill(0, $args[2], new Calendar());
})->shouldBeCalledTimes(1);
$calendarRepository->findByNotificationAvailable( $calendarRepository->findByNotificationAvailable(
Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class),
Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class),
Argument::type('int'), Argument::type('int'),
Argument::not(0) Argument::not(0)
)->will(static function ($args) { )->will(static fn ($args) => array_fill(0, $args[2] - 1, new Calendar()))->shouldBeCalledTimes(1);
return array_fill(0, $args[2] - 1, new Calendar());
})->shouldBeCalledTimes(1);
$em = $this->prophesize(EntityManagerInterface::class); $em = $this->prophesize(EntityManagerInterface::class);
$em->clear()->shouldBeCalled(); $em->clear()->shouldBeCalled();
@ -108,17 +104,13 @@ final class CalendarForShortMessageProviderTest extends TestCase
Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class),
Argument::type('int'), Argument::type('int'),
Argument::exact(0) Argument::exact(0)
)->will(static function ($args) { )->will(static fn ($args) => array_fill(0, 1, new Calendar()))->shouldBeCalledTimes(1);
return array_fill(0, 1, new Calendar());
})->shouldBeCalledTimes(1);
$calendarRepository->findByNotificationAvailable( $calendarRepository->findByNotificationAvailable(
Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class),
Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class),
Argument::type('int'), Argument::type('int'),
Argument::not(0) Argument::not(0)
)->will(static function ($args) { )->will(static fn ($args) => [])->shouldBeCalledTimes(1);
return [];
})->shouldBeCalledTimes(1);
$em = $this->prophesize(EntityManagerInterface::class); $em = $this->prophesize(EntityManagerInterface::class);
$em->clear()->shouldBeCalled(); $em->clear()->shouldBeCalled();

View File

@ -58,9 +58,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' => static function (Option $option) use ($translatableStringHelper) { 'choice_label' => static fn (Option $option) => $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(),
'multiple' => false, 'multiple' => false,
'expanded' => false, 'expanded' => false,

View File

@ -57,8 +57,6 @@ class OptionRepository extends EntityRepository
->getQuery() ->getQuery()
->getScalarResult(); ->getScalarResult();
return array_map(static function ($r) { return array_map(static fn ($r) => $r['key'], $keys);
return $r['key'];
}, $keys);
} }
} }

View File

@ -70,9 +70,7 @@ class CustomFieldType extends AbstractType
if ('entity' === $options['group_widget']) { if ('entity' === $options['group_widget']) {
$builder->add('customFieldsGroup', EntityType::class, [ $builder->add('customFieldsGroup', EntityType::class, [
'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup', 'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup',
'choice_label' => function ($g) { 'choice_label' => fn ($g) => $this->translatableStringHelper->localize($g->getName()),
return $this->translatableStringHelper->localize($g->getName());
},
]); ]);
} elseif ('hidden' === $options['group_widget']) { } elseif ('hidden' === $options['group_widget']) {
$builder->add('customFieldsGroup', HiddenType::class); $builder->add('customFieldsGroup', HiddenType::class);

View File

@ -38,9 +38,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(
static function ($e) { static fn ($e) => $e->getLabel(),
return $e->getLabel();
},
$customFields $customFields
); );

View File

@ -61,12 +61,8 @@ class DocGeneratorTemplateType extends AbstractType
$sub = $builder $sub = $builder
->create('options', null, ['compound' => true]) ->create('options', null, ['compound' => true])
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(
static function (array $data) use ($context) { static fn (array $data) => $context->adminFormTransform($data),
return $context->adminFormTransform($data); static fn (array $data) => $context->adminFormReverseTransform($data)
},
static function (array $data) use ($context) {
return $context->adminFormReverseTransform($data);
}
)); ));
$context->buildAdminForm($sub); $context->buildAdminForm($sub);
$builder->add($sub); $builder->add($sub);

View File

@ -17,6 +17,6 @@ class ObjectReadyException extends RuntimeException
{ {
public function __construct() public function __construct()
{ {
parent::__construct('object is already ready', 6698856); parent::__construct('object is already ready', 6_698_856);
} }
} }

View File

@ -19,7 +19,7 @@ class RelatedEntityNotFoundException extends RuntimeException
{ {
parent::__construct( parent::__construct(
sprintf('Related entity not found: %s, %s', $relatedEntityClass, $relatedEntityId), sprintf('Related entity not found: %s, %s', $relatedEntityClass, $relatedEntityId),
99876652, 99_876_652,
$previous $previous
); );
} }

View File

@ -58,7 +58,7 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @Serializer\Groups({"read", "write"}) * @Serializer\Groups({"read", "write"})
*/ */
private ?int $id; private ?int $id = null;
/** /**
* @var int[] * @var int[]
@ -94,7 +94,7 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa
/** /**
* @ORM\ManyToOne(targetEntity=DocGeneratorTemplate::class) * @ORM\ManyToOne(targetEntity=DocGeneratorTemplate::class)
*/ */
private ?DocGeneratorTemplate $template; private ?DocGeneratorTemplate $template = null;
/** /**
* @ORM\Column(type="text", options={"default": "ready"}) * @ORM\Column(type="text", options={"default": "ready"})

View File

@ -72,14 +72,10 @@ class AccompanyingCourseDocumentType extends AbstractType
->add('category', EntityType::class, [ ->add('category', EntityType::class, [
'placeholder' => 'Choose a document category', 'placeholder' => 'Choose a document category',
'class' => DocumentCategory::class, 'class' => DocumentCategory::class,
'query_builder' => static function (EntityRepository $er) { 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('c')
return $er->createQueryBuilder('c') ->where('c.documentClass = :docClass')
->where('c.documentClass = :docClass') ->setParameter('docClass', AccompanyingCourseDocument::class),
->setParameter('docClass', AccompanyingCourseDocument::class); 'choice_label' => fn ($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '',
},
'choice_label' => function ($entity = null) {
return $entity ? $this->translatableStringHelper->localize($entity->getName()) : '';
},
]); ]);
} }

View File

@ -67,14 +67,10 @@ class PersonDocumentType extends AbstractType
->add('category', EntityType::class, [ ->add('category', EntityType::class, [
'placeholder' => 'Choose a document category', 'placeholder' => 'Choose a document category',
'class' => DocumentCategory::class, 'class' => DocumentCategory::class,
'query_builder' => static function (EntityRepository $er) { 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('c')
return $er->createQueryBuilder('c') ->where('c.documentClass = :docClass')
->where('c.documentClass = :docClass') ->setParameter('docClass', PersonDocument::class),
->setParameter('docClass', PersonDocument::class); 'choice_label' => fn ($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '',
},
'choice_label' => function ($entity = null) {
return $entity ? $this->translatableStringHelper->localize($entity->getName()) : '';
},
]); ]);
if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) { if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) {

View File

@ -51,9 +51,7 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler
$persons = []; $persons = [];
if (null !== $course) { if (null !== $course) {
$persons = $course->getCurrentParticipations()->map(static function (AccompanyingPeriodParticipation $participation) { $persons = $course->getCurrentParticipations()->map(static fn (AccompanyingPeriodParticipation $participation) => $participation->getPerson())->toArray();
return $participation->getPerson();
})->toArray();
} }
return [ return [

View File

@ -113,9 +113,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(
static function (Participation $p) { static fn (Participation $p) => $p->getPerson()->getId(),
return $p->getPerson()->getId();
},
$participations $participations
)), )),
] ]
@ -649,19 +647,14 @@ class ParticipationController extends AbstractController
// create a collection of person's id participating to the event // create a collection of person's id participating to the event
/** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */ /** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */
$peopleParticipating = $peopleParticipating ?? $peopleParticipating ??= $participation->getEvent()->getParticipations()->map(
$participation->getEvent()->getParticipations()->map( static fn (Participation $p) => $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(
static function (Participation $p) use ($participation) { static fn (Participation $p) => $p->getPerson()->getId() === $participation->getPerson()->getId()
return $p->getPerson()->getId() === $participation->getPerson()->getId();
}
)->first(); )->first();
} else { } else {
$newParticipations[] = $participation; $newParticipations[] = $participation;

View File

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

View File

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

View File

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

View File

@ -109,16 +109,12 @@ class PickEventType extends AbstractType
// add the default options // add the default options
$resolver->setDefaults([ $resolver->setDefaults([
'class' => Event::class, 'class' => Event::class,
'choice_label' => static function (Event $e) { 'choice_label' => static fn (Event $e) => $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' => static function (Event $e) { 'choice_attr' => static fn (Event $e) => ['data-center' => $e->getCenter()->getId()],
return ['data-center' => $e->getCenter()->getId()];
},
'choiceloader' => function (Options $options) { 'choiceloader' => function (Options $options) {
$centers = $this->filterCenters($options); $centers = $this->filterCenters($options);
@ -143,9 +139,7 @@ class PickEventType extends AbstractType
// option role // option role
if (null === $options['role']) { if (null === $options['role']) {
$centers = array_map( $centers = array_map(
static function (GroupCenter $g) { static fn (GroupCenter $g) => $g->getCenter(),
return $g->getCenter();
},
$this->user->getGroupCenters()->toArray() $this->user->getGroupCenters()->toArray()
); );
} else { } else {
@ -173,9 +167,7 @@ class PickEventType extends AbstractType
if ( if (
!in_array($c->getId(), array_map( !in_array($c->getId(), array_map(
static function (Center $c) { static fn (Center $c) => $c->getId(),
return $c->getId();
},
$centers $centers
), true) ), true)
) { ) {

View File

@ -39,16 +39,10 @@ class PickEventTypeType extends AbstractType
$resolver->setDefaults( $resolver->setDefaults(
[ [
'class' => EventType::class, 'class' => EventType::class,
'query_builder' => static function (EntityRepository $er) { 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('et')
return $er->createQueryBuilder('et') ->where('et.active = true'),
->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 function (EventType $t) use ($helper) {
return $helper->localize($t->getName());
},
'choice_attrs' => static function (EventType $t) {
return ['data-link-category' => $t->getId()];
},
] ]
); );
} }

View File

@ -80,9 +80,7 @@ class PickRoleType extends AbstractType
$options = $config->getOptions(); $options = $config->getOptions();
$form->getParent()->add($name, $type, array_replace($options, [ $form->getParent()->add($name, $type, array_replace($options, [
'group_by' => function (Role $r) { 'group_by' => fn (Role $r) => $this->translatableStringHelper->localize($r->getType()->getName()),
return $this->translatableStringHelper->localize($r->getType()->getName());
},
])); ]));
} }
} }
@ -111,17 +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' => static function (Role $r) { 'choice_attr' => static fn (Role $r) => [
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' => static fn (Role $r) => $translatableStringHelper->localize($r->getName()) .
}, ($r->getActive() === true ? '' :
'choice_label' => static function (Role $r) use ($translatableStringHelper, $translator) { ' (' . $translator->trans('unactive') . ')'),
return $translatableStringHelper->localize($r->getName()) .
($r->getActive() === true ? '' :
' (' . $translator->trans('unactive') . ')');
},
]); ]);
} }

View File

@ -82,9 +82,7 @@ class PickStatusType extends AbstractType
$type = $config->getType()->getName(); $type = $config->getType()->getName();
$options = $config->getOptions(); $options = $config->getOptions();
$form->getParent()->add($name, $type, array_replace($options, [ $form->getParent()->add($name, $type, array_replace($options, [
'group_by' => function (Status $s) { 'group_by' => fn (Status $s) => $this->translatableStringHelper->localize($s->getType()->getName()),
return $this->translatableStringHelper->localize($s->getType()->getName());
},
])); ]));
} }
); );
@ -112,17 +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' => static function (Status $s) { 'choice_attr' => static fn (Status $s) => [
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' => static fn (Status $s) => $translatableStringHelper->localize($s->getName()) .
}, ($s->getActive() === true ? '' :
'choice_label' => static function (Status $s) use ($translatableStringHelper, $translator) { ' (' . $translator->trans('unactive') . ')'),
return $translatableStringHelper->localize($s->getName()) .
($s->getActive() === true ? '' :
' (' . $translator->trans('unactive') . ')');
},
]); ]);
} }

View File

@ -239,9 +239,7 @@ final class ParticipationControllerTest extends WebTestCase
$this->personsIdsCache = array_merge( $this->personsIdsCache = array_merge(
$this->personsIdsCache, $this->personsIdsCache,
$event->getParticipations()->map( $event->getParticipations()->map(
static function ($p) { static fn ($p) => $p->getPerson()->getId()
return $p->getPerson()->getId();
}
) )
->toArray() ->toArray()
); );
@ -305,9 +303,7 @@ final class ParticipationControllerTest extends WebTestCase
$event = $this->getRandomEventWithMultipleParticipations(); $event = $this->getRandomEventWithMultipleParticipations();
$persons_id = implode(',', $event->getParticipations()->map( $persons_id = implode(',', $event->getParticipations()->map(
static function ($p) { static fn ($p) => $p->getPerson()->getId()
return $p->getPerson()->getId();
}
)->toArray()); )->toArray());
$crawler = $this->client->request( $crawler = $this->client->request(
@ -333,9 +329,7 @@ final 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(
static function ($p) { static fn ($p) => $p->getPerson()->getId()
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);
@ -464,9 +458,7 @@ final class ParticipationControllerTest extends WebTestCase
$circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class) $circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class)
->findAll(); ->findAll();
array_filter($circles, static function ($circle) use ($circleName) { array_filter($circles, static fn ($circle) => in_array($circleName, $circle->getName(), true));
return in_array($circleName, $circle->getName(), true);
});
$circle = $circles[0]; $circle = $circles[0];
$events = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class) $events = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class)

View File

@ -208,9 +208,7 @@ class TimelineEventProvider implements TimelineProviderInterface
foreach ($reachableCenters as $center) { foreach ($reachableCenters as $center) {
$reachableCircleId = array_map( $reachableCircleId = array_map(
static function (Scope $scope) { static fn (Scope $scope) => $scope->getId(),
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

@ -230,7 +230,7 @@ class CRUDController extends AbstractController
*/ */
protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface
{ {
$formClass = $formClass ?? $this->getFormClassFor($action); $formClass ??= $this->getFormClassFor($action);
$form = $this->createForm($formClass, $entity, $formOptions); $form = $this->createForm($formClass, $entity, $formOptions);

View File

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

View File

@ -282,9 +282,7 @@ class NotificationController extends AbstractController
if ($request->query->has('edit')) { if ($request->query->has('edit')) {
$commentId = $request->query->getInt('edit'); $commentId = $request->query->getInt('edit');
$editedComment = $notification->getComments()->filter(static function (NotificationComment $c) use ($commentId) { $editedComment = $notification->getComments()->filter(static fn (NotificationComment $c) => $c->getId() === $commentId)->first();
return $c->getId() === $commentId;
})->first();
if (false === $editedComment) { if (false === $editedComment) {
throw $this->createNotFoundException("Comment with id {$commentId} does not exists nor belong to this notification"); throw $this->createNotFoundException("Comment with id {$commentId} does not exists nor belong to this notification");

View File

@ -158,9 +158,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(static function ($form) { 'delete_role_scopes_form' => array_map(static fn ($form) => $form->createView(), $deleteRoleScopesForm),
return $form->createView();
}, $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView(), 'add_role_scopes_form' => $addRoleScopesForm->createView(),
]); ]);
} }
@ -305,9 +303,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(static function ($form) { 'delete_role_scopes_form' => array_map(static fn ($form) => $form->createView(), $deleteRoleScopesForm),
return $form->createView();
}, $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView(), 'add_role_scopes_form' => $addRoleScopesForm->createView(),
]); ]);
} }
@ -449,9 +445,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(static function ($form) { 'delete_role_scopes_form' => array_map(static fn ($form) => $form->createView(), $deleteRoleScopesForm),
return $form->createView();
}, $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView(), 'add_role_scopes_form' => $addRoleScopesForm->createView(),
]); ]);
} }
@ -573,9 +567,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(
static function (Role $role) { static fn (Role $role) => $role->getRole(),
return $role->getRole();
},
$this->roleHierarchy $this->roleHierarchy
->getReachableRoles( ->getReachableRoles(
[new Role($roleScope->getRole())] [new Role($roleScope->getRole())]

View File

@ -337,14 +337,13 @@ 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(
static function (Form $form) { static fn (Form $form) => $form->createView(),
return $form->createView();
},
iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true) iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true)
), ),
] ]
); );
} elseif ('index' === $action) { }
if ('index' === $action) {
return array_merge( return array_merge(
['allow_change_password' => $this->parameterBag->get('chill_main.access_user_change_password')], ['allow_change_password' => $this->parameterBag->get('chill_main.access_user_change_password')],
$defaultTemplateParameters $defaultTemplateParameters

View File

@ -345,12 +345,10 @@ class WorkflowController extends AbstractController
if ($transitionForm->isSubmitted() && $transitionForm->isValid()) { if ($transitionForm->isSubmitted() && $transitionForm->isValid()) {
if (!$workflow->can($entityWorkflow, $transition = $transitionForm['transition']->getData()->getName())) { if (!$workflow->can($entityWorkflow, $transition = $transitionForm['transition']->getData()->getName())) {
$blockers = $workflow->buildTransitionBlockerList($entityWorkflow, $transition); $blockers = $workflow->buildTransitionBlockerList($entityWorkflow, $transition);
$msgs = array_map(function (TransitionBlocker $tb) { $msgs = array_map(fn (TransitionBlocker $tb) => $this->translator->trans(
return $this->translator->trans( $tb->getMessage(),
$tb->getMessage(), $tb->getParameters()
$tb->getParameters() ), iterator_to_array($blockers));
);
}, iterator_to_array($blockers));
throw $this->createAccessDeniedException( throw $this->createAccessDeniedException(
sprintf( sprintf(

View File

@ -37,9 +37,7 @@ class MenuCompilerPass implements CompilerPassInterface
]; ];
} }
usort($services, static function ($a, $b) { usort($services, static fn ($a, $b) => $a['priority'] <=> $b['priority']);
return $a['priority'] <=> $b['priority'];
});
foreach ($services as $service) { foreach ($services as $service) {
$class = $container->getDefinition($service['id'])->getClass(); $class = $container->getDefinition($service['id'])->getClass();

View File

@ -33,9 +33,7 @@ class Greatest extends FunctionNode
public function getSql(SqlWalker $sqlWalker) public function getSql(SqlWalker $sqlWalker)
{ {
return 'GREATEST(' . implode(', ', array_map(static function (Node $expr) use ($sqlWalker) { return 'GREATEST(' . implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')';
return $expr->dispatch($sqlWalker);
}, $this->exprs)) . ')';
} }
public function parse(Parser $parser) public function parse(Parser $parser)

View File

@ -33,9 +33,7 @@ class Least extends FunctionNode
public function getSql(SqlWalker $sqlWalker) public function getSql(SqlWalker $sqlWalker)
{ {
return 'LEAST(' . implode(', ', array_map(static function (Node $expr) use ($sqlWalker) { return 'LEAST(' . implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')';
return $expr->dispatch($sqlWalker);
}, $this->exprs)) . ')';
} }
public function parse(Parser $parser) public function parse(Parser $parser)

View File

@ -149,7 +149,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* @Groups({"write"}) * @Groups({"write"})
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL") * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/ */
private ?ThirdParty $linkedToThirdParty; private ?ThirdParty $linkedToThirdParty = null;
/** /**
* A geospatial field storing the coordinates of the Address. * A geospatial field storing the coordinates of the Address.

View File

@ -55,7 +55,7 @@ class AddressReference
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @groups({"read"}) * @groups({"read"})
*/ */
private ?int $id; private ?int $id = null;
/** /**
* @ORM\Column(type="text", nullable=false, options={"default": ""}) * @ORM\Column(type="text", nullable=false, options={"default": ""})
@ -79,7 +79,7 @@ class AddressReference
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode") * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
* @groups({"read"}) * @groups({"read"})
*/ */
private ?PostalCode $postcode; private ?PostalCode $postcode = null;
/** /**
* @ORM\Column(type="text", nullable=false, options={"default": ""}) * @ORM\Column(type="text", nullable=false, options={"default": ""})

View File

@ -36,7 +36,7 @@ class GeographicalUnit
/** /**
* @ORM\ManyToOne(targetEntity=GeographicalUnitLayer::class, inversedBy="units") * @ORM\ManyToOne(targetEntity=GeographicalUnitLayer::class, inversedBy="units")
*/ */
private ?GeographicalUnitLayer $layer; private ?GeographicalUnitLayer $layer = null;
/** /**
* @ORM\Column(type="text", nullable=false, options={"default": ""}) * @ORM\Column(type="text", nullable=false, options={"default": ""})

View File

@ -120,12 +120,12 @@ class Notification implements TrackUpdateInterface
/** /**
* @ORM\Column(type="datetime_immutable") * @ORM\Column(type="datetime_immutable")
*/ */
private ?DateTimeImmutable $updatedAt; private ?DateTimeImmutable $updatedAt = null;
/** /**
* @ORM\ManyToOne(targetEntity=User::class) * @ORM\ManyToOne(targetEntity=User::class)
*/ */
private ?User $updatedBy; private ?User $updatedBy = null;
public function __construct() public function __construct()
{ {

View File

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

View File

@ -291,9 +291,7 @@ class EntityWorkflowStep
public function removeDestEmail(string $email): self public function removeDestEmail(string $email): self
{ {
$this->destEmail = array_filter($this->destEmail, static function (string $existing) use ($email) { $this->destEmail = array_filter($this->destEmail, static fn (string $existing) => $email !== $existing);
return $email !== $existing;
});
return $this; return $this;
} }

View File

@ -199,9 +199,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(static function ($v) use ($key) { $values = array_map(static fn ($v) => $v[$key], $this->result);
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

@ -187,9 +187,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(static function ($v) use ($key) { $values = array_map(static fn ($v) => $v[$key], $this->result);
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

@ -445,7 +445,7 @@ class SpreadSheetFormatter implements FormatterInterface
$this->initializeCache($key); $this->initializeCache($key);
} }
$value = $value ?? ''; $value ??= '';
return call_user_func($this->cacheDisplayableResult[$key], $value); return call_user_func($this->cacheDisplayableResult[$key], $value);
} }

View File

@ -249,7 +249,7 @@ class ExportAddressHelper
if (($params & $bitmask) === $bitmask) { if (($params & $bitmask) === $bitmask) {
if ('geographical_units' === $key) { if ('geographical_units' === $key) {
// geographical unit generate keys dynamically, depending on layers // geographical unit generate keys dynamically, depending on layers
$prefixes = array_merge($prefixes, array_keys($this->generateKeysForUnitsNames($prefix)), array_keys($this->generateKeysForUnitsRefs($prefix))); $prefixes = [...$prefixes, ...array_keys($this->generateKeysForUnitsNames($prefix)), ...array_keys($this->generateKeysForUnitsRefs($prefix))];
continue; continue;
} }
@ -257,9 +257,7 @@ class ExportAddressHelper
$prefixes = array_merge( $prefixes = array_merge(
$prefixes, $prefixes,
array_map( array_map(
static function ($item) use ($prefix) { static fn ($item) => $prefix . $item,
return $prefix . $item;
},
self::COLUMN_MAPPING[$key] self::COLUMN_MAPPING[$key]
) )
); );

View File

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

View File

@ -37,9 +37,7 @@ class ExportPickCenterDataMapper implements DataMapperInterface
foreach ($this->regroupmentRepository->findAll() as $regroupment) { foreach ($this->regroupmentRepository->findAll() as $regroupment) {
/** @phpstan-ignore-next-line */ /** @phpstan-ignore-next-line */
[$contained, $notContained] = $regroupment->getCenters()->partition(static function (Center $center): bool { [$contained, $notContained] = $regroupment->getCenters()->partition(static fn (Center $center): bool => false);
return false;
});
if (0 === count($notContained)) { if (0 === count($notContained)) {
$pickedRegroupment[] = $regroupment; $pickedRegroupment[] = $regroupment;

View File

@ -42,9 +42,7 @@ class IdToEntityDataTransformer implements DataTransformerInterface
{ {
$this->repository = $repository; $this->repository = $repository;
$this->multiple = $multiple; $this->multiple = $multiple;
$this->getId = $getId ?? static function (object $o) { $this->getId = $getId ?? static fn (object $o) => $o->getId();
return $o->getId();
};
} }
/** /**

View File

@ -36,15 +36,11 @@ final class LocationFormType extends AbstractType
$builder $builder
->add('locationType', EntityType::class, [ ->add('locationType', EntityType::class, [
'class' => EntityLocationType::class, 'class' => EntityLocationType::class,
'choice_attr' => static function (EntityLocationType $entity) { 'choice_attr' => static fn (EntityLocationType $entity) => [
return [ 'data-address' => $entity->getAddressRequired(),
'data-address' => $entity->getAddressRequired(), 'data-contact' => $entity->getContactData(),
'data-contact' => $entity->getContactData(), ],
]; 'choice_label' => fn (EntityLocationType $entity) => $this->translatableStringHelper->localize($entity->getTitle()),
},
'choice_label' => function (EntityLocationType $entity) {
return $this->translatableStringHelper->localize($entity->getTitle());
},
]) ])
->add('name', TextType::class) ->add('name', TextType::class)
->add('phonenumber1', ChillPhoneNumberType::class, ['required' => false]) ->add('phonenumber1', ChillPhoneNumberType::class, ['required' => false])

View File

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

View File

@ -82,16 +82,12 @@ class ComposedRoleScopeType extends AbstractType
return ['data-has-scope' => '1']; return ['data-has-scope' => '1'];
}, },
'group_by' => function ($role, $key, $index) { 'group_by' => fn ($role, $key, $index) => $this->roleProvider->getRoleTitle($role),
return $this->roleProvider->getRoleTitle($role);
},
]) ])
->add('scope', EntityType::class, [ ->add('scope', EntityType::class, [
'class' => Scope::class, 'class' => Scope::class,
'choice_label' => static fn (Scope $scope) => $translatableStringHelper->localize($scope->getName()),
'placeholder' => 'Choose amongst scopes', 'placeholder' => 'Choose amongst scopes',
'choice_label' => static function (Scope $scope) use ($translatableStringHelper) {
return $translatableStringHelper->localize($scope->getName());
},
'required' => false, 'required' => false,
'data' => null, 'data' => null,
]); ]);

View File

@ -51,9 +51,7 @@ class EntityToJsonTransformer implements DataTransformerInterface
} }
return array_map( return array_map(
function ($item) { fn ($item) => $this->denormalizeOne($item),
return $this->denormalizeOne($item);
},
$denormalized $denormalized
); );
} }

View File

@ -67,9 +67,7 @@ final class PickCenterType extends AbstractType
'choices' => $centers, 'choices' => $centers,
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,
'choice_label' => static function (Center $c) { 'choice_label' => static fn (Center $c) => $c->getName(),
return $c->getName();
},
'data' => $centers, 'data' => $centers,
]); ]);
@ -80,9 +78,7 @@ final class PickCenterType extends AbstractType
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,
'choices' => $this->regroupmentRepository->findAllActive(), 'choices' => $this->regroupmentRepository->findAllActive(),
'choice_label' => static function (Regroupment $r) { 'choice_label' => static fn (Regroupment $r) => $r->getName(),
return $r->getName();
},
]); ]);
} }

View File

@ -90,9 +90,7 @@ class PickCenterType extends AbstractType
return ['center' => $data]; return ['center' => $data];
}, },
static function ($data) { static fn ($data) => $data['center']
return $data['center'];
}
)); ));
} }

View File

@ -34,17 +34,13 @@ class PickCivilityType extends AbstractType
->setDefault('label', 'Civility') ->setDefault('label', 'Civility')
->setDefault( ->setDefault(
'choice_label', 'choice_label',
function (Civility $civility): string { fn (Civility $civility): string => $this->translatableStringHelper->localize($civility->getName())
return $this->translatableStringHelper->localize($civility->getName());
}
) )
->setDefault( ->setDefault(
'query_builder', 'query_builder',
static function (EntityRepository $er): QueryBuilder { static fn (EntityRepository $er): QueryBuilder => $er->createQueryBuilder('c')
return $er->createQueryBuilder('c') ->where('c.active = true')
->where('c.active = true') ->orderBy('c.order'),
->orderBy('c.order');
},
) )
->setDefault('placeholder', 'choose civility') ->setDefault('placeholder', 'choose civility')
->setDefault('class', Civility::class); ->setDefault('class', Civility::class);

View File

@ -31,9 +31,7 @@ class PickLocationTypeType extends AbstractType
$resolver $resolver
->setDefaults([ ->setDefaults([
'class' => LocationType::class, 'class' => LocationType::class,
'choice_label' => function (LocationType $type) { 'choice_label' => fn (LocationType $type) => $this->translatableStringHelper->localize($type->getTitle()),
return $this->translatableStringHelper->localize($type->getTitle());
},
'placeholder' => 'Pick a location type', 'placeholder' => 'Pick a location type',
'required' => false, 'required' => false,
'attr' => ['class' => 'select2'], 'attr' => ['class' => 'select2'],

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