chore: code cleanup with rector and php-cs-fixer

This commit is contained in:
Björn Fromme
2026-05-04 17:20:01 +02:00
parent d211425ff2
commit 1fa8f88a6d
38 changed files with 130 additions and 98 deletions
@@ -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<Service> Array of services selected by this participant
*/
private function collectParticipantAdditionalServices(ParticipantDto $participant): array
{
@@ -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;
+2 -3
View File
@@ -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);
@@ -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,
) {
@@ -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', [
@@ -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)));
}
@@ -85,7 +85,7 @@ class Step1Controller extends AbstractBookingCreateController
return $this->render('booking/create/step_1.html.twig', [
'bookingCreateContext' => $context,
'form' => $form->createView(),
'form' => $form,
]);
}
@@ -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;
@@ -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,
@@ -228,7 +228,7 @@ class Step3Controller extends AbstractBookingCreateController
return $this->render('booking/create/step_3.html.twig', [
'bookingCreateContext' => $context,
'form' => $form->createView(),
'form' => $form,
]);
}
@@ -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,
]);
@@ -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;
@@ -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,
+1 -1
View File
@@ -55,7 +55,7 @@ class RegistrationController extends AbstractController
}
return $this->render('registration/index.html.twig', [
'form' => $form->createView(),
'form' => $form,
]);
}
}
+1 -1
View File
@@ -63,7 +63,7 @@ class ResetPasswordController extends AbstractController
}
return $this->render('reset_password/index.html.twig', [
'form' => $form->createView(),
'form' => $form,
]);
}
}
@@ -55,6 +55,7 @@ final class MailjetNewsletterWebhookController extends AbstractController
* into a list before dispatching.
*
* @param array<int|string, mixed> $payload
*
* @return list<array<string, mixed>>
*/
private function normalizeEvents(array $payload): array
+4 -4
View File
@@ -15,10 +15,10 @@ class BookingSummaryDto
* @param array<int, RoomSelectionDto> $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,
) {
}
@@ -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;
@@ -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<int, \App\Form\Model\ParticipantDto> Array of participants indexed by their position
* @return array<int, ParticipantDto> Array of participants indexed by their position
*/
private function getParticipantsAssignedToRoom(int $roomId, BookingDto $bookingDto, int $excludeParticipantIndex): array
{
@@ -14,7 +14,7 @@ class NewsletterSubscriptionRequestResult
public const LIST_STATE_SUCCESS = 'success';
/**
* @param list<int> $listIds
* @param list<int> $listIds
* @param array<int, string> $listStates
*/
public function __construct(
@@ -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();
}
@@ -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();
}
+10 -4
View File
@@ -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();
}
+1 -1
View File
@@ -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,
) {
}
+2 -1
View File
@@ -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)) {
+3 -1
View File
@@ -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,
+10 -6
View File
@@ -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<int, string>, rooms: array<int, string>, pickups: array<int, string>}
*/
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<string, array<int, string>> $lookups
*/
private function writeParticipantRow(
\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $sheet,
Worksheet $sheet,
int $row,
array $participant,
array $lookups,
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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<int|string> $mailjetListIds
* @param list<int|string> $mailjetListIds
* @param list<int|string>|null $knownMailjetListIds
*/
public function requestApiSubscription(string $email, array $mailjetListIds, ?array $knownMailjetListIds = null, ?string $firstName = null, ?string $lastName = null): NewsletterSubscriptionRequestResult
@@ -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;
+2 -2
View File
@@ -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(...)),
];
}