From 4a08de09b89090c304a1fe1ac7e0e301c51ec5fc Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 2 Oct 2025 16:19:16 +0200 Subject: [PATCH] Rector php82 changes --- rector.php | 10 +++++----- src/Bundle/ChillActivityBundle/Entity/ActivityType.php | 2 +- .../ChillEventBundle/Form/EventBudgetKindType.php | 4 ++-- .../ChillEventBundle/Form/Type/PickEventThemeType.php | 2 +- .../ChillMainBundle/Command/SetPasswordCommand.php | 2 +- .../ChillMainBundle/DataFixtures/ORM/LoadCountries.php | 2 +- .../ChillMainBundle/DataFixtures/ORM/LoadLanguages.php | 2 +- .../ChillMainBundle/DataFixtures/ORM/LoadUsers.php | 5 +---- .../Doctrine/Event/TrackCreateUpdateSubscriber.php | 5 +---- src/Bundle/ChillMainBundle/Tests/Entity/UserTest.php | 2 +- .../Tests/Serializer/Normalizer/UserNormalizerTest.php | 2 +- .../ChillPersonBundle/Actions/Remove/PersonMove.php | 4 ++-- .../AccompanyingPeriodWorkDuplicateController.php | 2 +- .../Controller/PersonEditController.php | 2 +- .../Repository/Household/HouseholdRepository.php | 4 ++-- ...gPeriodSocialIssueConsistencyEntityListenerTest.php | 8 ++++---- .../Controller/ThirdpartyDuplicateController.php | 4 ++-- .../Form/ThirdpartyFindDuplicateType.php | 4 ++-- 18 files changed, 30 insertions(+), 36 deletions(-) diff --git a/rector.php b/rector.php index c972ac2d8..7b5c3d460 100644 --- a/rector.php +++ b/rector.php @@ -51,7 +51,7 @@ return static function (RectorConfig $rectorConfig): void { // define sets of rules $rectorConfig->sets([ -// LevelSetList::UP_TO_PHP_82, + LevelSetList::UP_TO_PHP_82, // SymfonySetList::SYMFONY_60, // SymfonySetList::SYMFONY_61, // SymfonySetList::SYMFONY_62, @@ -59,10 +59,10 @@ return static function (RectorConfig $rectorConfig): void { // SymfonySetList::SYMFONY_64, // SymfonySetList::SYMFONY_70, // SymfonySetList::SYMFONY_71, - Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_ORM_29, - Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_DBAL_30, - Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_CODE_QUALITY, - Rector\Doctrine\Set\DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, +// Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_ORM_29, +// Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_DBAL_30, +// Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_CODE_QUALITY, +// Rector\Doctrine\Set\DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, ]); $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [ diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index a03096cb4..752629c16 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -462,7 +462,7 @@ class ActivityType $property = $field.'Visible'; // Get the real class name (not the proxy) - $class = get_class($this); + $class = static::class; if (str_contains($class, '__CG__')) { $class = get_parent_class($this); } diff --git a/src/Bundle/ChillEventBundle/Form/EventBudgetKindType.php b/src/Bundle/ChillEventBundle/Form/EventBudgetKindType.php index 571c4f942..6f1a0d9b8 100644 --- a/src/Bundle/ChillEventBundle/Form/EventBudgetKindType.php +++ b/src/Bundle/ChillEventBundle/Form/EventBudgetKindType.php @@ -25,7 +25,7 @@ class EventBudgetKindType extends AbstractType { public function __construct(private readonly TranslatorInterface $translator) {} - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('name', TranslatableStringFormType::class, [ @@ -45,7 +45,7 @@ class EventBudgetKindType extends AbstractType ]); } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver ->setDefault('class', EventBudgetKind::class); diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventThemeType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventThemeType.php index 3010df271..28de33a27 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventThemeType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventThemeType.php @@ -22,7 +22,7 @@ class PickEventThemeType extends AbstractType { public function __construct(private readonly EventThemeRender $eventThemeRender, private readonly EventThemeRepository $eventThemeRepository) {} - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver ->setDefaults([ diff --git a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php index 21a5a1623..99d0e912b 100644 --- a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php +++ b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php @@ -52,7 +52,7 @@ class SetPasswordCommand extends Command $user->setPassword( $encoderFactory->getEncoder($user)->encodePassword($password, $user->getSalt()) ); - $this->entityManager->flush($user); + $this->entityManager->flush(); } public function configure(): void diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadCountries.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadCountries.php index bbf79c55d..13c7da10c 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadCountries.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadCountries.php @@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; */ class LoadCountries extends Fixture implements OrderedFixtureInterface { - private array $availableLanguages; + private readonly array $availableLanguages; public function __construct(private readonly ParameterBagInterface $parameterBag) { diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php index 5182843d3..25f640494 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php @@ -30,7 +30,7 @@ class LoadLanguages extends Fixture implements OrderedFixtureInterface // This array contains regional code to not exclude private array $regionalVersionToInclude = ['ro_MD']; - private array $availableLanguages; + private readonly array $availableLanguages; public function __construct(private readonly ParameterBagInterface $parameterBag) { diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php index 70de02aa3..265d03478 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php @@ -54,11 +54,8 @@ class LoadUsers extends Fixture implements OrderedFixtureInterface ], ]; - private UserPasswordHasherInterface $passwordHasher; - - public function __construct(UserPasswordHasherInterface $passwordHasher) + public function __construct(private readonly UserPasswordHasherInterface $passwordHasher) { - $this->passwordHasher = $passwordHasher; } public function getOrder(): int diff --git a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php index 366e7941e..a3d9a6f90 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php @@ -22,11 +22,8 @@ use Symfony\Bundle\SecurityBundle\Security; class TrackCreateUpdateSubscriber implements EventSubscriber { - private Security $security; - - public function __construct(Security $security) + public function __construct(private readonly Security $security) { - $this->security = $security; } public function getSubscribedEvents(): array diff --git a/src/Bundle/ChillMainBundle/Tests/Entity/UserTest.php b/src/Bundle/ChillMainBundle/Tests/Entity/UserTest.php index b2838842e..68c97e6c6 100644 --- a/src/Bundle/ChillMainBundle/Tests/Entity/UserTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Entity/UserTest.php @@ -68,7 +68,7 @@ class UserTest extends TestCase ); } - public function testIsAbsent() + public function testIsAbsent(): void { $user = new User(); diff --git a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php index 7e864c829..6cbfd5a3b 100644 --- a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php @@ -57,7 +57,7 @@ final class UserNormalizerTest extends TestCase return ['context' => $context['docgen:expects'] ?? null]; } - public function supportsNormalization($data, ?string $format = null): bool + public function supportsNormalization($data, ?string $format = null, array $context = []): bool { return true; } diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php index 603825d35..25b48199c 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php @@ -113,11 +113,11 @@ class PersonMove $conditions = []; - if (array_key_exists('joinTable', $mapping)) { + if (property_exists($mapping, 'joinTable')) { foreach ($mapping['joinTable']['joinColumns'] as $columns) { $conditions[] = sprintf('%s = %d', $columns['referencedColumnName'], $from->getId()); } - } elseif (array_key_exists('joinColumns', $mapping)) { + } elseif (property_exists($mapping, 'joinColumns')) { foreach ($mapping['joinColumns'] as $columns) { $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php index eb4b67163..cdde94867 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php @@ -79,7 +79,7 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController * @ParamConverter("acpw2", options={"id": "acpw2_id"}) */ #[Route(path: '/{_locale}/person/{acpw1_id}/acpw-duplicate/{acpw2_id}/confirm', name: 'chill_person_acpw_duplicate_confirm')] - public function confirmAction(AccompanyingPeriodWork $acpw1, AccompanyingPeriodWork $acpw2, Request $request) + public function confirmAction(AccompanyingPeriodWork $acpw1, AccompanyingPeriodWork $acpw2, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response { $accompanyingPeriod = $acpw1->getAccompanyingPeriod(); diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonEditController.php b/src/Bundle/ChillPersonBundle/Controller/PersonEditController.php index bf62c285a..26f64cfd6 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonEditController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonEditController.php @@ -44,7 +44,7 @@ final readonly class PersonEditController * @ParamConverter("person", options={"id": "person_id"}) */ #[Route(path: '/{_locale}/person/{person_id}/general/edit', name: 'chill_person_general_edit')] - public function editAction(Person $person, Request $request, Session $session) + public function editAction(Person $person, Request $request, Session $session): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response { if (!$this->security->isGranted(PersonVoter::UPDATE, $person)) { throw new AccessDeniedHttpException('You are not allowed to edit this person.'); diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php index 4c6a59c54..de46e5c0a 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php @@ -50,7 +50,7 @@ final readonly class HouseholdRepository implements ObjectRepository $this->em = $entityManager; } - public function countByAccompanyingPeriodParticipation(Person $person) + public function countByAccompanyingPeriodParticipation(Person $person): mixed { return $this->buildQueryByAccompanyingPeriodParticipation($person, true); } @@ -70,7 +70,7 @@ final readonly class HouseholdRepository implements ObjectRepository return $this->repository->findBy($criteria, $orderBy, $limit, $offset); } - public function findByAccompanyingPeriodParticipation(Person $person, int $limit, int $offset) + public function findByAccompanyingPeriodParticipation(Person $person, int $limit, int $offset): mixed { return $this->buildQueryByAccompanyingPeriodParticipation($person, false, $limit, $offset); } diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php index e09516410..12adb2826 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php @@ -44,7 +44,7 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListenerTest extends T $entity = $this->generateClass($period, $socialIssues); $consistency = new AccompanyingPeriodSocialIssueConsistencyEntityListener(); - $consistency->prePersist($entity, $this->generateLifecycleArgs($period, Step::PrePersist)); + $consistency->prePersist($entity); $this->assertCount(2, $period->getSocialIssues()); $this->assertContains($grandGrandChild, $period->getSocialIssues()); @@ -69,7 +69,7 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListenerTest extends T $period->addSocialIssue($issue); } - $consistency->prePersistAccompanyingPeriod($period, $this->generateLifecycleArgs($period, Step::PrePersist)); + $consistency->prePersistAccompanyingPeriod($period); $this->assertCount(1, $period->getSocialIssues()); $this->assertSame($grandGrandChild, $period->getSocialIssues()->first()); @@ -87,7 +87,7 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListenerTest extends T $entity = $this->generateClass($period, $socialIssues); $consistency = new AccompanyingPeriodSocialIssueConsistencyEntityListener(); - $consistency->preUpdate($entity, $this->generateLifecycleArgs($period, Step::PreUpdate)); + $consistency->preUpdate($entity); $this->assertCount(2, $period->getSocialIssues()); $this->assertContains($grandGrandChild, $period->getSocialIssues()); @@ -112,7 +112,7 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListenerTest extends T $period->addSocialIssue($issue); } - $consistency->prePersistAccompanyingPeriod($period, $this->generateLifecycleArgs($period, Step::PrePersist)); + $consistency->prePersistAccompanyingPeriod($period); $this->assertCount(1, $period->getSocialIssues()); $this->assertSame($grandGrandChild, $period->getSocialIssues()->first()); diff --git a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdpartyDuplicateController.php b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdpartyDuplicateController.php index 6057f86fc..38dc4e0db 100644 --- a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdpartyDuplicateController.php +++ b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdpartyDuplicateController.php @@ -31,7 +31,7 @@ class ThirdpartyDuplicateController extends AbstractController * @ParamConverter("thirdparty", options={"id": "thirdparty_id"}) */ #[Route(path: '/{_locale}/3party/{thirdparty_id}/find-manually', name: 'chill_thirdparty_find_duplicate')] - public function findManuallyDuplicateAction(ThirdParty $thirdparty, Request $request) + public function findManuallyDuplicateAction(ThirdParty $thirdparty, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response { $suggested = []; @@ -74,7 +74,7 @@ class ThirdpartyDuplicateController extends AbstractController * @ParamConverter("thirdparty2", options={"id": "thirdparty2_id"}) */ #[Route(path: '/{_locale}/3party/{thirdparty1_id}/duplicate/{thirdparty2_id}/confirm', name: 'chill_thirdparty_duplicate_confirm')] - public function confirmAction(ThirdParty $thirdparty1, ThirdParty $thirdparty2, Request $request) + public function confirmAction(ThirdParty $thirdparty1, ThirdParty $thirdparty2, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response { try { $this->validateThirdpartyMerge($thirdparty1, $thirdparty2); diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdpartyFindDuplicateType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdpartyFindDuplicateType.php index 275b6d21c..6168fe9e5 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdpartyFindDuplicateType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdpartyFindDuplicateType.php @@ -19,7 +19,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class ThirdpartyFindDuplicateType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('thirdparty', PickThirdpartyDynamicType::class, [ @@ -32,7 +32,7 @@ class ThirdpartyFindDuplicateType extends AbstractType ]); } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'suggested' => [],