DX: rector rules upt to PHP 74

This commit is contained in:
2023-04-15 00:20:19 +02:00
parent a68190f0c6
commit 858ade467c
213 changed files with 433 additions and 1052 deletions

View File

@@ -169,9 +169,7 @@ final class AccompanyingCourseApiController extends ApiController
$accompanyingPeriods = $person->getCurrentAccompanyingPeriods();
$accompanyingPeriodsChecked = array_filter(
$accompanyingPeriods,
function (AccompanyingPeriod $period) {
return $this->isGranted(AccompanyingPeriodVoter::SEE, $period);
}
fn(AccompanyingPeriod $period) => $this->isGranted(AccompanyingPeriodVoter::SEE, $period)
);
return $this->json(array_values($accompanyingPeriodsChecked), Response::HTTP_OK, [], ['groups' => ['read']]);

View File

@@ -222,14 +222,10 @@ class AccompanyingPeriodController extends AbstractController
$accompanyingPeriodsRaw = $this->accompanyingPeriodACLAwareRepository
->findByPerson($person, AccompanyingPeriodVoter::SEE);
usort($accompanyingPeriodsRaw, static function ($a, $b) {
return $b->getOpeningDate() > $a->getOpeningDate();
});
usort($accompanyingPeriodsRaw, static fn($a, $b) => $b->getOpeningDate() > $a->getOpeningDate());
// filter visible or not visible
$accompanyingPeriods = array_filter($accompanyingPeriodsRaw, function (AccompanyingPeriod $ap) {
return $this->isGranted(AccompanyingPeriodVoter::SEE, $ap);
});
$accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn(AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap));
return $this->render('@ChillPerson/AccompanyingPeriod/list.html.twig', [
'accompanying_periods' => $accompanyingPeriods,
@@ -331,9 +327,7 @@ class AccompanyingPeriodController extends AbstractController
/** @var AccompanyingPeriod $period */
$period = array_filter(
$person->getAccompanyingPeriods(),
static function (AccompanyingPeriod $p) use ($period_id) {
return $p->getId() === ($period_id);
}
static fn(AccompanyingPeriod $p) => $p->getId() === ($period_id)
)[0] ?? null;
if (null === $period) {

View File

@@ -105,12 +105,8 @@ class AccompanyingPeriodRegulationListController
$builder
->add('services', EntityType::class, [
'class' => Scope::class,
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('s');
},
'choice_label' => function (Scope $s) {
return $this->translatableStringHelper->localize($s->getName());
},
'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('s'),
'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize($s->getName()),
'multiple' => true,
'label' => 'Service',
'required' => false,
@@ -123,9 +119,7 @@ class AccompanyingPeriodRegulationListController
return $qb;
},
'choice_label' => function (UserJob $j) {
return $this->translatableStringHelper->localize($j->getLabel());
},
'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()),
'multiple' => true,
'label' => 'Métier',
'required' => false,
@@ -147,9 +141,7 @@ class AccompanyingPeriodRegulationListController
return $qb;
},
'choice_label' => static function (Location $l) {
return $l->getName();
},
'choice_label' => static fn(Location $l) => $l->getName(),
'multiple' => true,
'group_by' => function (Location $l) {
if (null === $type = $l->getLocationType()) {

View File

@@ -164,9 +164,7 @@ class HouseholdCompositionController extends AbstractController
$isEdit = $request->query->has('edit');
if ($isEdit) {
$householdCompositions = $household->getCompositions()->filter(static function (HouseholdComposition $composition) use ($request) {
return $composition->getId() === $request->query->getInt('edit');
});
$householdCompositions = $household->getCompositions()->filter(static fn(HouseholdComposition $composition) => $composition->getId() === $request->query->getInt('edit'));
if ($householdCompositions->count() !== 1) {
throw new BadRequestHttpException('could not find the composition with this id associated to the household');

View File

@@ -81,9 +81,7 @@ class HouseholdController extends AbstractController
}
}
usort($accompanyingPeriods, static function ($a, $b) {
return $b->getOpeningDate() <=> $a->getOpeningDate();
});
usort($accompanyingPeriods, static fn($a, $b) => $b->getOpeningDate() <=> $a->getOpeningDate());
$oldMembers = $household->getNonCurrentMembers();
$accompanyingPeriodsOld = [];

View File

@@ -108,14 +108,10 @@ class PersonApiController extends ApiController
$addresses = $person
->getAccompanyingPeriodParticipations()
->filter(
static function (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool {
return null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation();
}
static fn(AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool => null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation()
)
->map(
static function (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address {
return $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation();
}
static fn(AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address => $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation()
)
->filter(
// We remove potential null addresses.

View File

@@ -44,9 +44,7 @@ class SocialWorkSocialActionApiController extends ApiController
$socialActions = $socialIssue->getRecursiveSocialActions()->toArray();
usort($socialActions, static function (SocialAction $sa, SocialAction $sb) {
return $sa->getOrdering() <=> $sb->getOrdering();
});
usort($socialActions, static fn(SocialAction $sa, SocialAction $sb) => $sa->getOrdering() <=> $sb->getOrdering());
$pagination = $this->paginator->create(count($socialActions));
// max one page

View File

@@ -115,9 +115,7 @@ class LoadCustomFields extends AbstractFixture implements
// get possible values for cfGroup
$choices = array_map(
static function ($a) {
return $a['slug'];
},
static fn($a) => $a['slug'],
$this->customFieldChoice->getOptions()['choices']
);
// create faker

View File

@@ -828,9 +828,7 @@ class AccompanyingPeriod implements
$collection = $this
->getParticipationsContainsPerson($person)
->filter(
static function (AccompanyingPeriodParticipation $participation): bool {
return null === $participation->getEndDate();
}
static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate()
);
return $collection->count() > 0 ? $collection->first() : null;
@@ -844,9 +842,7 @@ class AccompanyingPeriod implements
return $this
->getParticipations()
->filter(
static function (AccompanyingPeriodParticipation $participation): bool {
return null === $participation->getEndDate();
}
static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate()
);
}

View File

@@ -44,20 +44,20 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
* @Assert\NotBlank
* @Assert\NotNull
*/
private ?string $content;
private ?string $content = null;
/**
* @ORM\Column(type="datetime")
* @Groups({"read", "docgen:read"})
*/
private ?DateTimeInterface $createdAt;
private ?DateTimeInterface $createdAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
* @Groups({"read", "docgen:read"})
*/
private ?User $creator;
private ?User $creator = null;
/**
* @ORM\Id
@@ -65,20 +65,20 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
* @ORM\Column(type="integer")
* @Groups({"read", "docgen:read"})
*/
private ?int $id;
private ?int $id = null;
/**
* @ORM\Column(type="datetime")
* @Groups({"read"})
*/
private ?DateTimeInterface $updatedAt;
private ?DateTimeInterface $updatedAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
* @Groups({"read"})
*/
private ?User $updatedBy;
private ?User $updatedBy = null;
public function getAccompanyingPeriod(): ?AccompanyingPeriod
{

View File

@@ -200,13 +200,11 @@ class Household
*/
public function getCurrentAddress(?DateTime $at = null): ?Address
{
$at = $at ?? new DateTime('today');
$at ??= new DateTime('today');
$addrs = $this->getAddresses()->filter(static function (Address $a) use ($at) {
return $a->getValidFrom() <= $at && (
null === $a->getValidTo() || $a->getValidTo() > $at
);
});
$addrs = $this->getAddresses()->filter(static fn(Address $a) => $a->getValidFrom() <= $at && (
null === $a->getValidTo() || $a->getValidTo() > $at
));
if ($addrs->count() > 0) {
return $addrs->first();
@@ -338,9 +336,7 @@ class Household
public function getCurrentPersons(?DateTimeImmutable $now = null): ReadableCollection
{
return $this->getCurrentMembers($now)
->map(static function (HouseholdMember $m) {
return $m->getPerson();
});
->map(static fn(HouseholdMember $m) => $m->getPerson());
}
public function getId(): ?int
@@ -367,9 +363,7 @@ class Household
$membership->getStartDate(),
$membership->getEndDate()
)->filter(
static function (HouseholdMember $m) use ($membership) {
return $m->getPerson() !== $membership->getPerson();
}
static fn(HouseholdMember $m) => $m->getPerson() !== $membership->getPerson()
);
}
@@ -508,9 +502,7 @@ class Household
usort(
$compositionOrdered,
static function (HouseholdComposition $a, HouseholdComposition $b) {
return $a->getStartDate() <=> $b->getStartDate();
}
static fn(HouseholdComposition $a, HouseholdComposition $b) => $a->getStartDate() <=> $b->getStartDate()
);
$iterator = new ArrayIterator($compositionOrdered);

View File

@@ -142,7 +142,7 @@ class HouseholdMember
public function isCurrent(?DateTimeImmutable $at = null): bool
{
$at = $at ?? new DateTimeImmutable('now');
$at ??= new DateTimeImmutable('now');
return $this->getStartDate() < $at && (
null === $this->getEndDate() || $this->getEndDate() > $at

View File

@@ -775,9 +775,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
): int {
// TODO should be optimized to avoid loading accompanying period ?
return $this->getAccompanyingPeriodInvolved($asParticipantOpen, $asRequestor)
->filter(function (AccompanyingPeriod $p) {
return $p->getStep() !== AccompanyingPeriod::STEP_DRAFT;
})
->filter(fn(AccompanyingPeriod $p) => $p->getStep() !== AccompanyingPeriod::STEP_DRAFT)
->count();
}
@@ -1341,9 +1339,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->getAccompanyingPeriodParticipations()
->matching($criteria)
->filter(static function (AccompanyingPeriodParticipation $app) {
return AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep();
});
->filter(static fn(AccompanyingPeriodParticipation $app) => AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep());
}
public function getOtherPhoneNumbers(): Collection

View File

@@ -50,7 +50,7 @@ class PersonCurrentAddress
/**
* @ORM\Column(name="valid_to", type="date_immutable")
*/
protected ?DateTimeImmutable $validTo;
protected ?DateTimeImmutable $validTo = null;
public function getAddress(): Address
{

View File

@@ -55,7 +55,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
* @ORM\Column(type="integer")
* @Groups({"read", "docgen:read"})
*/
private ?int $id;
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=PersonResourceKind::class, inversedBy="personResources")

View File

@@ -41,7 +41,7 @@ class PersonPhone
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id;
private ?int $id = null;
/**
* @ORM\ManyToOne(
@@ -59,7 +59,7 @@ class PersonPhone
/**
* @ORM\Column(type="text", length=40, nullable=true)
*/
private ?string $type;
private ?string $type = null;
public function __construct()
{

View File

@@ -45,7 +45,7 @@ class Result
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTime $desactivationDate;
private ?DateTime $desactivationDate = null;
/**
* @ORM\ManyToMany(targetEntity=Goal::class, mappedBy="results")

View File

@@ -128,9 +128,7 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
'placeholder' => 'Select a geographical layer',
'class' => GeographicalUnitLayer::class,
'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(),
'choice_label' => function (GeographicalUnitLayer $item) {
return $this->translatableStringHelper->localize($item->getName());
},
'choice_label' => fn(GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()),
]);
}

View File

@@ -147,9 +147,7 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme
];
}
return static function (string $value) use ($labels): string {
return $labels[$value];
};
return static fn(string $value): string => $labels[$value];
}
public function getQueryKeys($data)

View File

@@ -100,9 +100,7 @@ class GeographicalUnitAggregator implements AggregatorInterface
'placeholder' => 'Select a geographical layer',
'class' => GeographicalUnitLayer::class,
'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(),
'choice_label' => function (GeographicalUnitLayer $item) {
return $this->translatableStringHelper->localize($item->getName());
},
'choice_label' => fn(GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()),
]);
}

View File

@@ -141,9 +141,7 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV
];
}
return static function ($value) use ($labels): string {
return $labels[$value];
};
return static fn($value): string => $labels[$value];
}
public function getQueryKeys($data)

View File

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

View File

@@ -63,9 +63,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter
$labels = array_combine($values, $values);
$labels['_header'] = $this->getTitle();
return static function ($value) use ($labels) {
return $labels[$value];
};
return static fn($value) => $labels[$value];
}
public function getQueryKeys($data): array
@@ -90,9 +88,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
{
$centers = array_map(static function ($el) {
return $el['center'];
}, $acl);
$centers = array_map(static fn($el) => $el['center'], $acl);
$qb = $this->em->createQueryBuilder();

View File

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

View File

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

View File

@@ -62,9 +62,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface
$labels = array_combine($values, $values);
$labels['_header'] = $this->getTitle();
return static function ($value) use ($labels) {
return $labels[$value];
};
return static fn($value) => $labels[$value];
}
public function getQueryKeys($data)
@@ -94,9 +92,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface
*/
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static function ($el) {
return $el['center'];
}, $acl);
$centers = array_map(static fn($el) => $el['center'], $acl);
$qb = $this->personRepository->createQueryBuilder('person');

View File

@@ -64,9 +64,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
$labels = array_combine($values, $values);
$labels['_header'] = $this->getTitle();
return static function ($value) use ($labels) {
return $labels[$value];
};
return static fn($value) => $labels[$value];
}
public function getQueryKeys($data): array
@@ -91,9 +89,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static function ($el) {
return $el['center'];
}, $acl);
$centers = array_map(static fn($el) => $el['center'], $acl);
$qb = $this->repository->createQueryBuilder('acp');

View File

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

View File

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

View File

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

View File

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

View File

@@ -191,9 +191,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
*/
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static function ($el) {
return $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

@@ -159,9 +159,7 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac
*/
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static function ($el) {
return $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

@@ -112,9 +112,7 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
{
$centers = array_map(static function ($el) {
return $el['center'];
}, $acl);
$centers = array_map(static fn($el) => $el['center'], $acl);
$qb = $this->repository->createQueryBuilder('acp');

View File

@@ -59,9 +59,7 @@ class ClosingMotiveFilter implements FilterInterface
{
$builder->add('accepted_closingmotives', EntityType::class, [
'class' => ClosingMotive::class,
'choice_label' => function (ClosingMotive $cm) {
return $this->translatableStringHelper->localize($cm->getName());
},
'choice_label' => fn(ClosingMotive $cm) => $this->translatableStringHelper->localize($cm->getName()),
'multiple' => true,
'expanded' => true,
]);

View File

@@ -61,11 +61,9 @@ class CreatorJobFilter implements FilterInterface
$builder->add('creator_job', EntityType::class, [
'class' => UserJob::class,
'choices' => $this->userJobRepository->findAllActive(),
'choice_label' => function (UserJob $j) {
return $this->translatableStringHelper->localize(
$j->getLabel()
);
},
'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize(
$j->getLabel()
),
'multiple' => true,
'expanded' => true,
'label' => 'Job',

View File

@@ -69,9 +69,7 @@ class EvaluationFilter implements FilterInterface
$builder->add('accepted_evaluations', EntityType::class, [
'class' => Evaluation::class,
'choices' => $this->evaluationRepository->findAllActive(),
'choice_label' => function (Evaluation $ev) {
return $this->translatableStringHelper->localize($ev->getTitle());
},
'choice_label' => fn(Evaluation $ev) => $this->translatableStringHelper->localize($ev->getTitle()),
'multiple' => true,
'expanded' => false,
'attr' => ['class' => 'select2'],

View File

@@ -107,9 +107,7 @@ class GeographicalUnitStatFilter implements FilterInterface
'placeholder' => 'Select a geographical unit',
'choices' => $this->geographicalUnitRepository->findAll(),
'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id,
'choice_label' => function (SimpleGeographicalUnitDTO $item) {
return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName;
},
'choice_label' => fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName,
'attr' => [
'class' => 'select2',
],
@@ -124,9 +122,7 @@ class GeographicalUnitStatFilter implements FilterInterface
'%units' => implode(
', ',
array_map(
function (SimpleGeographicalUnitDTO $item) {
return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName;
},
fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName,
$data['units']
)
),

View File

@@ -59,9 +59,7 @@ class OriginFilter implements FilterInterface
{
$builder->add('accepted_origins', EntityType::class, [
'class' => Origin::class,
'choice_label' => function (Origin $o) {
return $this->translatableStringHelper->localize($o->getLabel());
},
'choice_label' => fn(Origin $o) => $this->translatableStringHelper->localize($o->getLabel()),
'multiple' => true,
'expanded' => true,
]);

View File

@@ -59,9 +59,7 @@ final class EvaluationTypeFilter implements FilterInterface
{
$builder->add('accepted_evaluationtype', EntityType::class, [
'class' => Evaluation::class,
'choice_label' => function (Evaluation $ev): string {
return $this->translatableStringHelper->localize($ev->getTitle());
},
'choice_label' => fn(Evaluation $ev): string => $this->translatableStringHelper->localize($ev->getTitle()),
'multiple' => true,
'expanded' => true,
]);

View File

@@ -78,11 +78,9 @@ class CompositionFilter implements FilterInterface
$builder
->add('accepted_composition', EntityType::class, [
'class' => HouseholdCompositionType::class,
'choice_label' => function (HouseholdCompositionType $type) {
return $this->translatableStringHelper->localize(
$type->getLabel()
);
},
'choice_label' => fn(HouseholdCompositionType $type) => $this->translatableStringHelper->localize(
$type->getLabel()
),
'multiple' => true,
'expanded' => true,
])

View File

@@ -81,9 +81,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface
->add('ref_statuses', ChoiceType::class, [
'label' => 'export.filter.person.by_address_ref_status.Status',
'choices' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW, Address::ADDR_REFERENCE_STATUS_REVIEWED, Address::ADDR_REFERENCE_STATUS_MATCH],
'choice_label' => function (string $item) {
return 'export.filter.person.by_address_ref_status.'.$item;
},
'choice_label' => fn(string $item) => 'export.filter.person.by_address_ref_status.'.$item,
'multiple' => true,
'expanded' => true,
'data' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW]
@@ -99,9 +97,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface
'%statuses%' => implode(
', ',
array_map(
function (string $item) {
return 'export.filter.person.by_address_ref_status.'.$item;
},
fn(string $item) => 'export.filter.person.by_address_ref_status.'.$item,
$data['ref_statuses'] ?? RollingDate::T_TODAY
)
),

View File

@@ -67,9 +67,7 @@ class GenderFilter implements
$qb->add('where', $where);
$qb->setParameter('person_gender', array_filter(
$data['accepted_genders'],
static function ($el) {
return 'null' !== $el;
}
static fn($el) => 'null' !== $el
));
}

View File

@@ -98,9 +98,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface
'placeholder' => 'Select a geographical unit',
'choices' => $this->geographicalUnitRepository->findAll(),
'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id,
'choice_label' => function (SimpleGeographicalUnitDTO $item) {
return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName;
},
'choice_label' => fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName,
'attr' => [
'class' => 'select2',
],
@@ -117,9 +115,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface
'%units%' => implode(
', ',
array_map(
function (SimpleGeographicalUnitDTO $item) {
return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName;
},
fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName,
$data['units']
)
),

View File

@@ -49,11 +49,9 @@ class MaritalStatusFilter implements FilterInterface
{
$builder->add('maritalStatus', EntityType::class, [
'class' => MaritalStatus::class,
'choice_label' => function (MaritalStatus $ms) {
return $this->translatableStringHelper->localize(
$ms->getName()
);
},
'choice_label' => fn(MaritalStatus $ms) => $this->translatableStringHelper->localize(
$ms->getName()
),
'multiple' => true,
'expanded' => true,
]);

View File

@@ -72,9 +72,7 @@ class NationalityFilter implements
{
$countries = $data['nationalities'];
$names = array_map(function (Country $c) {
return $this->translatableStringHelper->localize($c->getName());
}, [$countries]);
$names = array_map(fn(Country $c) => $this->translatableStringHelper->localize($c->getName()), [$countries]);
return [
'Filtered by nationality : %nationalities%',

View File

@@ -100,9 +100,7 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface
$builder->add('thirdparty_cat', EntityType::class, [
'class' => ThirdPartyCategory::class,
'label' => 'Category',
'choice_label' => function (ThirdPartyCategory $tpc) {
return $this->translatableStringHelper->localize($tpc->getName());
},
'choice_label' => fn(ThirdPartyCategory $tpc) => $this->translatableStringHelper->localize($tpc->getName()),
'multiple' => true,
'expanded' => true,
]);

View File

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

View File

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

View File

@@ -136,7 +136,7 @@ class SocialWorkTypeFilter implements FilterInterface
}
return ['Filtered actions by type, goals and results: %selected%', [
'%selected%' => implode(', ', array_merge($actionTypes, $goals, $results)),
'%selected%' => implode(', ', [...$actionTypes, ...$goals, ...$results]),
]];
}

View File

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

View File

@@ -40,9 +40,7 @@ class HouseholdCompositionType extends AbstractType
->add('householdCompositionType', EntityType::class, [
'class' => \Chill\PersonBundle\Entity\Household\HouseholdCompositionType::class,
'choices' => $types,
'choice_label' => function (\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) {
return $this->translatableStringHelper->localize($type->getLabel());
},
'choice_label' => fn(\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) => $this->translatableStringHelper->localize($type->getLabel()),
'label' => 'household_composition.Household composition',
])
->add('startDate', ChillDateType::class, [

View File

@@ -118,12 +118,8 @@ class PersonType extends AbstractType
]);
$builder->get('placeOfBirth')->addModelTransformer(new CallbackTransformer(
static function ($string) {
return strtoupper((string) $string);
},
static function ($string) {
return strtoupper((string) $string);
}
static fn($string) => strtoupper((string) $string),
static fn($string) => strtoupper((string) $string)
));
}
@@ -167,9 +163,7 @@ class PersonType extends AbstractType
'allow_delete' => true,
'by_reference' => false,
'label' => false,
'delete_empty' => static function (?PersonPhone $pp = null) {
return null === $pp || $pp->isEmpty();
},
'delete_empty' => static fn(?PersonPhone $pp = null) => null === $pp || $pp->isEmpty(),
'error_bubbling' => false,
'empty_collection_explain' => 'No additional phone numbers',
]);

View File

@@ -46,9 +46,7 @@ class GoalType extends AbstractType
'class' => Result::class,
'required' => false,
'multiple' => true,
'choice_label' => function (Result $r) {
return $this->translatableStringHelper->localize($r->getTitle());
},
'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()),
'attr' => ['class' => 'select2 '],
])
->add('desactivationDate', ChillDateType::class, [

View File

@@ -50,16 +50,12 @@ class SocialActionType extends AbstractType
->add('issue', EntityType::class, [
'class' => SocialIssue::class,
'label' => 'socialAction.socialIssue',
'choice_label' => function (SocialIssue $issue) {
return $this->translatableStringHelper->localize($issue->getTitle());
},
'choice_label' => fn(SocialIssue $issue) => $this->translatableStringHelper->localize($issue->getTitle()),
])
->add('parent', EntityType::class, [
'class' => SocialAction::class,
'required' => false,
'choice_label' => function (SocialAction $issue) {
return $this->translatableStringHelper->localize($issue->getTitle());
},
'choice_label' => fn(SocialAction $issue) => $this->translatableStringHelper->localize($issue->getTitle()),
])
->add('ordering', NumberType::class, [
'required' => true,
@@ -70,9 +66,7 @@ class SocialActionType extends AbstractType
'required' => false,
'multiple' => true,
'attr' => ['class' => 'select2'],
'choice_label' => function (Result $r) {
return $this->translatableStringHelper->localize($r->getTitle());
},
'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()),
])
->add('goals', EntityType::class, [
@@ -80,9 +74,7 @@ class SocialActionType extends AbstractType
'required' => false,
'multiple' => true,
'attr' => ['class' => 'select2'],
'choice_label' => function (Goal $g) {
return $this->translatableStringHelper->localize($g->getTitle());
},
'choice_label' => fn(Goal $g) => $this->translatableStringHelper->localize($g->getTitle()),
])
->add('evaluations', EntityType::class, [
@@ -90,9 +82,7 @@ class SocialActionType extends AbstractType
'required' => false,
'multiple' => true,
'attr' => ['class' => 'select2'],
'choice_label' => function (Evaluation $e) {
return $this->translatableStringHelper->localize($e->getTitle());
},
'choice_label' => fn(Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()),
])
->add('defaultNotificationDelay', DateIntervalType::class, [

View File

@@ -60,18 +60,14 @@ class ClosingMotivePickerType extends AbstractType
'class' => ClosingMotive::class,
'empty_data' => null,
'placeholder' => 'Choose a motive',
'choice_label' => function (ClosingMotive $cm) {
return $this->entityRenderExtension->renderString($cm);
},
'choice_label' => fn(ClosingMotive $cm) => $this->entityRenderExtension->renderString($cm),
'only_leaf' => true,
]);
$resolver
->setAllowedTypes('only_leaf', 'bool')
->setNormalizer('choices', function (Options $options) {
return $this->repository
->getActiveClosingMotive($options['only_leaf']);
});
->setNormalizer('choices', fn(Options $options) => $this->repository
->getActiveClosingMotive($options['only_leaf']));
}
/**

View File

@@ -113,15 +113,11 @@ class PickPersonType extends AbstractType
// add the default options
$resolver->setDefaults([
'class' => Person::class,
'choice_label' => static function (Person $p) {
return $p->getFirstname() . ' ' . $p->getLastname();
},
'choice_label' => static fn(Person $p) => $p->getFirstname() . ' ' . $p->getLastname(),
'placeholder' => 'Pick a person',
'choice_attr' => static function (Person $p) {
return [
'data-center' => $p->getCenter()->getId(),
];
},
'choice_attr' => static fn(Person $p) => [
'data-center' => $p->getCenter()->getId(),
],
'attr' => ['class' => 'select2 '],
'choice_loader' => function (Options $options) {
$centers = $this->filterCentersfom($options);
@@ -139,9 +135,7 @@ class PickPersonType extends AbstractType
protected function filterCentersfom(Options $options)
{
if (null === $options['role']) {
$centers = array_map(static function (GroupCenter $g) {
return $g->getCenter();
}, $this->user->getGroupCenters()->toArray());
$centers = array_map(static fn(GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray());
} else {
$centers = $this->authorizationHelper
->getReachableCenters($this->user, $options['role']->getRole());
@@ -164,9 +158,7 @@ class PickPersonType extends AbstractType
if (
!in_array($c->getId(), array_map(
static function (Center $c) {
return $c->getId();
},
static fn(Center $c) => $c->getId(),
$centers
), true)
) {

View File

@@ -38,9 +38,7 @@ class PickSocialActionType extends AbstractType
->setDefaults([
'class' => SocialAction::class,
'choices' => $this->actionRepository->findAllActive(),
'choice_label' => function (SocialAction $sa) {
return $this->actionRender->renderString($sa, []);
},
'choice_label' => fn(SocialAction $sa) => $this->actionRender->renderString($sa, []),
'placeholder' => 'Pick a social action',
'required' => false,
'attr' => ['class' => 'select2'],

View File

@@ -38,9 +38,7 @@ class PickSocialIssueType extends AbstractType
->setDefaults([
'class' => SocialIssue::class,
'choices' => $this->issueRepository->findAllActive(),
'choice_label' => function (SocialIssue $si) {
return $this->issueRender->renderString($si, []);
},
'choice_label' => fn(SocialIssue $si) => $this->issueRender->renderString($si, []),
'placeholder' => 'Pick a social issue',
'required' => false,
'attr' => ['class' => 'select2'],

View File

@@ -76,9 +76,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
$involved = $this->getInvolved();
$involved['period_id'] = $event->getPeriod()->getId();
$involved['persons'] = $event->getPeriod()->getPersons()
->map(static function (Person $p) {
return $p->getId();
})
->map(static fn(Person $p) => $p->getId())
->toArray();
$this->logger->notice(
@@ -102,9 +100,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
if ($event->hasPersons()) {
$involved['persons'] = array_map(
static function (Person $p) {
return $p->getId();
},
static fn(Person $p) => $p->getId(),
$event->getPersons()
);
}

View File

@@ -322,9 +322,7 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
),
]
),
array_map(static function (Center $c) {
return $c->getId();
}, $authorizedCenters)
array_map(static fn(Center $c) => $c->getId(), $authorizedCenters)
);
}
}

View File

@@ -97,9 +97,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi
private function checkAssociatedMembersRole(Household $household, string $attribute): bool
{
foreach ($household->getCurrentMembers()->map(static function (HouseholdMember $member) {
return $member->getPerson();
}) as $person) {
foreach ($household->getCurrentMembers()->map(static fn(HouseholdMember $member) => $member->getPerson()) as $person) {
if ($this->security->isGranted($attribute, $person)) {
return true;
}

View File

@@ -150,12 +150,8 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
$this->closingMotiveRender->renderString($period->getClosingMotive(), []) : '',
'ref' => $this->normalizer->normalize($period->getUser(), $format, $userContext),
'hasRef' => $period->getUser() !== null,
'socialIssuesText' => implode(', ', array_map(function (SocialIssue $s) {
return $this->socialIssueRender->renderString($s, []);
}, $period->getSocialIssues()->toArray())),
'scopesText' => implode(', ', array_map(function (Scope $s) {
return $this->translatableStringHelper->localize($s->getName());
}, $scopes)),
'socialIssuesText' => implode(', ', array_map(fn(SocialIssue $s) => $this->socialIssueRender->renderString($s, []), $period->getSocialIssues()->toArray())),
'scopesText' => implode(', ', array_map(fn(Scope $s) => $this->translatableStringHelper->localize($s->getName()), $scopes)),
'hasRequestor' => $period->getRequestor() !== null,
'requestorKind' => $period->getRequestorKind(),
'hasLocation' => $period->getLocation() !== null,

View File

@@ -48,9 +48,7 @@ class AccompanyingPeriodWorkEvaluationNormalizer implements ContextAwareNormaliz
$initial = $this->normalizer->normalize($object, $format, array_merge(
$context,
[self::IGNORE_EVALUATION => spl_object_hash($object)],
[AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => static function ($object, $format, $context) {
return $object->getId();
}]
[AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => static fn($object, $format, $context) => $object->getId()]
));
// due to bug: https://api-platform.com/docs/core/serialization/#collection-relation

View File

@@ -94,9 +94,7 @@ class PersonDocGenNormalizer implements
// we simplify the list of attributes for the embedded persons
AbstractNormalizer::GROUPS => ['docgen:read'],
// when a person reference the same person... take care of circular references
AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => function ($object, $format, $context) {
return $this->normalizer->normalize(null, $format, $context);
},
AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => fn($object, $format, $context) => $this->normalizer->normalize(null, $format, $context),
]);
if (null === $person) {
@@ -117,9 +115,7 @@ class PersonDocGenNormalizer implements
'altNames' => implode(
', ',
array_map(
static function (PersonAltName $altName) {
return $altName->getLabel();
},
static fn(PersonAltName $altName) => $altName->getLabel(),
$person->getAltNames()->toArray()
)
),

View File

@@ -257,12 +257,10 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
{
return $altNames
->map(
static function (PersonAltName $personAltName): array {
return [
'key' => $personAltName->getKey(),
'label' => $personAltName->getLabel(),
];
}
static fn(PersonAltName $personAltName): array => [
'key' => $personAltName->getKey(),
'label' => $personAltName->getLabel(),
]
)
->toArray();
}

View File

@@ -37,9 +37,7 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz
'type' => 'social_issue',
'id' => $socialIssue->getId(),
'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null,
'children_ids' => $socialIssue->getChildren()->map(static function (SocialIssue $si) {
return $si->getId();
}),
'children_ids' => $socialIssue->getChildren()->map(static fn(SocialIssue $si) => $si->getId()),
'title' => $socialIssue->getTitle(),
'text' => $this->render->renderString($socialIssue, []),
];

View File

@@ -143,14 +143,10 @@ class AccompanyingPeriodContext implements
->add('category', EntityType::class, [
'placeholder' => 'Choose a document category',
'class' => DocumentCategory::class,
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('c')
->where('c.documentClass = :docClass')
->setParameter('docClass', AccompanyingCourseDocument::class);
},
'choice_label' => function ($entity = null) {
return $entity ? $this->translatableStringHelper->localize($entity->getName()) : '';
},
'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c')
->where('c.documentClass = :docClass')
->setParameter('docClass', AccompanyingCourseDocument::class),
'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '',
]);
}
@@ -160,9 +156,7 @@ class AccompanyingPeriodContext implements
public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, mixed $entity): void
{
$options = $template->getOptions();
$persons = new ArrayCollection($entity->getCurrentParticipations()->map(static function (AccompanyingPeriodParticipation $p) {
return $p->getPerson();
})->toArray());
$persons = new ArrayCollection($entity->getCurrentParticipations()->map(static fn(AccompanyingPeriodParticipation $p) => $p->getPerson())->toArray());
foreach ($entity->getCurrentParticipations() as $p) {
foreach ($p->getPerson()->getResources() as $r) {
@@ -187,9 +181,7 @@ class AccompanyingPeriodContext implements
$builder->add($key, EntityType::class, [
'class' => Person::class,
'choices' => $persons,
'choice_label' => function (Person $p) {
return $this->personRender->renderString($p, ['addAge' => true]);
},
'choice_label' => fn(Person $p) => $this->personRender->renderString($p, ['addAge' => true]),
'multiple' => false,
'expanded' => true,
'required' => false,

View File

@@ -63,9 +63,7 @@ class AccompanyingPeriodWorkEvaluationContext implements
$this->accompanyingPeriodWorkContext->adminFormReverseTransform($data),
[
'evaluations' => array_map(
static function (Evaluation $e) {
return $e->getId();
},
static fn(Evaluation $e) => $e->getId(),
$data['evaluations']
),
]
@@ -78,9 +76,7 @@ class AccompanyingPeriodWorkEvaluationContext implements
$this->accompanyingPeriodWorkContext->adminFormTransform($data),
[
'evaluations' => array_map(
function ($id) {
return $this->evaluationRepository->find($id);
},
fn($id) => $this->evaluationRepository->find($id),
$data['evaluations'] ?? []
),
]
@@ -97,9 +93,7 @@ class AccompanyingPeriodWorkEvaluationContext implements
'class' => Evaluation::class,
'label' => 'Linked evaluations',
'choices' => $this->evaluationRepository->findAll(),
'choice_label' => function (Evaluation $e) {
return $this->translatableStringHelper->localize($e->getTitle());
},
'choice_label' => fn(Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()),
'multiple' => true,
'attr' => ['class' => 'select2'],
]);

View File

@@ -126,14 +126,10 @@ final class PersonContext implements PersonContextInterface
->add('category', EntityType::class, [
'placeholder' => 'Choose a document category',
'class' => DocumentCategory::class,
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('c')
->where('c.documentClass = :docClass')
->setParameter('docClass', PersonDocument::class);
},
'choice_label' => function ($entity = null) {
return $entity ? $this->translatableStringHelper->localize($entity->getName()) : '';
},
'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c')
->where('c.documentClass = :docClass')
->setParameter('docClass', PersonDocument::class),
'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '',
'required' => true,
]);
}

View File

@@ -342,9 +342,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
// check that the person id is contained
$participationsPersonsIds = array_map(
static function ($participation) {
return $participation->person->id;
},
static fn($participation) => $participation->person->id,
$data->participations
);

View File

@@ -161,9 +161,7 @@ final class HouseholdApiControllerTest extends WebTestCase
$this->assertArrayHasKey('count', $data);
$this->assertArrayHasKey('results', $data);
$householdIds = array_map(static function ($r) {
return $r['id'];
}, $data['results']);
$householdIds = array_map(static fn($r) => $r['id'], $data['results']);
$this->assertContains($expectedHouseholdId, $householdIds);
}

View File

@@ -294,49 +294,23 @@ final class PersonControllerUpdateTest extends WebTestCase
public function validTextFieldsProvider()
{
return [
['firstName', 'random Value', static function (Person $person) {
return $person->getFirstName();
}],
['lastName', 'random Value', static function (Person $person) {
return $person->getLastName();
}],
['firstName', 'random Value', static fn(Person $person) => $person->getFirstName()],
['lastName', 'random Value', static fn(Person $person) => $person->getLastName()],
// reminder: this value is capitalized
['placeOfBirth', 'A PLACE', static function (Person $person) {
return $person->getPlaceOfBirth();
}],
['birthdate', '1980-12-15', static function (Person $person) {
return $person->getBirthdate()->format('Y-m-d');
}],
['placeOfBirth', 'A PLACE', static fn(Person $person) => $person->getPlaceOfBirth()],
['birthdate', '1980-12-15', static fn(Person $person) => $person->getBirthdate()->format('Y-m-d')],
// TODO test on phonenumber update
// ['phonenumber', '+32123456789', static function (Person $person) { return $person->getPhonenumber(); }],
['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) {
return $person->getMemo();
}],
['countryOfBirth', 'BE', static function (Person $person) {
return $person->getCountryOfBirth()->getCountryCode();
}],
['nationality', 'FR', static function (Person $person) {
return $person->getNationality()->getCountryCode();
}],
['placeOfBirth', '', static function (Person $person) {
return $person->getPlaceOfBirth();
}],
['birthdate', '', static function (Person $person) {
return $person->getBirthdate();
}],
['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn(Person $person) => $person->getMemo()],
['countryOfBirth', 'BE', static fn(Person $person) => $person->getCountryOfBirth()->getCountryCode()],
['nationality', 'FR', static fn(Person $person) => $person->getNationality()->getCountryCode()],
['placeOfBirth', '', static fn(Person $person) => $person->getPlaceOfBirth()],
['birthdate', '', static fn(Person $person) => $person->getBirthdate()],
//['phonenumber', '', static function (Person $person) { return $person->getPhonenumber(); }],
['memo', '', static function (Person $person) {
return $person->getMemo();
}],
['countryOfBirth', null, static function (Person $person) {
return $person->getCountryOfBirth();
}],
['nationality', null, static function (Person $person) {
return $person->getNationality();
}],
['gender', Person::FEMALE_GENDER, static function (Person $person) {
return $person->getGender();
}],
['memo', '', static fn(Person $person) => $person->getMemo()],
['countryOfBirth', null, static fn(Person $person) => $person->getCountryOfBirth()],
['nationality', null, static fn(Person $person) => $person->getNationality()],
['gender', Person::FEMALE_GENDER, static fn(Person $person) => $person->getGender()],
];
}

View File

@@ -197,24 +197,12 @@ final class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase
public function validTextFieldsProvider()
{
return [
['firstName', 'random Value', static function (Person $person) {
return $person->getFirstName();
}],
['lastName', 'random Value', static function (Person $person) {
return $person->getLastName();
}],
['birthdate', '15-12-1980', static function (Person $person) {
return $person->getBirthdate()->format('d-m-Y');
}],
['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) {
return $person->getMemo();
}],
['birthdate', '', static function (Person $person) {
return $person->getBirthdate();
}],
['gender', Person::FEMALE_GENDER, static function (Person $person) {
return $person->getGender();
}],
['firstName', 'random Value', static fn(Person $person) => $person->getFirstName()],
['lastName', 'random Value', static fn(Person $person) => $person->getLastName()],
['birthdate', '15-12-1980', static fn(Person $person) => $person->getBirthdate()->format('d-m-Y')],
['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn(Person $person) => $person->getMemo()],
['birthdate', '', static fn(Person $person) => $person->getBirthdate()],
['gender', Person::FEMALE_GENDER, static fn(Person $person) => $person->getGender()],
];
}

View File

@@ -152,9 +152,7 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
$locations = $period->getLocationHistories()->toArray();
usort($locations, static function (AccompanyingPeriod\AccompanyingPeriodLocationHistory $a, AccompanyingPeriod\AccompanyingPeriodLocationHistory $b) {
return $a->getStartDate() <=> $b->getStartDate();
});
usort($locations, static fn(AccompanyingPeriod\AccompanyingPeriodLocationHistory $a, AccompanyingPeriod\AccompanyingPeriodLocationHistory $b) => $a->getStartDate() <=> $b->getStartDate());
$iterator = new ArrayIterator($locations);
$iterator->rewind();

View File

@@ -101,19 +101,13 @@ final class MembersEditorTest extends TestCase
$editor = $factory->createEditor($household2 = new Household());
$editor->addMovement(new DateTimeImmutable('yesterday'), $person, $positionNotSharing);
$sharings = $household->getCurrentMembers()->filter(static function (HouseholdMember $m) {
return $m->getShareHousehold();
});
$notSharing = $household2->getCurrentMembers()->filter(static function (HouseholdMember $m) {
return !$m->getShareHousehold();
});
$sharings = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => $m->getShareHousehold());
$notSharing = $household2->getCurrentMembers()->filter(static fn(HouseholdMember $m) => !$m->getShareHousehold());
$this->assertCount(1, $notSharing);
$this->assertCount(1, $sharings);
$getPerson = static function (HouseholdMember $m) {
return $m->getPerson();
};
$getPerson = static fn(HouseholdMember $m) => $m->getPerson();
$this->assertContains($person, $notSharing->map($getPerson));
}
@@ -143,19 +137,13 @@ final class MembersEditorTest extends TestCase
$editor = $factory->createEditor($household);
$editor->addMovement(new DateTimeImmutable('yesterday'), $person, $positionNotSharing);
$sharings = $household->getCurrentMembers()->filter(static function (HouseholdMember $m) {
return $m->getShareHousehold();
});
$notSharing = $household->getCurrentMembers()->filter(static function (HouseholdMember $m) {
return !$m->getShareHousehold();
});
$sharings = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => $m->getShareHousehold());
$notSharing = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => !$m->getShareHousehold());
$this->assertCount(1, $notSharing);
$this->assertCount(0, $sharings);
$getPerson = static function (HouseholdMember $m) {
return $m->getPerson();
};
$getPerson = static fn(HouseholdMember $m) => $m->getPerson();
$this->assertContains($person, $notSharing->map($getPerson));
}

View File

@@ -318,9 +318,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
$normalizerManager = $this->prophesize(NormalizerInterface::class);
$normalizerManager->supportsNormalization(Argument::any(), 'docgen', Argument::any())->willReturn(true);
$normalizerManager->normalize(Argument::type(Person::class), 'docgen', Argument::any())
->will(static function ($args) use ($normalizer) {
return $normalizer->normalize($args[0], $args[1], $args[2]);
});
->will(static fn($args) => $normalizer->normalize($args[0], $args[1], $args[2]));
$normalizerManager->normalize(Argument::any(), 'docgen', Argument::any())->will(
static function ($args) {
if (is_iterable($args[0])) {

View File

@@ -118,9 +118,7 @@ final class RelationshipDocGenNormalizerTest extends TestCase
{
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
$translatableStringHelper->localize(Argument::type('array'))->will(
static function ($args) {
return $args[0][array_keys($args[0])[0]];
}
static fn($args) => $args[0][array_keys($args[0])[0]]
);
$normalizer = new RelationshipDocGenNormalizer(
@@ -130,9 +128,7 @@ final class RelationshipDocGenNormalizerTest extends TestCase
$normalizerManager = $this->prophesize(NormalizerInterface::class);
$normalizerManager->supportsNormalization(Argument::any(), 'docgen', Argument::any())->willReturn(true);
$normalizerManager->normalize(Argument::type(Relationship::class), 'docgen', Argument::any())
->will(static function ($args) use ($normalizer) {
return $normalizer->normalize($args[0], $args[1], $args[2]);
});
->will(static fn($args) => $normalizer->normalize($args[0], $args[1], $args[2]));
$normalizerManager->normalize(Argument::any(), 'docgen', Argument::any())->will(
static function ($args) {
if (null === $args[0]) {

View File

@@ -263,9 +263,7 @@ final class PersonContextTest extends TestCase
if (null === $translatableStringHelper) {
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
// return only the 'fr' key
$translatableStringHelper->localize(Argument::type('array'))->will(static function ($args) {
return $args[0]['fr'];
});
$translatableStringHelper->localize(Argument::type('array'))->will(static fn($args) => $args[0]['fr']);
$translatableStringHelper = $translatableStringHelper->reveal();
}

View File

@@ -70,9 +70,7 @@ final class PersonContextWithThirdPartyTest extends KernelTestCase
{
$normalizer = $this->prophesize(NormalizerInterface::class);
$normalizer->normalize(Argument::type(ThirdParty::class), 'docgen', Argument::type('array'))
->will(static function ($args): array {
return ['class' => '3party', 'hash' => spl_object_hash($args[0])];
});
->will(static fn($args): array => ['class' => '3party', 'hash' => spl_object_hash($args[0])]);
$personContext = $this->prophesize(PersonContextInterface::class);

View File

@@ -74,9 +74,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
$periodIssuesWithAncestors = array_merge(
$periodIssuesWithAncestors,
array_map(
static function (SocialIssue $si) {
return spl_object_hash($si);
},
static fn(SocialIssue $si) => spl_object_hash($si),
$si->getAncestors(true)
)
);