DX: fix cs

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

View File

@@ -59,7 +59,7 @@ class Configuration implements ConfigurationInterface
->info('The number of seconds of this duration. Must be an integer.')
->cannotBeEmpty()
->validate()
->ifTrue(static fn($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer')
->ifTrue(static fn ($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer')
->end()
->end()
->scalarNode('label')

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -137,7 +137,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
$activity = $activityRepository->find($value);
return implode(', ', array_map(fn(ActivityReason $r) => '"' .
return implode(', ', array_map(fn (ActivityReason $r) => '"' .
$this->translatableStringHelper->localize($r->getCategory()->getName())
. ' > ' .
$this->translatableStringHelper->localize($r->getName())
@@ -195,7 +195,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static fn($el) => $el['center'], $acl);
$centers = array_map(static fn ($el) => $el['center'], $acl);
// throw an error if any fields are present
if (!array_key_exists('fields', $data)) {

View File

@@ -61,7 +61,7 @@ class ActivityTypeFilter implements FilterInterface
$builder->add('accepted_activitytypes', EntityType::class, [
'class' => ActivityType::class,
'choices' => $this->activityTypeRepository->findAllActive(),
'choice_label' => fn(ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '')
'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '')
.
$this->translatableStringHelper->localize($aty->getName()),
'multiple' => true,

View File

@@ -64,7 +64,7 @@ class UserScopeFilter implements FilterInterface
{
$builder->add('accepted_userscope', EntityType::class, [
'class' => Scope::class,
'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize(
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
$s->getName()
),
'multiple' => true,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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