From 1fa8f88a6d36d83a65239537babfefc597806c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Mon, 4 May 2026 17:20:01 +0200 Subject: [PATCH] chore: code cleanup with rector and php-cs-fixer --- .../ParticipantServiceProcessor.php | 3 +- src/BusProNet/XmlParser/BookingParser.php | 1 - src/Command/BpnXmlSyncCommand.php | 5 ++- .../MailjetNewsletterWebhookCommand.php | 4 +-- .../Account/PersonalDataController.php | 34 +++++++++---------- .../Api/NewsletterSubscriptionController.php | 2 +- .../Booking/Create/Step1Controller.php | 2 +- .../Booking/Create/Step2Controller.php | 2 +- .../Create/Step2ParticipantController.php | 2 +- .../Booking/Create/Step3Controller.php | 2 +- .../Booking/Create/Step4Controller.php | 2 +- .../Booking/Edit/IndexController.php | 2 +- .../Booking/Edit/ParticipantController.php | 2 +- src/Controller/RegistrationController.php | 2 +- src/Controller/ResetPasswordController.php | 2 +- .../MailjetNewsletterWebhookController.php | 1 + src/Form/Model/BookingSummaryDto.php | 8 ++--- .../Condition/RentalSelectionCondition.php | 1 - .../ParticipantAssignedRoomFieldHandler.php | 3 +- .../NewsletterSubscriptionRequestResult.php | 2 +- src/Repository/BookingEditDraftRepository.php | 8 +++-- .../NewsletterOptInRequestRepository.php | 14 +++++--- src/Repository/TravelSnapshotRepository.php | 14 +++++--- src/Service/BookingConfigurator.php | 2 +- src/Service/BookingEditDraftMerger.php | 3 +- src/Service/BookingEditSubmitter.php | 4 ++- src/Service/BookingExporter.php | 16 +++++---- src/Service/BpnXmlSnapshotRefreshManager.php | 2 +- src/Service/NewsletterManager.php | 4 +-- src/Service/ParticipantPricingCalculator.php | 1 - src/Twig/ErrorCodeExtension.php | 4 +-- .../Service/BookingStatusRuleRegistryTest.php | 5 +-- .../Account/PersonalDataControllerTest.php | 1 - tests/Form/Model/ParticipantEditDtoTest.php | 29 +++++++++------- .../NewsletterSubscriptionRequestTest.php | 3 +- .../Service/BookingConfiguratorStatusTest.php | 8 +++-- tests/Service/BookingEditSubmitterTest.php | 17 +++++----- .../Service/ParticipantCardAssemblerTest.php | 11 +++--- 38 files changed, 130 insertions(+), 98 deletions(-) diff --git a/src/BusProNet/DataProcessor/ParticipantServiceProcessor.php b/src/BusProNet/DataProcessor/ParticipantServiceProcessor.php index 0f4cd44..9c2a6de 100644 --- a/src/BusProNet/DataProcessor/ParticipantServiceProcessor.php +++ b/src/BusProNet/DataProcessor/ParticipantServiceProcessor.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\BusProNet\DataProcessor; use App\BusProNet\Model\Booking; +use App\BusProNet\Model\Service; use App\BusProNet\Model\Travel; use App\Form\Model\ParticipantDto; use Psr\Log\LoggerInterface; @@ -120,7 +121,7 @@ class ParticipantServiceProcessor * * @param ParticipantDto $participant The participant data * - * @return array<\App\BusProNet\Model\Service> Array of services selected by this participant + * @return array Array of services selected by this participant */ private function collectParticipantAdditionalServices(ParticipantDto $participant): array { diff --git a/src/BusProNet/XmlParser/BookingParser.php b/src/BusProNet/XmlParser/BookingParser.php index 46da375..39aabca 100644 --- a/src/BusProNet/XmlParser/BookingParser.php +++ b/src/BusProNet/XmlParser/BookingParser.php @@ -6,7 +6,6 @@ use App\BusProNet\Constants; use App\BusProNet\Model\Address; use App\BusProNet\Model\BankAccount; use App\BusProNet\Model\Booking; -use App\BusProNet\Model\Communication; use App\BusProNet\Model\PersonalData; use Symfony\Component\DomCrawler\Crawler; diff --git a/src/Command/BpnXmlSyncCommand.php b/src/Command/BpnXmlSyncCommand.php index a190d6a..b7eca34 100644 --- a/src/Command/BpnXmlSyncCommand.php +++ b/src/Command/BpnXmlSyncCommand.php @@ -7,8 +7,8 @@ namespace App\Command; use App\BusProNet\Model\XmlExportInfo; use App\Model\BpnXmlSnapshotRefreshResult; use App\Model\BpnXmlSyncTarget; -use App\Service\BpnXmlSyncManager; use App\Service\BpnXmlSnapshotRefreshManager; +use App\Service\BpnXmlSyncManager; use League\Flysystem\FilesystemException; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Attribute\AsCommand; @@ -183,8 +183,7 @@ class BpnXmlSyncCommand extends Command bool $dryRun, SymfonyStyle $io, OutputInterface $output, - ): array - { + ): array { $datasetName = $target->name; $remoteInfo = $this->syncManager->readRemoteInfo($target->source, $datasetName); diff --git a/src/Command/MailjetNewsletterWebhookCommand.php b/src/Command/MailjetNewsletterWebhookCommand.php index 7fb770d..eec787b 100644 --- a/src/Command/MailjetNewsletterWebhookCommand.php +++ b/src/Command/MailjetNewsletterWebhookCommand.php @@ -32,9 +32,9 @@ final class MailjetNewsletterWebhookCommand extends Command public function __construct( private readonly MailjetApiClient $mailjetApiClient, - #[Autowire('%env(APP_BASE_URL)%')] + #[Autowire(env: 'APP_BASE_URL')] private readonly string $defaultBaseUrl, - #[Autowire('%env(MAILJET_WEBHOOK_BASIC_PASSWORD)%')] + #[Autowire(env: 'MAILJET_WEBHOOK_BASIC_PASSWORD')] private readonly string $basicAuthPassword, private readonly LoggerInterface $logger, ) { diff --git a/src/Controller/Account/PersonalDataController.php b/src/Controller/Account/PersonalDataController.php index d0cbaea..841b328 100644 --- a/src/Controller/Account/PersonalDataController.php +++ b/src/Controller/Account/PersonalDataController.php @@ -10,12 +10,12 @@ use App\BusProNet\Model\Notification; use App\BusProNet\Model\PersonalData; use App\Entity\User; use App\Exception\NewsletterProviderException; -use App\Htmx\HxTrait; use App\Form\PersonalDataType; +use App\Htmx\HxTrait; use App\Model\NewsletterSubscriptionRequestResult; -use App\Service\NewsletterManager; use App\Security\Crypt; use App\Service\BookingEditDataLoader; +use App\Service\NewsletterManager; use App\Service\ProfileCompletenessChecker; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; @@ -39,24 +39,23 @@ class PersonalDataController extends AbstractController public const SESSION_REDIRECT_KEY = '_profile_completion_redirect'; /** - * @param ApiClient $apiClient BusProNet API client for data operations - * @param Crypt $crypt Encryption service for password handling - * @param BookingEditDataLoader $dataLoader Data loader for cache invalidation + * @param ApiClient $apiClient BusProNet API client for data operations + * @param Crypt $crypt Encryption service for password handling + * @param BookingEditDataLoader $dataLoader Data loader for cache invalidation * @param ProfileCompletenessChecker $completenessChecker Profile validation service - * @param EntityManagerInterface $entityManager Entity manager for persisting user changes - * @param NewsletterManager $newsletterManager Newsletter confirmation service - * @param LoggerInterface $logger Logger for audit trails and debugging + * @param EntityManagerInterface $entityManager Entity manager for persisting user changes + * @param NewsletterManager $newsletterManager Newsletter confirmation service + * @param LoggerInterface $logger Logger for audit trails and debugging */ public function __construct( - private readonly ApiClient $apiClient, - private readonly Crypt $crypt, - private readonly BookingEditDataLoader $dataLoader, + private readonly ApiClient $apiClient, + private readonly Crypt $crypt, + private readonly BookingEditDataLoader $dataLoader, private readonly ProfileCompletenessChecker $completenessChecker, - private readonly EntityManagerInterface $entityManager, - private readonly NewsletterManager $newsletterManager, - private readonly LoggerInterface $logger, - ) - { + private readonly EntityManagerInterface $entityManager, + private readonly NewsletterManager $newsletterManager, + private readonly LoggerInterface $logger, + ) { } /** @@ -125,7 +124,7 @@ class PersonalDataController extends AbstractController return $this->render('account/personal_data.html.twig', [ 'personalData' => $personalData, - 'personalDataForm' => $personalDataForm->createView(), + 'personalDataForm' => $personalDataForm, 'newsletterSubscribed' => $newsletterSubscribed, 'newsletterPendingConfirmation' => $newsletterPendingConfirmation, ]); @@ -149,7 +148,6 @@ class PersonalDataController extends AbstractController $result = $this->newsletterManager->requestDefaultListSubscription($email, $personalData->firstName, $personalData->name); $this->addFlash(...$this->newsletterRequestFlash($result)); } - } catch (NewsletterProviderException|\InvalidArgumentException $e) { $this->addFlash('error', 'Die Newsletter-Aktion konnte gerade nicht verarbeitet werden. Bitte versuche es erneut.'); $this->logger->warning('Newsletter action failed', [ diff --git a/src/Controller/Api/NewsletterSubscriptionController.php b/src/Controller/Api/NewsletterSubscriptionController.php index c0df923..3093ee5 100644 --- a/src/Controller/Api/NewsletterSubscriptionController.php +++ b/src/Controller/Api/NewsletterSubscriptionController.php @@ -32,7 +32,7 @@ class NewsletterSubscriptionController extends AbstractController } #[Route('/newsletters', name: 'api_newsletters_all', methods: ['GET'])] - public function index():JsonResponse + public function index(): JsonResponse { return $this->json($this->newsletterManager->createListIdMapping(array_keys($this->mailjetLists))); } diff --git a/src/Controller/Booking/Create/Step1Controller.php b/src/Controller/Booking/Create/Step1Controller.php index 421a329..939cd22 100644 --- a/src/Controller/Booking/Create/Step1Controller.php +++ b/src/Controller/Booking/Create/Step1Controller.php @@ -85,7 +85,7 @@ class Step1Controller extends AbstractBookingCreateController return $this->render('booking/create/step_1.html.twig', [ 'bookingCreateContext' => $context, - 'form' => $form->createView(), + 'form' => $form, ]); } diff --git a/src/Controller/Booking/Create/Step2Controller.php b/src/Controller/Booking/Create/Step2Controller.php index e4901de..e8bd42d 100644 --- a/src/Controller/Booking/Create/Step2Controller.php +++ b/src/Controller/Booking/Create/Step2Controller.php @@ -5,10 +5,10 @@ declare(strict_types=1); namespace App\Controller\Booking\Create; use App\BusProNet\Model\Travel; +use App\Entity\User; use App\Exception\BookingSessionNotFoundException; use App\Exception\HotelNotInTravelException; use App\Exception\TravelNotFoundException; -use App\Entity\User; use App\Form\BookingCreateStep2Type; use App\Form\Model\BookingDto; use App\Form\Model\ParticipantDto; diff --git a/src/Controller/Booking/Create/Step2ParticipantController.php b/src/Controller/Booking/Create/Step2ParticipantController.php index 10746fb..9a9e14c 100644 --- a/src/Controller/Booking/Create/Step2ParticipantController.php +++ b/src/Controller/Booking/Create/Step2ParticipantController.php @@ -136,7 +136,7 @@ class Step2ParticipantController extends AbstractController ); return $this->render('booking/create/step_2_participant.html.twig', [ - 'form' => $form->createView(), + 'form' => $form, 'participantIndex' => $index, 'bookingCreateContext' => $bookingCreateContext, 'bookingDto' => $bookingCreateContext->bookingDto, diff --git a/src/Controller/Booking/Create/Step3Controller.php b/src/Controller/Booking/Create/Step3Controller.php index 09f2881..1542fc3 100644 --- a/src/Controller/Booking/Create/Step3Controller.php +++ b/src/Controller/Booking/Create/Step3Controller.php @@ -228,7 +228,7 @@ class Step3Controller extends AbstractBookingCreateController return $this->render('booking/create/step_3.html.twig', [ 'bookingCreateContext' => $context, - 'form' => $form->createView(), + 'form' => $form, ]); } diff --git a/src/Controller/Booking/Create/Step4Controller.php b/src/Controller/Booking/Create/Step4Controller.php index 870cfcc..a3e0dec 100644 --- a/src/Controller/Booking/Create/Step4Controller.php +++ b/src/Controller/Booking/Create/Step4Controller.php @@ -182,7 +182,7 @@ class Step4Controller extends AbstractBookingCreateController return $this->render('booking/create/step_4.html.twig', [ 'bookingCreateContext' => $bookingCreateContext, - 'form' => $form->createView(), + 'form' => $form, 'newsletterOptInVisible' => $newsletterOptInVisible, 'newsletterTargetEmail' => $newsletterTargetEmail, ]); diff --git a/src/Controller/Booking/Edit/IndexController.php b/src/Controller/Booking/Edit/IndexController.php index 180d31d..b50dc48 100644 --- a/src/Controller/Booking/Edit/IndexController.php +++ b/src/Controller/Booking/Edit/IndexController.php @@ -9,8 +9,8 @@ use App\Entity\User; use App\Exception\TravelNotFoundException; use App\Form\BookingEditType; use App\Form\Model\BookingDto; -use App\Model\BookingEditSubmissionResult; use App\Htmx\HxTrait; +use App\Model\BookingEditSubmissionResult; use App\Service\BookingChangeTracker; use App\Service\BookingEditContextFactory; use App\Service\BookingEditDataLoader; diff --git a/src/Controller/Booking/Edit/ParticipantController.php b/src/Controller/Booking/Edit/ParticipantController.php index 588bb07..aef92b6 100644 --- a/src/Controller/Booking/Edit/ParticipantController.php +++ b/src/Controller/Booking/Edit/ParticipantController.php @@ -99,7 +99,7 @@ class ParticipantController extends AbstractController $context = $this->editContextFactory->createParticipantContext($bookingDto, $bookingData); return $this->render('booking/edit/participant.html.twig', [ - 'form' => $form->createView(), + 'form' => $form, 'participantIndex' => $index, 'bookingEditContext' => $context, 'bookingDto' => $context->bookingDto, diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index fa8b3c0..093f404 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -55,7 +55,7 @@ class RegistrationController extends AbstractController } return $this->render('registration/index.html.twig', [ - 'form' => $form->createView(), + 'form' => $form, ]); } } diff --git a/src/Controller/ResetPasswordController.php b/src/Controller/ResetPasswordController.php index 3d78e02..56c3fc4 100644 --- a/src/Controller/ResetPasswordController.php +++ b/src/Controller/ResetPasswordController.php @@ -63,7 +63,7 @@ class ResetPasswordController extends AbstractController } return $this->render('reset_password/index.html.twig', [ - 'form' => $form->createView(), + 'form' => $form, ]); } } diff --git a/src/Controller/Webhook/MailjetNewsletterWebhookController.php b/src/Controller/Webhook/MailjetNewsletterWebhookController.php index 93cecb0..8ea9243 100644 --- a/src/Controller/Webhook/MailjetNewsletterWebhookController.php +++ b/src/Controller/Webhook/MailjetNewsletterWebhookController.php @@ -55,6 +55,7 @@ final class MailjetNewsletterWebhookController extends AbstractController * into a list before dispatching. * * @param array $payload + * * @return list> */ private function normalizeEvents(array $payload): array diff --git a/src/Form/Model/BookingSummaryDto.php b/src/Form/Model/BookingSummaryDto.php index ba8b581..ed34d60 100644 --- a/src/Form/Model/BookingSummaryDto.php +++ b/src/Form/Model/BookingSummaryDto.php @@ -15,10 +15,10 @@ class BookingSummaryDto * @param array $selectedRooms Selected room DTOs from booking */ public function __construct( - public readonly array $selectedRooms, - public readonly int $participantCount, - public readonly BookingSummaryPricingDto $pricing, - public readonly BookingSummaryVoucherDto $vouchers, + public readonly array $selectedRooms, + public readonly int $participantCount, + public readonly BookingSummaryPricingDto $pricing, + public readonly BookingSummaryVoucherDto $vouchers, public readonly ?BookingSummaryCmsHotelData $cmsData, ) { } diff --git a/src/Form/Service/Condition/RentalSelectionCondition.php b/src/Form/Service/Condition/RentalSelectionCondition.php index e77447e..fc5eb12 100644 --- a/src/Form/Service/Condition/RentalSelectionCondition.php +++ b/src/Form/Service/Condition/RentalSelectionCondition.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace App\Form\Service\Condition; -use App\BusProNet\Model\Service; use App\Form\Model\BookingDto; use App\Form\Service\Contract\FieldConditionInterface; diff --git a/src/Form/Service/ParticipantAssignedRoomFieldHandler.php b/src/Form/Service/ParticipantAssignedRoomFieldHandler.php index 6698531..f71ee16 100644 --- a/src/Form/Service/ParticipantAssignedRoomFieldHandler.php +++ b/src/Form/Service/ParticipantAssignedRoomFieldHandler.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Form\Service; use App\Form\Model\BookingDto; +use App\Form\Model\ParticipantDto; use App\Form\Service\Abstract\AbstractParticipantFieldHandler; /** @@ -217,7 +218,7 @@ class ParticipantAssignedRoomFieldHandler extends AbstractParticipantFieldHandle * @param BookingDto $bookingDto The booking DTO with all participants * @param int $excludeParticipantIndex Participant index to exclude from results * - * @return array Array of participants indexed by their position + * @return array Array of participants indexed by their position */ private function getParticipantsAssignedToRoom(int $roomId, BookingDto $bookingDto, int $excludeParticipantIndex): array { diff --git a/src/Model/NewsletterSubscriptionRequestResult.php b/src/Model/NewsletterSubscriptionRequestResult.php index a2ceade..da23a48 100644 --- a/src/Model/NewsletterSubscriptionRequestResult.php +++ b/src/Model/NewsletterSubscriptionRequestResult.php @@ -14,7 +14,7 @@ class NewsletterSubscriptionRequestResult public const LIST_STATE_SUCCESS = 'success'; /** - * @param list $listIds + * @param list $listIds * @param array $listStates */ public function __construct( diff --git a/src/Repository/BookingEditDraftRepository.php b/src/Repository/BookingEditDraftRepository.php index 399fb51..156ee44 100644 --- a/src/Repository/BookingEditDraftRepository.php +++ b/src/Repository/BookingEditDraftRepository.php @@ -7,6 +7,8 @@ namespace App\Repository; use App\Entity\BookingEditDraft; use App\Entity\User; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\ORM\Query\Parameter; use Doctrine\Persistence\ManagerRegistry; /** @@ -47,8 +49,10 @@ class BookingEditDraftRepository extends ServiceEntityRepository ->delete() ->where('d.user = :user') ->andWhere('d.bookingId = :bookingId') - ->setParameter('user', $user) - ->setParameter('bookingId', $bookingId) + ->setParameters(new ArrayCollection([ + new Parameter('user', $user), + new Parameter('bookingId', $bookingId), + ])) ->getQuery() ->execute(); } diff --git a/src/Repository/NewsletterOptInRequestRepository.php b/src/Repository/NewsletterOptInRequestRepository.php index 720bb76..8d1322b 100644 --- a/src/Repository/NewsletterOptInRequestRepository.php +++ b/src/Repository/NewsletterOptInRequestRepository.php @@ -6,6 +6,8 @@ namespace App\Repository; use App\Entity\NewsletterOptInRequest; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\ORM\Query\Parameter; use Doctrine\Persistence\ManagerRegistry; /** @@ -29,8 +31,10 @@ class NewsletterOptInRequestRepository extends ServiceEntityRepository ->where('c.email = :email') ->andWhere('c.confirmedAt IS NULL') ->andWhere('c.expiresAt > :now') - ->setParameter('email', mb_strtolower(trim($email))) - ->setParameter('now', new \DateTimeImmutable()) + ->setParameters(new ArrayCollection([ + new Parameter('email', mb_strtolower(trim($email))), + new Parameter('now', new \DateTimeImmutable()), + ])) ->orderBy('c.createdAt', 'DESC') ->setMaxResults(1) ->getQuery() @@ -44,8 +48,10 @@ class NewsletterOptInRequestRepository extends ServiceEntityRepository ->where('c.email = :email') ->andWhere('c.confirmedAt IS NULL') ->andWhere('c.expiresAt <= :now') - ->setParameter('email', mb_strtolower(trim($email))) - ->setParameter('now', new \DateTimeImmutable()) + ->setParameters(new ArrayCollection([ + new Parameter('email', mb_strtolower(trim($email))), + new Parameter('now', new \DateTimeImmutable()), + ])) ->getQuery() ->execute(); } diff --git a/src/Repository/TravelSnapshotRepository.php b/src/Repository/TravelSnapshotRepository.php index 672bf3d..6cadec1 100644 --- a/src/Repository/TravelSnapshotRepository.php +++ b/src/Repository/TravelSnapshotRepository.php @@ -6,6 +6,8 @@ namespace App\Repository; use App\Entity\TravelSnapshot; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\ORM\Query\Parameter; use Doctrine\Persistence\ManagerRegistry; /** @@ -102,8 +104,10 @@ class TravelSnapshotRepository extends ServiceEntityRepository ->where('s.dateTo IS NULL OR s.dateTo >= :dateToThreshold') // extendedRefreshedAt IS NULL: never-refreshed snapshots rank as oldest. ->andWhere('s.extendedRefreshedAt IS NULL OR s.extendedRefreshedAt < :refreshBefore') - ->setParameter('dateToThreshold', $dateToThreshold) - ->setParameter('refreshBefore', $refreshBefore) + ->setParameters(new ArrayCollection([ + new Parameter('dateToThreshold', $dateToThreshold), + new Parameter('refreshBefore', $refreshBefore), + ])) ->orderBy('s.extendedRefreshedAt', 'ASC') ->addOrderBy('s.id', 'ASC') ->setMaxResults($limit) @@ -148,8 +152,10 @@ class TravelSnapshotRepository extends ServiceEntityRepository ->where('s.dateFrom IS NOT NULL') ->andWhere('s.dateFrom > :today') ->andWhere('s.dateId NOT IN (:activeXmlDateIds)') - ->setParameter('today', $today) - ->setParameter('activeXmlDateIds', $activeXmlDateIds) + ->setParameters(new ArrayCollection([ + new Parameter('today', $today), + new Parameter('activeXmlDateIds', $activeXmlDateIds), + ])) ->getQuery() ->execute(); } diff --git a/src/Service/BookingConfigurator.php b/src/Service/BookingConfigurator.php index 41b36bf..008bf17 100644 --- a/src/Service/BookingConfigurator.php +++ b/src/Service/BookingConfigurator.php @@ -27,7 +27,7 @@ class BookingConfigurator private readonly ParticipantEligibilityChecker $participantEligibilityService, private readonly BookingStatusRuleRegistry $bookingStatusRuleRegistry, private readonly AgencyLoader $agencyLoader, - #[Autowire('%default_booking_status%')] + #[Autowire(param: 'default_booking_status')] private readonly string $defaultBookingStatus, ) { } diff --git a/src/Service/BookingEditDraftMerger.php b/src/Service/BookingEditDraftMerger.php index 6c8f289..f586ff9 100644 --- a/src/Service/BookingEditDraftMerger.php +++ b/src/Service/BookingEditDraftMerger.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Service; +use App\BusProNet\Model\Address; use App\BusProNet\Model\Service; use App\BusProNet\Model\Travel; use App\Form\Model\BookingDto; @@ -120,7 +121,7 @@ class BookingEditDraftMerger } if (null === $participant->address) { - $participant->address = new \App\BusProNet\Model\Address(); + $participant->address = new Address(); } if (true === array_key_exists('street', $data)) { diff --git a/src/Service/BookingEditSubmitter.php b/src/Service/BookingEditSubmitter.php index b99dff0..b122b68 100644 --- a/src/Service/BookingEditSubmitter.php +++ b/src/Service/BookingEditSubmitter.php @@ -9,8 +9,8 @@ use App\BusProNet\Exception\ApiClientException; use App\BusProNet\Exception\TimeoutException; use App\BusProNet\Model\Notification; use App\Entity\User; -use App\Model\BookingEditSubmissionResult; use App\Form\Model\BookingDto; +use App\Model\BookingEditSubmissionResult; use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Request; @@ -76,6 +76,7 @@ class BookingEditSubmitter 'booking_id' => $bookingId, 'message' => $response->message, ]); + return new BookingEditSubmissionResult( true === $response->isError() ? BookingEditSubmissionResult::STATUS_NOTIFICATION_ERROR @@ -118,6 +119,7 @@ class BookingEditSubmitter 'email' => $email, 'booking_id' => $bookingId, ]); + return new BookingEditSubmissionResult( BookingEditSubmissionResult::STATUS_TIMEOUT, null, diff --git a/src/Service/BookingExporter.php b/src/Service/BookingExporter.php index 76040f2..33ff7e5 100644 --- a/src/Service/BookingExporter.php +++ b/src/Service/BookingExporter.php @@ -4,8 +4,12 @@ declare(strict_types=1); namespace App\Service; +use App\BusProNet\Model\Travel; use App\Entity\BookingEditDraft; +use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Style\Fill; +use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use Symfony\Component\HttpFoundation\StreamedResponse; @@ -106,11 +110,11 @@ class BookingExporter /** * Builds lookup arrays for converting IDs to labels. * - * @param \App\BusProNet\Model\Travel $travel The travel data + * @param Travel $travel The travel data * * @return array{services: array, rooms: array, pickups: array} */ - private function buildLookups(\App\BusProNet\Model\Travel $travel): array + private function buildLookups(Travel $travel): array { $services = []; $rooms = []; @@ -174,11 +178,11 @@ class BookingExporter $headerStyle = [ 'font' => ['bold' => true], 'fill' => [ - 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, + 'fillType' => Fill::FILL_SOLID, 'startColor' => ['rgb' => 'E0E0E0'], ], ]; - $lastColumn = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex(count(self::COLUMN_HEADERS)); + $lastColumn = Coordinate::stringFromColumnIndex(count(self::COLUMN_HEADERS)); $sheet->getStyle('A1:'.$lastColumn.'1')->applyFromArray($headerStyle); // Write participant data @@ -193,7 +197,7 @@ class BookingExporter // Auto-size columns foreach (range(1, count(self::COLUMN_HEADERS)) as $col) { - $colLetter = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($col); + $colLetter = Coordinate::stringFromColumnIndex($col); $sheet->getColumnDimension($colLetter)->setAutoSize(true); } @@ -208,7 +212,7 @@ class BookingExporter * @param array> $lookups */ private function writeParticipantRow( - \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $sheet, + Worksheet $sheet, int $row, array $participant, array $lookups, diff --git a/src/Service/BpnXmlSnapshotRefreshManager.php b/src/Service/BpnXmlSnapshotRefreshManager.php index 39acec7..cdbe969 100644 --- a/src/Service/BpnXmlSnapshotRefreshManager.php +++ b/src/Service/BpnXmlSnapshotRefreshManager.php @@ -4,9 +4,9 @@ declare(strict_types=1); namespace App\Service; +use App\BusProNet\XmlLoader\TravelLoader; use App\Model\BpnXmlSnapshotRefreshPlan; use App\Model\BpnXmlSnapshotRefreshResult; -use App\BusProNet\XmlLoader\TravelLoader; use Psr\Log\LoggerInterface; final class BpnXmlSnapshotRefreshManager diff --git a/src/Service/NewsletterManager.php b/src/Service/NewsletterManager.php index a1349f6..5387ca8 100644 --- a/src/Service/NewsletterManager.php +++ b/src/Service/NewsletterManager.php @@ -11,8 +11,8 @@ use App\Exception\NewsletterListNotAllowedException; use App\Exception\NewsletterProviderException; use App\Model\NewsletterConfirmationResult; use App\Model\NewsletterSubscriptionRequestResult; -use App\Repository\NewsletterOptInRequestRepository; use App\Repository\NewsletterConsentRepository; +use App\Repository\NewsletterOptInRequestRepository; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; @@ -72,7 +72,7 @@ class NewsletterManager } /** - * @param list $mailjetListIds + * @param list $mailjetListIds * @param list|null $knownMailjetListIds */ public function requestApiSubscription(string $email, array $mailjetListIds, ?array $knownMailjetListIds = null, ?string $firstName = null, ?string $lastName = null): NewsletterSubscriptionRequestResult diff --git a/src/Service/ParticipantPricingCalculator.php b/src/Service/ParticipantPricingCalculator.php index efc481a..387eb6d 100644 --- a/src/Service/ParticipantPricingCalculator.php +++ b/src/Service/ParticipantPricingCalculator.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace App\Service; use App\BusProNet\Model\Insurance; -use App\BusProNet\Model\Service; use App\Form\Model\BookingDto; use App\Form\Model\ParticipantDto; diff --git a/src/Twig/ErrorCodeExtension.php b/src/Twig/ErrorCodeExtension.php index d721773..74a841b 100644 --- a/src/Twig/ErrorCodeExtension.php +++ b/src/Twig/ErrorCodeExtension.php @@ -18,8 +18,8 @@ class ErrorCodeExtension extends AbstractExtension public function getFunctions(): array { return [ - new TwigFunction('error_code', [$this, 'getErrorCode']), - new TwigFunction('has_error_code', [$this, 'hasErrorCode']), + new TwigFunction('error_code', $this->getErrorCode(...)), + new TwigFunction('has_error_code', $this->hasErrorCode(...)), ]; } diff --git a/tests/BusProNet/Service/BookingStatusRuleRegistryTest.php b/tests/BusProNet/Service/BookingStatusRuleRegistryTest.php index 91abf00..bbd27cd 100644 --- a/tests/BusProNet/Service/BookingStatusRuleRegistryTest.php +++ b/tests/BusProNet/Service/BookingStatusRuleRegistryTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Tests\BusProNet\Service; +use App\BusProNet\Model\Travel; use App\BusProNet\Service\BookingStatusRuleRegistry; use App\BusProNet\Service\Contract\BookingStatusRuleInterface; use App\Form\Model\BookingDto; @@ -98,9 +99,9 @@ class BookingStatusRuleRegistryTest extends TestCase $this->assertSame('L', $registry->evaluateStatus($bookingDto)); } - private function createMockTravel(): \App\BusProNet\Model\Travel + private function createMockTravel(): Travel { - $travel = new \App\BusProNet\Model\Travel(); + $travel = new Travel(); $travel->id = 1; $travel->hotelId = 1; $travel->dateFrom = new \DateTimeImmutable('2030-01-01'); diff --git a/tests/Controller/Account/PersonalDataControllerTest.php b/tests/Controller/Account/PersonalDataControllerTest.php index 5ef39c3..33a63bd 100644 --- a/tests/Controller/Account/PersonalDataControllerTest.php +++ b/tests/Controller/Account/PersonalDataControllerTest.php @@ -17,7 +17,6 @@ use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; diff --git a/tests/Form/Model/ParticipantEditDtoTest.php b/tests/Form/Model/ParticipantEditDtoTest.php index 059333d..87c636c 100644 --- a/tests/Form/Model/ParticipantEditDtoTest.php +++ b/tests/Form/Model/ParticipantEditDtoTest.php @@ -4,6 +4,11 @@ declare(strict_types=1); namespace App\Tests\Form\Model; +use App\BusProNet\Model\Booking; +use App\BusProNet\Model\Address; +use App\Form\Model\AddressDto; +use App\BusProNet\Model\Service; +use App\BusProNet\Model\Insurance; use App\BusProNet\Model\Travel; use App\BusProNet\XmlLoader\AgencyLoader; use App\Form\Model\BookingDto; @@ -314,7 +319,7 @@ class ParticipantEditDtoTest extends TestCase $bookingDto = new BookingDto($travel, 1); // hotelId must be int // Create mock booking to simulate edit mode - $mockBooking = new \App\BusProNet\Model\Booking(); + $mockBooking = new Booking(); $bookingDto->booking = $mockBooking; // Create valid participants with all required fields for strict validation @@ -322,7 +327,7 @@ class ParticipantEditDtoTest extends TestCase $participant1->index = 0; $participant1->mutable = false; // Immutable - strict validation applies $participant1->mobile = '+49 123 456789'; // Required for applicant - $participant1->address = new \App\BusProNet\Model\Address(); + $participant1->address = new Address(); $participant1->address->street = 'Test Street 1'; $participant1->address->postCode = '12345'; $participant1->address->city = 'Test City'; @@ -489,7 +494,7 @@ class ParticipantEditDtoTest extends TestCase $participant->dateOfBirth = $travel->dateFrom->modify('-2 years'); $participant->index = 0; $participant->mobile = '+49 123 456789'; - $participant->address = new \App\BusProNet\Model\Address(); + $participant->address = new Address(); $participant->address->street = 'Test Street 1'; $participant->address->postCode = '12345'; $participant->address->city = 'Test City'; @@ -526,7 +531,7 @@ class ParticipantEditDtoTest extends TestCase $participant->dateOfBirth = $travel->dateFrom->modify('-3 years'); $participant->index = 0; $participant->mobile = '+49 123 456789'; - $participant->address = new \App\BusProNet\Model\Address(); + $participant->address = new Address(); $participant->address->street = 'Test Street 1'; $participant->address->postCode = '12345'; $participant->address->city = 'Test City'; @@ -559,7 +564,7 @@ class ParticipantEditDtoTest extends TestCase $bookingDto = new BookingDto($travel, 1); // Create mock booking to simulate edit mode - $mockBooking = new \App\BusProNet\Model\Booking(); + $mockBooking = new Booking(); $bookingDto->booking = $mockBooking; // Create adult participant without ski pass in edit mode @@ -568,7 +573,7 @@ class ParticipantEditDtoTest extends TestCase $participant->index = 0; $participant->mutable = false; $participant->mobile = '+49 123 456789'; - $participant->address = new \App\BusProNet\Model\Address(); + $participant->address = new Address(); $participant->address->street = 'Test Street 1'; $participant->address->postCode = '12345'; $participant->address->city = 'Test City'; @@ -606,7 +611,7 @@ class ParticipantEditDtoTest extends TestCase $participant->dateOfBirth = new \DateTimeImmutable('2023-06-02'); $participant->index = 0; $participant->mobile = '+49 123 456789'; - $participant->address = new \App\BusProNet\Model\Address(); + $participant->address = new Address(); $participant->address->street = 'Test Street 1'; $participant->address->postCode = '12345'; $participant->address->city = 'Test City'; @@ -647,7 +652,7 @@ class ParticipantEditDtoTest extends TestCase $participant->mobile = '+49 123 456789'; if (null === $participant->address) { - $participant->address = new \App\Form\Model\AddressDto(); + $participant->address = new AddressDto(); } $participant->address->street = 'Test Street 1'; $participant->address->postCode = '12345'; @@ -712,9 +717,9 @@ class ParticipantEditDtoTest extends TestCase return $participant; } - private function createMockService(): \App\BusProNet\Model\Service + private function createMockService(): Service { - $service = new \App\BusProNet\Model\Service(); + $service = new Service(); $service->id = 1; $service->label = 'Test Service'; $service->subType = 'TEST'; @@ -723,9 +728,9 @@ class ParticipantEditDtoTest extends TestCase return $service; } - private function createMockInsurance(): \App\BusProNet\Model\Insurance + private function createMockInsurance(): Insurance { - $insurance = new \App\BusProNet\Model\Insurance(); + $insurance = new Insurance(); $insurance->id = '1'; $insurance->label = 'Test Insurance'; $insurance->price = 10.0; diff --git a/tests/Model/NewsletterSubscriptionRequestTest.php b/tests/Model/NewsletterSubscriptionRequestTest.php index 1ebbe7c..3c845a6 100644 --- a/tests/Model/NewsletterSubscriptionRequestTest.php +++ b/tests/Model/NewsletterSubscriptionRequestTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Tests\Model; +use PHPUnit\Framework\TestCase; use App\Model\NewsletterSubscriptionRequest; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidatorFactory; @@ -13,7 +14,7 @@ use Symfony\Component\Validator\Constraints\EmailValidator; use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Validator\ValidatorInterface; -class NewsletterSubscriptionRequestTest extends \PHPUnit\Framework\TestCase +class NewsletterSubscriptionRequestTest extends TestCase { public function testValidRequestPassesValidation(): void { diff --git a/tests/Service/BookingConfiguratorStatusTest.php b/tests/Service/BookingConfiguratorStatusTest.php index f7b18cf..3e701f5 100644 --- a/tests/Service/BookingConfiguratorStatusTest.php +++ b/tests/Service/BookingConfiguratorStatusTest.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace App\Tests\Service; +use App\Form\Model\BookingDto; +use App\Form\Model\ParticipantDto; use App\BusProNet\Constants; use App\BusProNet\Model\Room; use App\BusProNet\Model\Service; @@ -192,9 +194,9 @@ class BookingConfiguratorStatusTest extends TestCase $travel->dateFrom = new \DateTimeImmutable('2030-01-01'); $travel->dateTo = new \DateTimeImmutable('2030-01-06'); - $bookingDto = new \App\Form\Model\BookingDto($travel, 456); + $bookingDto = new BookingDto($travel, 456); $bookingDto->bookingStatus = 'F'; - $participant = new \App\Form\Model\ParticipantDto(); + $participant = new ParticipantDto(); $participant->additionalServices = [new Service()]; $bookingDto->participants = [$participant]; @@ -223,7 +225,7 @@ class BookingConfiguratorStatusTest extends TestCase $travel->dateFrom = new \DateTimeImmutable('2030-01-01'); $travel->dateTo = new \DateTimeImmutable('2030-01-06'); - $bookingDto = new \App\Form\Model\BookingDto($travel, 456); + $bookingDto = new BookingDto($travel, 456); $bookingDto->bookingStatus = 'A'; $bookingService->applyCreateBookingStatusRules($bookingDto); diff --git a/tests/Service/BookingEditSubmitterTest.php b/tests/Service/BookingEditSubmitterTest.php index b6c8bb3..123e792 100644 --- a/tests/Service/BookingEditSubmitterTest.php +++ b/tests/Service/BookingEditSubmitterTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Tests\Service; +use App\BusProNet\ApiClient; use App\BusProNet\Exception\ApiClientException; use App\BusProNet\Exception\TimeoutException; use App\BusProNet\Model\Booking; @@ -87,7 +88,7 @@ class BookingEditSubmitterTest extends TestCase ->with($bookingDto, $freshBookingData) ->willReturn(false); - $apiClient = $this->createMock(\App\BusProNet\ApiClient::class); + $apiClient = $this->createMock(ApiClient::class); $apiClient->expects($this->once()) ->method('updateBooking') ->with($bookingDto, true) @@ -137,7 +138,7 @@ class BookingEditSubmitterTest extends TestCase ->with($bookingDto, $freshBookingData) ->willReturn(false); - $apiClient = $this->createMock(\App\BusProNet\ApiClient::class); + $apiClient = $this->createMock(ApiClient::class); $bookingUpdate = new BookingUpdate(); $bookingUpdate->success = false; $bookingUpdate->status = 'BPN-FAIL'; @@ -200,7 +201,7 @@ class BookingEditSubmitterTest extends TestCase ->with($bookingDto, $freshBookingData) ->willReturn(false); - $apiClient = $this->createMock(\App\BusProNet\ApiClient::class); + $apiClient = $this->createMock(ApiClient::class); $bookingUpdate = new BookingUpdate(); $bookingUpdate->success = true; $apiClient->expects($this->once()) @@ -266,7 +267,7 @@ class BookingEditSubmitterTest extends TestCase ->with($bookingDto, $freshBookingData) ->willReturn(true); - $apiClient = $this->createMock(\App\BusProNet\ApiClient::class); + $apiClient = $this->createMock(ApiClient::class); $bookingUpdate = new BookingUpdate(); $bookingUpdate->success = true; $apiClient->expects($this->once()) @@ -350,7 +351,7 @@ class BookingEditSubmitterTest extends TestCase ->with($bookingDto, $freshBookingData) ->willReturn(false); - $apiClient = $this->createMock(\App\BusProNet\ApiClient::class); + $apiClient = $this->createMock(ApiClient::class); $apiClient->expects($this->once()) ->method('updateBooking') ->with($bookingDto, true) @@ -400,7 +401,7 @@ class BookingEditSubmitterTest extends TestCase ->with($bookingDto, $freshBookingData) ->willReturn(false); - $apiClient = $this->createMock(\App\BusProNet\ApiClient::class); + $apiClient = $this->createMock(ApiClient::class); $apiClient->expects($this->once()) ->method('updateBooking') ->with($bookingDto, true) @@ -421,7 +422,7 @@ class BookingEditSubmitterTest extends TestCase } private function createService( - ?\App\BusProNet\ApiClient $apiClient = null, + ?ApiClient $apiClient = null, ?BookingEditDataLoader $dataLoader = null, ?BookingEditDraftManager $draftService = null, ?TravelDataProvider $travelDataService = null, @@ -429,7 +430,7 @@ class BookingEditSubmitterTest extends TestCase ?BookingSessionManager $bookingSessionService = null, ): BookingEditSubmitter { return new BookingEditSubmitter( - $apiClient ?? $this->createMock(\App\BusProNet\ApiClient::class), + $apiClient ?? $this->createMock(ApiClient::class), $dataLoader ?? $this->createMock(BookingEditDataLoader::class), $draftService ?? $this->createMock(BookingEditDraftManager::class), $travelDataService ?? $this->createMock(TravelDataProvider::class), diff --git a/tests/Service/ParticipantCardAssemblerTest.php b/tests/Service/ParticipantCardAssemblerTest.php index 80b9b24..15f6afc 100644 --- a/tests/Service/ParticipantCardAssemblerTest.php +++ b/tests/Service/ParticipantCardAssemblerTest.php @@ -4,6 +4,9 @@ declare(strict_types=1); namespace App\Tests\Service; +use Symfony\Component\Validator\ConstraintViolationListInterface; +use Symfony\Component\Validator\ConstraintViolationInterface; +use Symfony\Component\Validator\ConstraintViolationList; use App\BusProNet\Model\Room; use App\BusProNet\Model\Travel; use App\Form\Model\BookingDto; @@ -384,7 +387,7 @@ class ParticipantCardAssemblerTest extends TestCase ->willReturn([450.50]); // Mock validator to return no violations (valid) - $violations = $this->createMock(\Symfony\Component\Validator\ConstraintViolationListInterface::class); + $violations = $this->createMock(ConstraintViolationListInterface::class); $violations->expects($this->once()) ->method('count') ->willReturn(0); @@ -422,13 +425,13 @@ class ParticipantCardAssemblerTest extends TestCase ->willReturn([0.0]); // Mock validator to return violations (invalid) - $violation = $this->createMock(\Symfony\Component\Validator\ConstraintViolationInterface::class); + $violation = $this->createMock(ConstraintViolationInterface::class); $violation->expects($this->once()) ->method('getMessage') ->willReturn('Diese E-Mail Adresse wird bereits von einem anderen Teilnehmer verwendet'); // Use ConstraintViolationList directly instead of mocking - $violations = new \Symfony\Component\Validator\ConstraintViolationList([$violation]); + $violations = new ConstraintViolationList([$violation]); $this->validator ->expects($this->once()) @@ -473,7 +476,7 @@ class ParticipantCardAssemblerTest extends TestCase ->willReturn([450.0, 500.0]); // Mock validator to return no violations for both participants - $violations = $this->createMock(\Symfony\Component\Validator\ConstraintViolationListInterface::class); + $violations = $this->createMock(ConstraintViolationListInterface::class); $violations->expects($this->exactly(2)) ->method('count') ->willReturn(0);