phpstan, rector, phpcs fixes

This commit is contained in:
Julie Lenaerts 2025-05-08 10:59:54 +02:00
parent 3d6ffea58e
commit 70b104d41e
17 changed files with 51 additions and 54 deletions

View File

@ -23,11 +23,11 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Form\Type\PickPersonDynamicType; use Chill\PersonBundle\Form\Type\PickPersonDynamicType;
use Chill\PersonBundle\Privacy\PrivacyEvent; use Chill\PersonBundle\Privacy\PrivacyEvent;
use Doctrine\Persistence\ManagerRegistry;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Csv; use PhpOffice\PhpSpreadsheet\Writer\Csv;
use PhpOffice\PhpSpreadsheet\Writer\Ods; use PhpOffice\PhpSpreadsheet\Writer\Ods;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -41,8 +41,10 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
/** /**
* Class EventController. * Class EventController.
@ -59,9 +61,8 @@ final class EventController extends AbstractController
private readonly TranslatorInterface $translator, private readonly TranslatorInterface $translator,
private readonly PaginatorFactory $paginator, private readonly PaginatorFactory $paginator,
private readonly Security $security, private readonly Security $security,
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, private readonly ManagerRegistry $managerRegistry,
private readonly SerializerInterface $serializer, private readonly SerializerInterface $serializer,
) {} ) {}
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/{event_id}/delete', name: 'chill_event__event_delete', requirements: ['event_id' => '\d+'], methods: ['GET', 'POST', 'DELETE'])] #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/{event_id}/delete', name: 'chill_event__event_delete', requirements: ['event_id' => '\d+'], methods: ['GET', 'POST', 'DELETE'])]
@ -172,6 +173,8 @@ final class EventController extends AbstractController
/** /**
* Displays a form to create a new Event entity. * Displays a form to create a new Event entity.
*
* @throws ExceptionInterface
*/ */
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/new', name: 'chill_event__event_new', methods: ['GET', 'POST'])] #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/new', name: 'chill_event__event_new', methods: ['GET', 'POST'])]
public function newAction(?Center $center, Request $request): Response public function newAction(?Center $center, Request $request): Response

View File

@ -200,7 +200,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter
$this->animators->removeElement($tp); $this->animators->removeElement($tp);
} }
public function getCenter(): ?Center public function getCenter(): Center
{ {
return $this->center; return $this->center;
} }

View File

@ -52,6 +52,7 @@ class EventBudgetElement
{ {
$this->id = $id; $this->id = $id;
} }
public function getAmount(): float public function getAmount(): float
{ {
return (float) $this->amount; return (float) $this->amount;

View File

@ -80,24 +80,14 @@ class EventTheme
return $this->name; return $this->name;
} }
/** public function setIsActive(bool $active): self
* Set active.
*
* @return EventTheme
*/
public function setIsActive(bool $active): static
{ {
$this->isActive = $active; $this->isActive = $active;
return $this; return $this;
} }
/** public function setName(array $label): self
* Set label.
*
* @return EventTheme
*/
public function setName(array $label): static
{ {
$this->name = $label; $this->name = $label;
@ -130,23 +120,9 @@ class EventTheme
return $this->children; return $this->children;
} }
public function getDescendants(): Collection public function hasChildren(): bool
{ {
$descendants = new ArrayCollection(); return 0 < $this->getChildren()->count();
foreach ($this->getChildren() as $child) {
if (!$descendants->contains($child)) {
$descendants->add($child);
foreach ($child->getDescendants() as $descendantsOfChild) {
if (!$descendants->contains($descendantsOfChild)) {
$descendants->add($descendantsOfChild);
}
}
}
}
return $descendants;
} }
public function hasParent(): bool public function hasParent(): bool

View File

@ -108,7 +108,7 @@ class ListEvents implements ListInterface, GroupedExportInterface
return 'Exports of events'; return 'Exports of events';
} }
public function getLabels($key, array $values, $data): \Closure public function getLabels($key, array $values, $data)
{ {
return match ($key) { return match ($key) {
'event_id' => fn ($value) => '_header' === $value ? 'export.event.list.'.$key : $value, 'event_id' => fn ($value) => '_header' === $value ? 'export.event.list.'.$key : $value,
@ -258,21 +258,21 @@ class ListEvents implements ListInterface, GroupedExportInterface
break; break;
case 'event_type': case 'event_type':
if (!$qb->getDQLPart('join') || !$this->hasJoin($qb, 'event.type')) { if (!$this->hasJoin($qb, 'event.type')) {
$qb->leftJoin('event.type', 'type'); $qb->leftJoin('event.type', 'type');
} }
$qb->addSelect('type.name AS event_type'); $qb->addSelect('type.name AS event_type');
break; break;
case 'event_center': case 'event_center':
if (!$qb->getDQLPart('join') || !$this->hasJoin($qb, 'event.center')) { if (!$this->hasJoin($qb, 'event.center')) {
$qb->leftJoin('event.center', 'center'); $qb->leftJoin('event.center', 'center');
} }
$qb->addSelect('center.name AS event_center'); $qb->addSelect('center.name AS event_center');
break; break;
case 'event_moderator': case 'event_moderator':
if (!$qb->getDQLPart('join') || !$this->hasJoin($qb, 'event.moderator')) { if (!$this->hasJoin($qb, 'event.moderator')) {
$qb->leftJoin('event.moderator', 'user'); $qb->leftJoin('event.moderator', 'user');
} }
$qb->addSelect('user.username AS event_moderator'); $qb->addSelect('user.username AS event_moderator');
@ -283,7 +283,7 @@ class ListEvents implements ListInterface, GroupedExportInterface
break; break;
case 'event_location': case 'event_location':
if (!$qb->getDQLPart('join') || !$this->hasJoin($qb, 'event.location')) { if (!$this->hasJoin($qb, 'event.location')) {
$qb->leftJoin('event.location', 'location'); $qb->leftJoin('event.location', 'location');
} }
$qb->addSelect('location.name AS event_location'); $qb->addSelect('location.name AS event_location');

View File

@ -25,7 +25,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class AddEventBudgetElementType extends AbstractType class AddEventBudgetElementType extends AbstractType
{ {
public function __construct(private EventBudgetKindRepository $kindRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) {} public function __construct(private readonly EventBudgetKindRepository $kindRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {

View File

@ -12,11 +12,11 @@ declare(strict_types=1);
namespace Chill\EventBundle\Form; namespace Chill\EventBundle\Form;
use Chill\EventBundle\Entity\BudgetTypeEnum; use Chill\EventBundle\Entity\BudgetTypeEnum;
use Chill\EventBundle\Entity\EventBudgetKind;
use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EnumType; use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
@ -48,6 +48,6 @@ class EventBudgetKindType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver $resolver
->setDefault('class', ChargeKind::class); ->setDefault('class', EventBudgetKind::class);
} }
} }

View File

@ -38,7 +38,7 @@ class EventThemeType extends AbstractType
'class' => EventTheme::class, 'class' => EventTheme::class,
'required' => false, 'required' => false,
'choice_label' => fn (EventTheme $theme): ?string => $this->translatableStringHelper->localize($theme->getName()), 'choice_label' => fn (EventTheme $theme): ?string => $this->translatableStringHelper->localize($theme->getName()),
'mapped' => 'create' === $options['step'], 'mapped' => 'create' == $options['step'],
]); ]);
} }

View File

@ -109,9 +109,6 @@ class EventType extends AbstractType
->setAllowedTypes('role', 'string'); ->setAllowedTypes('role', 'string');
} }
/**
* @return string
*/
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
// as the js shares some hardcoded items from the activity bundle, we have to rewrite block prefix // as the js shares some hardcoded items from the activity bundle, we have to rewrite block prefix

View File

@ -23,11 +23,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/ */
class PickEventTypeType extends AbstractType class PickEventTypeType extends AbstractType
{ {
protected TranslatableStringHelper $translatableStringHelper; public function __construct(protected TranslatableStringHelper $translatableStringHelper)
public function __construct(TranslatableStringHelper $helper)
{ {
$this->translatableStringHelper = $helper;
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)

View File

@ -17,11 +17,8 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
class AdminMenuBuilder implements LocalMenuBuilderInterface class AdminMenuBuilder implements LocalMenuBuilderInterface
{ {
protected AuthorizationCheckerInterface $authorizationChecker; public function __construct(protected AuthorizationCheckerInterface $authorizationChecker)
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
{ {
$this->authorizationChecker = $authorizationChecker;
} }
public function buildMenu($menuId, MenuItem $menu, array $parameters): void public function buildMenu($menuId, MenuItem $menu, array $parameters): void

View File

@ -24,5 +24,4 @@ class EventBudgetElementRepository extends ServiceEntityRepository
{ {
parent::__construct($registry, EventBudgetElement::class); parent::__construct($registry, EventBudgetElement::class);
} }
} }

View File

@ -34,5 +34,4 @@ class EventThemeRepository extends ServiceEntityRepository
->getQuery() ->getQuery()
->getResult(); ->getResult();
} }
} }

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\Event; namespace Chill\Migrations\Event;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;

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\Event; namespace Chill\Migrations\Event;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;

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\Event; namespace Chill\Migrations\Event;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;

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\Event; namespace Chill\Migrations\Event;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;