From aebeca1d7a54a535d5e528872035e081a32e052d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 5 Apr 2025 00:56:54 +0200 Subject: [PATCH] Use readonly properties in constructors for better immutability. Converted constructor properties to readonly where applicable, ensuring immutability and promoting safer code practices. Updated throwable class reference for clarity and consistency. --- ...ExportGenerationCreateFromSavedExportController.php | 10 +++++----- .../Export/Messenger/OnExportGenerationFails.php | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/ExportGenerationCreateFromSavedExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportGenerationCreateFromSavedExportController.php index 737cbbea1..199b9c92d 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportGenerationCreateFromSavedExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportGenerationCreateFromSavedExportController.php @@ -28,11 +28,11 @@ use Symfony\Component\Serializer\SerializerInterface; class ExportGenerationCreateFromSavedExportController { public function __construct( - private Security $security, - private EntityManagerInterface $entityManager, - private MessageBusInterface $messageBus, - private ClockInterface $clock, - private SerializerInterface $serializer, + private readonly Security $security, + private readonly EntityManagerInterface $entityManager, + private readonly MessageBusInterface $messageBus, + private readonly ClockInterface $clock, + private readonly SerializerInterface $serializer, ) {} #[Route('/api/1.0/main/export/export-generation/create-from-saved-export/{id}', methods: ['POST'])] diff --git a/src/Bundle/ChillMainBundle/Export/Messenger/OnExportGenerationFails.php b/src/Bundle/ChillMainBundle/Export/Messenger/OnExportGenerationFails.php index 43caaac54..09270dce0 100644 --- a/src/Bundle/ChillMainBundle/Export/Messenger/OnExportGenerationFails.php +++ b/src/Bundle/ChillMainBundle/Export/Messenger/OnExportGenerationFails.php @@ -24,9 +24,9 @@ class OnExportGenerationFails implements EventSubscriberInterface private const LOG_PREFIX = '[export_generation failed] '; public function __construct( - private LoggerInterface $logger, - private ExportGenerationRepository $repository, - private EntityManagerInterface $entityManager, + private readonly LoggerInterface $logger, + private readonly ExportGenerationRepository $repository, + private readonly EntityManagerInterface $entityManager, ) {} public static function getSubscribedEvents() @@ -58,7 +58,7 @@ class OnExportGenerationFails implements EventSubscriberInterface 'alias' => $exportGeneration->getExportAlias(), 'throwable_message' => $event->getThrowable()->getMessage(), 'throwable_trace' => $event->getThrowable()->getTraceAsString(), - 'throwable' => get_class($event->getThrowable()), + 'throwable' => $event->getThrowable()::class, 'full_generation_duration_failure' => microtime(true) - $exportGeneration->getCreatedAt()->getTimestamp(), ]);