Php cs fixes and phpstan

This commit is contained in:
2024-10-22 15:56:41 +02:00
parent 73b0dd6009
commit f1844ae02b
5 changed files with 26 additions and 12 deletions

View File

@@ -30,8 +30,11 @@ class GenderFilter implements
DataTransformerInterface
{
// inject gender repository and find the active genders so that you can pass them to the ChoiceType (ordered by ordering)
public function __construct(private readonly TranslatorInterface $translator, private readonly TranslatableStringHelperInterface $translatableStringHelper,
private readonly GenderRepository $genderRepository) {}
public function __construct(
private readonly TranslatorInterface $translator,
private readonly TranslatableStringHelperInterface $translatableStringHelper,
private readonly GenderRepository $genderRepository
) {}
public function addRole(): ?string
{
@@ -44,7 +47,7 @@ class GenderFilter implements
$isIn = $qb->expr()->in('person.gender', ':person_gender');
$acceptedGenders = $data['accepted_genders_entity'];
$nullIncluded = in_array(null, $acceptedGenders, true);
$nullIncluded = in_array(null, $acceptedGenders ?? [], true);
if (!$nullIncluded) {
$clause = $isIn;
@@ -53,7 +56,7 @@ class GenderFilter implements
}
$qb->andWhere($clause);
$qb->setParameter('person_gender', array_filter($acceptedGenders, fn ($gender) => null !== $gender));
$qb->setParameter('person_gender', array_filter($acceptedGenders ?? [], fn ($gender) => null !== $gender));
}
public function applyOn()
@@ -80,6 +83,7 @@ class GenderFilter implements
public function transformData(?array $before): array
{
$transformedData = [];
$transformedData['accepted_genders_entity'] = $before['accepted_genders_entity'] ?? [];
if (array_key_exists('accepted_genders', $before)) {