chore: cgl cleanup

This commit is contained in:
Björn Fromme
2026-04-16 13:34:54 +02:00
parent c0cc183c59
commit a927d6bf59
26 changed files with 45 additions and 66 deletions
+1
View File
@@ -193,6 +193,7 @@ class BpnXmlSyncCommand extends Command
/** /**
* @return array<string, int> * @return array<string, int>
*
* @throws FilesystemException * @throws FilesystemException
*/ */
private function syncFiles(SymfonyStyle $io): array private function syncFiles(SymfonyStyle $io): array
@@ -14,9 +14,9 @@ use App\Form\PersonalDataType;
use App\Repository\NewsletterOptInConfirmationRepository; use App\Repository\NewsletterOptInConfirmationRepository;
use App\Security\Crypt; use App\Security\Crypt;
use App\Service\BookingEditDataLoader; use App\Service\BookingEditDataLoader;
use App\Service\ProfileCompletenessChecker;
use App\Service\MailjetApiClient; use App\Service\MailjetApiClient;
use App\Service\NewsletterManager; use App\Service\NewsletterManager;
use App\Service\ProfileCompletenessChecker;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -37,12 +37,12 @@ class PersonalDataController extends AbstractController
public const SESSION_REDIRECT_KEY = '_profile_completion_redirect'; public const SESSION_REDIRECT_KEY = '_profile_completion_redirect';
/** /**
* @param ApiClient $apiClient BusProNet API client for data operations * @param ApiClient $apiClient BusProNet API client for data operations
* @param Crypt $crypt Encryption service for password handling * @param Crypt $crypt Encryption service for password handling
* @param BookingEditDataLoader $dataLoader Data loader for cache invalidation * @param BookingEditDataLoader $dataLoader Data loader for cache invalidation
* @param ProfileCompletenessChecker $completenessChecker Profile validation service * @param ProfileCompletenessChecker $completenessChecker Profile validation service
* @param EntityManagerInterface $entityManager Entity manager for persisting user changes * @param EntityManagerInterface $entityManager Entity manager for persisting user changes
* @param LoggerInterface $logger Logger for audit trails and debugging * @param LoggerInterface $logger Logger for audit trails and debugging
*/ */
public function __construct( public function __construct(
private readonly ApiClient $apiClient, private readonly ApiClient $apiClient,
@@ -182,8 +182,7 @@ class Step4Controller extends AbstractController
FormInterface $form, FormInterface $form,
bool $newsletterOptInVisible, bool $newsletterOptInVisible,
?string $newsletterTargetEmail, ?string $newsletterTargetEmail,
): Response ): Response {
{
$bookingCreateContext = $this->createContextFactory->createWithParticipantPrices($bookingCreateDto); $bookingCreateContext = $this->createContextFactory->createWithParticipantPrices($bookingCreateDto);
return $this->render('booking/create/step_4.html.twig', [ return $this->render('booking/create/step_4.html.twig', [
+1
View File
@@ -86,6 +86,7 @@ class Mailer
/** /**
* @param array<string, mixed> $options * @param array<string, mixed> $options
*
* @return array<string, mixed> * @return array<string, mixed>
*/ */
private function resolveConfig(array $options): array private function resolveConfig(array $options): array
+3 -3
View File
@@ -10,10 +10,10 @@ namespace App\Form\Model;
final class BookingSummaryPricingDto final class BookingSummaryPricingDto
{ {
/** /**
* @param array<int, array<string, mixed>> $rooms * @param array<int, array<string, mixed>> $rooms
* @param array<int, array<string, mixed>> $services * @param array<int, array<string, mixed>> $services
* @param array<int, array<string, mixed>>|null $surcharges * @param array<int, array<string, mixed>>|null $surcharges
* @param array<int, int> $assignmentCounts * @param array<int, int> $assignmentCounts
*/ */
public function __construct( public function __construct(
public readonly array $rooms, public readonly array $rooms,
+1 -1
View File
@@ -22,8 +22,8 @@ use App\Form\Service\Condition\RentalSelectionCondition;
use App\Form\Service\Condition\RoomSelectionCondition; use App\Form\Service\Condition\RoomSelectionCondition;
use App\Form\Service\Condition\ServiceSubTypeCondition; use App\Form\Service\Condition\ServiceSubTypeCondition;
use App\Form\Service\Condition\SkiPassSelectionCondition; use App\Form\Service\Condition\SkiPassSelectionCondition;
use App\Form\Service\Condition\TravelStartCutoffReachedCondition;
use App\Form\Service\Condition\TransportationServicesMutabilityCondition; use App\Form\Service\Condition\TransportationServicesMutabilityCondition;
use App\Form\Service\Condition\TravelStartCutoffReachedCondition;
/** /**
* Field state provider for the booking edit workflow. * Field state provider for the booking edit workflow.
@@ -16,8 +16,8 @@ use App\Form\Model\RoomSelectionDto;
use App\Form\Service\Abstract\AbstractFieldOptionsProvider; use App\Form\Service\Abstract\AbstractFieldOptionsProvider;
use App\Service\BookingPriceCalculator; use App\Service\BookingPriceCalculator;
use App\Service\InsuranceManager; use App\Service\InsuranceManager;
use App\Service\ServiceLabelFormatter;
use App\Service\ServiceAvailabilityCalculator; use App\Service\ServiceAvailabilityCalculator;
use App\Service\ServiceLabelFormatter;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
/** /**
@@ -222,8 +222,8 @@ class ParticipantRentalsFieldHandler extends AbstractParticipantFieldHandler
* - rental.dateFrom === skipass.dateFrom * - rental.dateFrom === skipass.dateFrom
* - rental.dateTo === skipass.dateTo * - rental.dateTo === skipass.dateTo
* *
* @param array $rentals All available rental services * @param array $rentals All available rental services
* @param \App\Form\Model\ParticipantDto $participant The participant with skipass selection * @param ParticipantDto $participant The participant with skipass selection
* *
* @return array Filtered rentals matching the skipass duration * @return array Filtered rentals matching the skipass duration
*/ */
+2 -4
View File
@@ -13,8 +13,8 @@ use App\BusProNet\XmlLoader\AgencyLoader;
use App\Exception\NoRoomsAvailableException; use App\Exception\NoRoomsAvailableException;
use App\Form\Model\BookingDto; use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto; use App\Form\Model\ParticipantDto;
use App\Form\Service\ServiceAgeEvaluator;
use App\Form\Model\RoomSelectionDto; use App\Form\Model\RoomSelectionDto;
use App\Form\Service\ServiceAgeEvaluator;
use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -539,8 +539,7 @@ class BookingConfigurator
BookingDto $bookingDto, BookingDto $bookingDto,
int $participantIndex, int $participantIndex,
ServiceAgeEvaluator $ageEvaluator, ServiceAgeEvaluator $ageEvaluator,
): bool ): bool {
{
if (false === $ageEvaluator->canEvaluate($service)) { if (false === $ageEvaluator->canEvaluate($service)) {
return true; return true;
} }
@@ -640,5 +639,4 @@ class BookingConfigurator
$bookingDto->bookingStatus = $this->bookingStatusRuleRegistry->evaluateStatus($bookingDto); $bookingDto->bookingStatus = $this->bookingStatusRuleRegistry->evaluateStatus($bookingDto);
} }
} }
+1 -2
View File
@@ -25,8 +25,7 @@ class BookingCreateContextFactory
public function create( public function create(
BookingDto $bookingDto, BookingDto $bookingDto,
string $pricingMode = RoomPricingCalculator::PRICING_MODE_ASSIGNMENT, string $pricingMode = RoomPricingCalculator::PRICING_MODE_ASSIGNMENT,
): BookingCreateContext ): BookingCreateContext {
{
$baseContext = $this->buildBaseContext($bookingDto, $pricingMode); $baseContext = $this->buildBaseContext($bookingDto, $pricingMode);
return new BookingCreateContext( return new BookingCreateContext(
+1 -1
View File
@@ -7,8 +7,8 @@ namespace App\Service;
use App\BusProNet\Model\Booking; use App\BusProNet\Model\Booking;
use App\Form\Model\BookingDto; use App\Form\Model\BookingDto;
use App\Form\Model\BookingEditContext; use App\Form\Model\BookingEditContext;
use App\Form\Model\BookingSummaryDto;
use App\Form\Model\BookingMutabilityDto; use App\Form\Model\BookingMutabilityDto;
use App\Form\Model\BookingSummaryDto;
/** /**
* Prepares the shared booking edit flow context. * Prepares the shared booking edit flow context.
+2
View File
@@ -241,6 +241,7 @@ class BookingPricingAssembler
* Groups services by their subtypes for display, separating positive costs and discounts. * Groups services by their subtypes for display, separating positive costs and discounts.
* *
* @param array<string, array<string, mixed>> $serviceAggregation * @param array<string, array<string, mixed>> $serviceAggregation
*
* @return array<int, array<string, mixed>> * @return array<int, array<string, mixed>>
*/ */
private function groupServicesBySubtype(array $serviceAggregation): array private function groupServicesBySubtype(array $serviceAggregation): array
@@ -387,6 +388,7 @@ class BookingPricingAssembler
/** /**
* @param array<string, mixed> $serviceData * @param array<string, mixed> $serviceData
*
* @return array<string, mixed> * @return array<string, mixed>
*/ */
private function createServicePricingLineItem(array $serviceData): array private function createServicePricingLineItem(array $serviceData): array
+1 -2
View File
@@ -42,8 +42,7 @@ class BookingSummaryAssembler
public function getSummaryData( public function getSummaryData(
BookingDto $bookingDto, BookingDto $bookingDto,
string $roomPricingMode = RoomPricingCalculator::PRICING_MODE_ASSIGNMENT, string $roomPricingMode = RoomPricingCalculator::PRICING_MODE_ASSIGNMENT,
): BookingSummaryDto ): BookingSummaryDto {
{
// Get selected rooms (for Step1 controller compatibility) // Get selected rooms (for Step1 controller compatibility)
$selectedRooms = $bookingDto->getSelectedRooms(); $selectedRooms = $bookingDto->getSelectedRooms();
-2
View File
@@ -161,8 +161,6 @@ class BpnXmlAnonymizer
} }
/** /**
* @param string $personId
*
* @return array{firstName: string, lastName: string, street: string, postalCode: string, city: string, email: string, mobilePhone: string} * @return array{firstName: string, lastName: string, street: string, postalCode: string, city: string, email: string, mobilePhone: string}
*/ */
private function getOrCreateIdentity(string $personId): array private function getOrCreateIdentity(string $personId): array
+5 -14
View File
@@ -157,19 +157,13 @@ class MailjetApiClient
$payload = $response->toArray(false); $payload = $response->toArray(false);
if ($statusCode >= 400) { if ($statusCode >= 400) {
$payloadSummary = is_array($payload) $payloadSummary = json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
? json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) $payloadSummary = false === $payloadSummary ? null : $payloadSummary;
: null;
throw new NewsletterProviderException(sprintf( throw new NewsletterProviderException(sprintf('Mailjet request failed with status %d for resource %s%s', $statusCode, $resource, null !== $payloadSummary ? sprintf(' (%s)', $payloadSummary) : ''));
'Mailjet request failed with status %d for resource %s%s',
$statusCode,
$resource,
null !== $payloadSummary ? sprintf(' (%s)', $payloadSummary) : ''
));
} }
return is_array($payload) ? $payload : []; return $payload;
} catch (\Throwable $exception) { } catch (\Throwable $exception) {
if ($allow404 && str_contains($exception->getMessage(), '404')) { if ($allow404 && str_contains($exception->getMessage(), '404')) {
return []; return [];
@@ -179,10 +173,7 @@ class MailjetApiClient
throw $exception; throw $exception;
} }
throw new NewsletterProviderException( throw new NewsletterProviderException(sprintf('Mailjet request error for resource %s', $resource), previous: $exception);
sprintf('Mailjet request error for resource %s', $resource),
previous: $exception
);
} }
} }
+1 -1
View File
@@ -5,8 +5,8 @@ declare(strict_types=1);
namespace App\Service; namespace App\Service;
use App\Email\Mailer; use App\Email\Mailer;
use App\Exception\NewsletterProviderException;
use App\Entity\NewsletterOptInConfirmation; use App\Entity\NewsletterOptInConfirmation;
use App\Exception\NewsletterProviderException;
use App\Model\NewsletterConfirmationResult; use App\Model\NewsletterConfirmationResult;
use App\Repository\NewsletterOptInConfirmationRepository; use App\Repository\NewsletterOptInConfirmationRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
-6
View File
@@ -26,8 +26,6 @@ class ParticipantCardAssembler
/** /**
* Get card data for a single participant. * Get card data for a single participant.
*
* @return ParticipantCardDataDto
*/ */
public function getCardData(BookingDto $bookingDto, int $index): ParticipantCardDataDto public function getCardData(BookingDto $bookingDto, int $index): ParticipantCardDataDto
{ {
@@ -124,8 +122,6 @@ class ParticipantCardAssembler
* *
* Returns a dash marker when the price is zero and no room is assigned, * Returns a dash marker when the price is zero and no room is assigned,
* indicating incomplete configuration rather than a zero-cost booking. * indicating incomplete configuration rather than a zero-cost booking.
*
* @return ParticipantCardPriceDto
*/ */
private function getPriceData(BookingDto $bookingDto, int $index): ParticipantCardPriceDto private function getPriceData(BookingDto $bookingDto, int $index): ParticipantCardPriceDto
{ {
@@ -169,8 +165,6 @@ class ParticipantCardAssembler
/** /**
* Get card data for a single participant with validation state. * Get card data for a single participant with validation state.
*
* @return ParticipantCardDataDto
*/ */
public function getCardDataWithValidation(BookingDto $bookingDto, int $index): ParticipantCardDataDto public function getCardDataWithValidation(BookingDto $bookingDto, int $index): ParticipantCardDataDto
{ {
+2 -4
View File
@@ -28,8 +28,7 @@ class RoomPricingCalculator
public function calculateRoomPricing( public function calculateRoomPricing(
BookingDto $bookingDto, BookingDto $bookingDto,
string $pricingMode = self::PRICING_MODE_ASSIGNMENT, string $pricingMode = self::PRICING_MODE_ASSIGNMENT,
): array ): array {
{
// In edit mode, use room data from the booking entity // In edit mode, use room data from the booking entity
if (BookingDto::MODE_EDIT === $bookingDto->getMode() && null !== $bookingDto->booking) { if (BookingDto::MODE_EDIT === $bookingDto->getMode() && null !== $bookingDto->booking) {
return $this->calculateRoomPricingFromBooking($bookingDto); return $this->calculateRoomPricingFromBooking($bookingDto);
@@ -45,8 +44,7 @@ class RoomPricingCalculator
public function calculateRoomTotal( public function calculateRoomTotal(
BookingDto $bookingDto, BookingDto $bookingDto,
string $pricingMode = self::PRICING_MODE_ASSIGNMENT, string $pricingMode = self::PRICING_MODE_ASSIGNMENT,
): float ): float {
{
$roomPricing = $this->calculateRoomPricing($bookingDto, $pricingMode); $roomPricing = $this->calculateRoomPricing($bookingDto, $pricingMode);
return array_sum(array_column($roomPricing, 'totalPrice')); return array_sum(array_column($roomPricing, 'totalPrice'));
+1 -1
View File
@@ -40,7 +40,7 @@ final class ServiceLabelFormatter
return $fallbackLabel; return $fallbackLabel;
} }
if (!($service instanceof Service)) { if (!$service instanceof Service) {
return $fallbackLabel; return $fallbackLabel;
} }
+3 -3
View File
@@ -85,9 +85,9 @@ class TravelDataProvider
* *
* @return Travel|null The travel data or null on unexpected failure * @return Travel|null The travel data or null on unexpected failure
* *
* @throws TravelNotFoundException When the travel date is not found * @throws TravelNotFoundException When the travel date is not found
* @throws HotelNotFoundException When the requested hotel is not found * @throws HotelNotFoundException When the requested hotel is not found
* @throws HotelNotInTravelException When the hotel does not belong to this travel * @throws HotelNotInTravelException When the hotel does not belong to this travel
*/ */
public function getTravelDataFromXml(int $dateId, ?int $hotelId = null): ?Travel public function getTravelDataFromXml(int $dateId, ?int $hotelId = null): ?Travel
{ {
+3 -1
View File
@@ -162,14 +162,16 @@ class TravelSnapshotManager
/** /**
* Refreshes snapshot payloads with extended availability data. * Refreshes snapshot payloads with extended availability data.
*
* @param array<int>|null $xmlAvailableDateIds * @param array<int>|null $xmlAvailableDateIds
*
* @return array{processed:int,updated:int,failed:int} * @return array{processed:int,updated:int,failed:int}
*/ */
public function refreshExtendedSnapshots( public function refreshExtendedSnapshots(
int $limit = 500, int $limit = 500,
bool $force = false, bool $force = false,
int $refreshAfterMinutes = 360, int $refreshAfterMinutes = 360,
?array $xmlAvailableDateIds = null ?array $xmlAvailableDateIds = null,
): array { ): array {
$dateToThreshold = new \DateTimeImmutable('today'); $dateToThreshold = new \DateTimeImmutable('today');
$refreshBefore = new \DateTimeImmutable(sprintf('-%d minutes', $refreshAfterMinutes)); $refreshBefore = new \DateTimeImmutable(sprintf('-%d minutes', $refreshAfterMinutes));
-1
View File
@@ -14,7 +14,6 @@ use App\Model\DomainConfig;
use App\Service\ParticipantEligibilityChecker; use App\Service\ParticipantEligibilityChecker;
use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Twig\Environment;
use Twig\Extension\RuntimeExtensionInterface; use Twig\Extension\RuntimeExtensionInterface;
use Twig\Extra\Intl\IntlExtension; use Twig\Extra\Intl\IntlExtension;
@@ -22,4 +22,3 @@ class MandatoryAdditionalServicesSelected extends Constraint
return static::CLASS_CONSTRAINT; return static::CLASS_CONSTRAINT;
} }
} }
@@ -83,4 +83,3 @@ class MandatoryAdditionalServicesSelectedValidator extends ConstraintValidator
} }
} }
} }
+5 -5
View File
@@ -423,11 +423,11 @@ class BookingEditSubmitterTest extends TestCase
private function createService( private function createService(
?\App\BusProNet\ApiClient $apiClient = null, ?\App\BusProNet\ApiClient $apiClient = null,
?BookingEditDataLoader $dataLoader = null, ?BookingEditDataLoader $dataLoader = null,
?BookingEditDraftManager $draftService = null, ?BookingEditDraftManager $draftService = null,
?TravelDataProvider $travelDataService = null, ?TravelDataProvider $travelDataService = null,
?BookingEditSubmitGuard $submitGuard = null, ?BookingEditSubmitGuard $submitGuard = null,
?BookingSessionStore $bookingSessionService = null, ?BookingSessionManager $bookingSessionService = null,
): BookingEditSubmitter { ): BookingEditSubmitter {
return new BookingEditSubmitter( return new BookingEditSubmitter(
$apiClient ?? $this->createMock(\App\BusProNet\ApiClient::class), $apiClient ?? $this->createMock(\App\BusProNet\ApiClient::class),