php cs fixes

This commit is contained in:
Julie Lenaerts 2024-10-08 16:49:54 +02:00
parent 2da6b746fb
commit 59f9ac25ba
15 changed files with 101 additions and 42 deletions

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Controller; namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController; use Chill\MainBundle\CRUD\Controller\ApiController;

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Controller; namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController; use Chill\MainBundle\CRUD\Controller\CRUDController;

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Entity; namespace Chill\MainBundle\Entity;
use Chill\MainBundle\Repository\GenderRepository; use Chill\MainBundle\Repository\GenderRepository;

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Entity; namespace Chill\MainBundle\Entity;
enum GenderEnum: string enum GenderEnum: string

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Entity; namespace Chill\MainBundle\Entity;
enum GenderIconEnum: string enum GenderIconEnum: string

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Form; namespace Chill\MainBundle\Form;
use Chill\MainBundle\Entity\Gender; use Chill\MainBundle\Entity\Gender;
@ -10,7 +19,6 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EnumType; use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@ -22,12 +30,6 @@ class GenderType extends AbstractType
->add('label', TranslatableStringFormType::class, [ ->add('label', TranslatableStringFormType::class, [
'required' => true, 'required' => true,
]) ])
/* ->add('icon', EnumType::class, [
'class' => GenderIconEnum::class,
'label_html' => true,
'expanded' => false,
'mapped' => true,
])*/
->add('icon', ChoiceType::class, [ ->add('icon', ChoiceType::class, [
'choices' => GenderIconEnum::cases(), 'choices' => GenderIconEnum::cases(),
'expanded' => true, 'expanded' => true,
@ -40,6 +42,7 @@ class GenderType extends AbstractType
]) ])
->add('genderTranslation', EnumType::class, [ ->add('genderTranslation', EnumType::class, [
'class' => GenderEnum::class, 'class' => GenderEnum::class,
'choice_label' => fn (GenderEnum $enum) => $enum->value,
'label' => 'gender.admin.Select Gender Translation', 'label' => 'gender.admin.Select Gender Translation',
]) ])
->add('active', ChoiceType::class, [ ->add('active', ChoiceType::class, [

View File

@ -1,15 +1,22 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Repository; namespace Chill\MainBundle\Repository;
use Chill\MainBundle\Entity\Gender; use Chill\MainBundle\Entity\Gender;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\ObjectRepository;
use UnexpectedValueException;
class GenderRepository extends ServiceEntityRepository { class GenderRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry) public function __construct(ManagerRegistry $registry)
{ {
parent::__construct($registry, Gender::class); parent::__construct($registry, Gender::class);

View File

@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Chill\MainBundle\Templating\Entity; namespace Chill\MainBundle\Templating\Entity;
use Chill\MainBundle\Entity\GenderIconEnum; use Chill\MainBundle\Entity\GenderIconEnum;
use Chill\MainBundle\Entity\NewsItem;
/** /**
* @implements ChillEntityRenderInterface<GenderIconEnum> * @implements ChillEntityRenderInterface<GenderIconEnum>
@ -21,8 +20,7 @@ final readonly class ChillGenderIconRender implements ChillEntityRenderInterface
{ {
public function renderBox($icon, array $options): string public function renderBox($icon, array $options): string
{ {
return return '<i class="'.$icon->value.'"></i>';
'<i class="'. $icon->value .'"></i>';
} }
public function renderString($icon, array $options): string public function renderString($icon, array $options): string

View File

@ -2,6 +2,13 @@
declare(strict_types=1); declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\Migrations\Main; namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;

View File

@ -15,6 +15,7 @@ use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Country; use Chill\MainBundle\Entity\Country;
use Chill\MainBundle\Entity\GenderEnum;
use Chill\MainBundle\Entity\PostalCode; use Chill\MainBundle\Entity\PostalCode;
use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
@ -81,7 +82,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
protected NativeLoader $loader; protected NativeLoader $loader;
private array $genders = [Person::MALE_GENDER, Person::FEMALE_GENDER, Person::BOTH_GENDER]; private array $genders = [GenderEnum::MALE, GenderEnum::FEMALE, GenderEnum::NEUTRAL];
private array $peoples = [ private array $peoples = [
[ [
@ -90,7 +91,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
'birthdate' => '1948-12-27', 'birthdate' => '1948-12-27',
'placeOfBirth' => 'Châteauroux', 'placeOfBirth' => 'Châteauroux',
'nationality' => 'RU', 'nationality' => 'RU',
'gender' => Person::MALE_GENDER, 'gender' => GenderEnum::MALE,
'center' => 'Center A', 'center' => 'Center A',
'accompanyingPeriods' => [ 'accompanyingPeriods' => [
[ [
@ -131,7 +132,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
'lastName' => 'Depardieu', 'lastName' => 'Depardieu',
'firstName' => 'Charline', 'firstName' => 'Charline',
'birthdate' => '1970-10-15', 'birthdate' => '1970-10-15',
'gender' => Person::FEMALE_GENDER, 'gender' => GenderEnum::FEMALE,
'center' => 'Center A', 'center' => 'Center A',
'maritalStatus' => 'ms_legalco', 'maritalStatus' => 'ms_legalco',
], ],

View File

@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators;
use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Repository\GenderRepository; use Chill\MainBundle\Repository\GenderRepository;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;

View File

@ -12,17 +12,13 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\PersonFilters; namespace Chill\PersonBundle\Export\Filter\PersonFilters;
use Chill\MainBundle\Entity\Gender; use Chill\MainBundle\Entity\Gender;
use Chill\MainBundle\Entity\GenderEnum;
use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Export\ExportElementValidatedInterface;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
@ -31,9 +27,7 @@ class GenderFilter implements
ExportElementValidatedInterface, ExportElementValidatedInterface,
FilterInterface FilterInterface
{ {
public function __construct(private TranslatorInterface $translator, private TranslatableStringHelperInterface $translatableStringHelper) public function __construct(private TranslatorInterface $translator, private TranslatableStringHelperInterface $translatableStringHelper) {}
{
}
public function addRole(): ?string public function addRole(): ?string
{ {
@ -92,7 +86,7 @@ class GenderFilter implements
if ('null' === $g) { if ('null' === $g) {
$genders[] = $this->translator->trans('Not given'); $genders[] = $this->translator->trans('Not given');
} else { } else {
$genders[] = $this->translatableStringHelper($g->getLabel()); $genders[] = $this->translatableStringHelper->localize($g->getLabel());
} }
} }

View File

@ -13,12 +13,10 @@ namespace Chill\PersonBundle\Form\Type;
use Chill\MainBundle\Entity\Gender; use Chill\MainBundle\Entity\Gender;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
/** /**

View File

@ -2,6 +2,13 @@
declare(strict_types=1); declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\Migrations\Person; namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;