From 06f3d60797cfa9e9aa35d0209fa129e7ace12f3c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 15 Apr 2024 12:40:16 +0200 Subject: [PATCH] Mark some properties and classes as readonly --- src/EventSubscriber/CheckRequirementsSubscriber.php | 4 ++-- src/EventSubscriber/CommentNotificationSubscriber.php | 10 +++++----- src/EventSubscriber/ControllerSubscriber.php | 4 ++-- .../DataTransformer/TagArrayToStringTransformer.php | 4 ++-- src/Twig/AppExtension.php | 2 +- src/Twig/SourceCodeExtension.php | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/EventSubscriber/CheckRequirementsSubscriber.php b/src/EventSubscriber/CheckRequirementsSubscriber.php index cdeed0275..b8f728cec 100644 --- a/src/EventSubscriber/CheckRequirementsSubscriber.php +++ b/src/EventSubscriber/CheckRequirementsSubscriber.php @@ -29,10 +29,10 @@ * * @author Javier Eguiluz */ -final class CheckRequirementsSubscriber implements EventSubscriberInterface +final readonly class CheckRequirementsSubscriber implements EventSubscriberInterface { public function __construct( - private readonly EntityManagerInterface $entityManager + private EntityManagerInterface $entityManager ) { } diff --git a/src/EventSubscriber/CommentNotificationSubscriber.php b/src/EventSubscriber/CommentNotificationSubscriber.php index 842abff42..b71327b45 100644 --- a/src/EventSubscriber/CommentNotificationSubscriber.php +++ b/src/EventSubscriber/CommentNotificationSubscriber.php @@ -26,14 +26,14 @@ * * @author Oleg Voronkovich */ -final class CommentNotificationSubscriber implements EventSubscriberInterface +final readonly class CommentNotificationSubscriber implements EventSubscriberInterface { public function __construct( - private readonly MailerInterface $mailer, - private readonly UrlGeneratorInterface $urlGenerator, - private readonly TranslatorInterface $translator, + private MailerInterface $mailer, + private UrlGeneratorInterface $urlGenerator, + private TranslatorInterface $translator, #[Autowire('%app.notifications.email_sender%')] - private readonly string $sender + private string $sender ) { } diff --git a/src/EventSubscriber/ControllerSubscriber.php b/src/EventSubscriber/ControllerSubscriber.php index 5fc857410..e85d62a3c 100644 --- a/src/EventSubscriber/ControllerSubscriber.php +++ b/src/EventSubscriber/ControllerSubscriber.php @@ -23,10 +23,10 @@ * @author Ryan Weaver * @author Javier Eguiluz */ -final class ControllerSubscriber implements EventSubscriberInterface +final readonly class ControllerSubscriber implements EventSubscriberInterface { public function __construct( - private readonly SourceCodeExtension $twigExtension + private SourceCodeExtension $twigExtension ) { } diff --git a/src/Form/DataTransformer/TagArrayToStringTransformer.php b/src/Form/DataTransformer/TagArrayToStringTransformer.php index b98be0a5c..0358ac054 100644 --- a/src/Form/DataTransformer/TagArrayToStringTransformer.php +++ b/src/Form/DataTransformer/TagArrayToStringTransformer.php @@ -27,10 +27,10 @@ * * @template-implements DataTransformerInterface */ -final class TagArrayToStringTransformer implements DataTransformerInterface +final readonly class TagArrayToStringTransformer implements DataTransformerInterface { public function __construct( - private readonly TagRepository $tags + private TagRepository $tags ) { } diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index e6c44439e..6f4cefd4e 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -33,7 +33,7 @@ final class AppExtension extends AbstractExtension // See https://symfony.com/doc/current/service_container.html#binding-arguments-by-name-or-type public function __construct( /** @var string[] */ - private array $enabledLocales, + private readonly array $enabledLocales, ) { } diff --git a/src/Twig/SourceCodeExtension.php b/src/Twig/SourceCodeExtension.php index c0248209b..182cf9966 100644 --- a/src/Twig/SourceCodeExtension.php +++ b/src/Twig/SourceCodeExtension.php @@ -36,7 +36,7 @@ final class SourceCodeExtension extends AbstractExtension private $controller; public function __construct( - private FileLinkFormatter $fileLinkFormat, + private readonly FileLinkFormatter $fileLinkFormat, #[Autowire('%kernel.project_dir%')] private string $projectDir, ) {