diff --git a/src/Bundle/ChillActivityBundle/Audit/Displayer/ActivityDisplayer.php b/src/Bundle/ChillActivityBundle/Audit/Displayer/ActivityDisplayer.php index 6a594ebf1..8fa76a231 100644 --- a/src/Bundle/ChillActivityBundle/Audit/Displayer/ActivityDisplayer.php +++ b/src/Bundle/ChillActivityBundle/Audit/Displayer/ActivityDisplayer.php @@ -17,12 +17,12 @@ use Chill\MainBundle\Audit\SubjectDisplayerInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Symfony\Contracts\Translation\TranslatorInterface; -final class ActivityDisplayer implements SubjectDisplayerInterface +final readonly class ActivityDisplayer implements SubjectDisplayerInterface { public function __construct( - private readonly TranslatorInterface $translator, - private readonly ActivityRepository $activityRepository, - private readonly TranslatableStringHelperInterface $translatableStringHelper, + private TranslatorInterface $translator, + private ActivityRepository $activityRepository, + private TranslatableStringHelperInterface $translatableStringHelper, ) {} public function supportsDisplay(Subject $subject, array $options = []): bool diff --git a/src/Bundle/ChillCalendarBundle/Audit/Displayer/CalendarDisplayer.php b/src/Bundle/ChillCalendarBundle/Audit/Displayer/CalendarDisplayer.php index 1219486c3..8531aacfd 100644 --- a/src/Bundle/ChillCalendarBundle/Audit/Displayer/CalendarDisplayer.php +++ b/src/Bundle/ChillCalendarBundle/Audit/Displayer/CalendarDisplayer.php @@ -16,11 +16,11 @@ use Chill\MainBundle\Audit\Subject; use Chill\MainBundle\Audit\SubjectDisplayerInterface; use Symfony\Contracts\Translation\TranslatorInterface; -final class CalendarDisplayer implements SubjectDisplayerInterface +final readonly class CalendarDisplayer implements SubjectDisplayerInterface { public function __construct( - private readonly TranslatorInterface $translator, - private readonly CalendarRepository $calendarRepository, + private TranslatorInterface $translator, + private CalendarRepository $calendarRepository, ) {} public function supportsDisplay(Subject $subject, array $options = []): bool diff --git a/src/Bundle/ChillDocStoreBundle/Audit/Displayer/AccompanyingCourseDocumentSubjectDisplayer.php b/src/Bundle/ChillDocStoreBundle/Audit/Displayer/AccompanyingCourseDocumentSubjectDisplayer.php index 7b668dc54..2d79499bc 100644 --- a/src/Bundle/ChillDocStoreBundle/Audit/Displayer/AccompanyingCourseDocumentSubjectDisplayer.php +++ b/src/Bundle/ChillDocStoreBundle/Audit/Displayer/AccompanyingCourseDocumentSubjectDisplayer.php @@ -16,11 +16,11 @@ use Chill\MainBundle\Audit\Subject; use Chill\MainBundle\Audit\SubjectDisplayerInterface; use Twig\Environment; -final class AccompanyingCourseDocumentSubjectDisplayer implements SubjectDisplayerInterface +final readonly class AccompanyingCourseDocumentSubjectDisplayer implements SubjectDisplayerInterface { public function __construct( - private readonly AccompanyingCourseDocumentRepository $repository, - private readonly Environment $twig, + private AccompanyingCourseDocumentRepository $repository, + private Environment $twig, ) {} public function supportsDisplay(Subject $subject, array $options = []): bool diff --git a/src/Bundle/ChillDocStoreBundle/Repository/AssociatedEntityToStoredObjectRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/AssociatedEntityToStoredObjectRepository.php index 2f220490d..f2884b89c 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/AssociatedEntityToStoredObjectRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/AssociatedEntityToStoredObjectRepository.php @@ -21,7 +21,7 @@ class AssociatedEntityToStoredObjectRepository /** * @param iterable $repositories */ - public function __construct(private iterable $repositories) {} + public function __construct(private readonly iterable $repositories) {} public function findAssociatedEntityToStoredObject(StoredObject $storedObject): ?object { diff --git a/src/Bundle/ChillMainBundle/Audit/AuditEventDumper.php b/src/Bundle/ChillMainBundle/Audit/AuditEventDumper.php index 95bb818db..d7334118a 100644 --- a/src/Bundle/ChillMainBundle/Audit/AuditEventDumper.php +++ b/src/Bundle/ChillMainBundle/Audit/AuditEventDumper.php @@ -28,12 +28,12 @@ class AuditEventDumper public const MAX_LINES = 100_000; public function __construct( - private StoredObjectManagerInterface $storedObjectManager, - private AuditTrailRepository $auditTrailRepository, - private TranslatorInterface $translator, - private SubjectConverterManagerInterface $converterManager, - private EntityManagerInterface $entityManager, - private UserRender $userRender, + private readonly StoredObjectManagerInterface $storedObjectManager, + private readonly AuditTrailRepository $auditTrailRepository, + private readonly TranslatorInterface $translator, + private readonly SubjectConverterManagerInterface $converterManager, + private readonly EntityManagerInterface $entityManager, + private readonly UserRender $userRender, ) {} /** @@ -111,9 +111,7 @@ class AuditEventDumper $subjectsDisplay = ''; $subjects = $audit->getSubjects(); if ([] !== $subjects) { - $subjectsDisplay = implode(', ', array_map(function (array $s): string { - return $this->converterManager->display(Subject::fromArray($s), 'string'); - }, $subjects)); + $subjectsDisplay = implode(', ', array_map(fn (array $s): string => $this->converterManager->display(Subject::fromArray($s), 'string'), $subjects)); } fputcsv($handle, [ diff --git a/src/Bundle/ChillMainBundle/Audit/Exception/ConvertSubjectException.php b/src/Bundle/ChillMainBundle/Audit/Exception/ConvertSubjectException.php index 0c0ff020d..06b3df261 100644 --- a/src/Bundle/ChillMainBundle/Audit/Exception/ConvertSubjectException.php +++ b/src/Bundle/ChillMainBundle/Audit/Exception/ConvertSubjectException.php @@ -16,7 +16,7 @@ class ConvertSubjectException extends \LogicException public function __construct(mixed $subject, ?\Throwable $previous = null) { parent::__construct( - sprintf('Could not convert object of type %s to an acceptable audit representation', is_object($subject) ? get_class($subject) : gettype($subject)), + sprintf('Could not convert object of type %s to an acceptable audit representation', get_debug_type($subject)), previous: $previous ); } diff --git a/src/Bundle/ChillMainBundle/Tests/Audit/Messenger/AuditDumpRequestHandlerTest.php b/src/Bundle/ChillMainBundle/Tests/Audit/Messenger/AuditDumpRequestHandlerTest.php index 3b8b45b90..294323199 100644 --- a/src/Bundle/ChillMainBundle/Tests/Audit/Messenger/AuditDumpRequestHandlerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Audit/Messenger/AuditDumpRequestHandlerTest.php @@ -98,13 +98,11 @@ class AuditDumpRequestHandlerTest extends TestCase ]; $this->auditEventDumper->dump( - Argument::that(function ($criteria) use ($expectedCriteria) { - return $criteria['from_date'] === $expectedCriteria['from_date'] - && $criteria['to_date'] === $expectedCriteria['to_date'] - && 1 === count($criteria['subjects']) - && $criteria['subjects'][0]->isEqual($expectedCriteria['subjects'][0]) - && $criteria['by_users'] === $expectedCriteria['by_users']; - }), + Argument::that(fn ($criteria) => $criteria['from_date'] === $expectedCriteria['from_date'] + && $criteria['to_date'] === $expectedCriteria['to_date'] + && 1 === count($criteria['subjects']) + && $criteria['subjects'][0]->isEqual($expectedCriteria['subjects'][0]) + && $criteria['by_users'] === $expectedCriteria['by_users']), 'fr', $storedObject )->shouldBeCalled(); @@ -152,7 +150,7 @@ class AuditDumpRequestHandlerTest extends TestCase } } - public function provideExceptions(): array + public static function provideExceptions(): array { return [ [new AuditDumpTooMuchLines(1000, 500)], diff --git a/src/Bundle/ChillPersonBundle/Audit/Displayer/AccompanyingPeriodWorkSubjectDisplayer.php b/src/Bundle/ChillPersonBundle/Audit/Displayer/AccompanyingPeriodWorkSubjectDisplayer.php index 0e3ed8046..2ad0464a9 100644 --- a/src/Bundle/ChillPersonBundle/Audit/Displayer/AccompanyingPeriodWorkSubjectDisplayer.php +++ b/src/Bundle/ChillPersonBundle/Audit/Displayer/AccompanyingPeriodWorkSubjectDisplayer.php @@ -20,9 +20,9 @@ use Twig\Environment; class AccompanyingPeriodWorkSubjectDisplayer implements SubjectDisplayerInterface { public function __construct( - private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository, - private Environment $twig, - private TranslatorInterface $translator, + private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository, + private readonly Environment $twig, + private readonly TranslatorInterface $translator, ) {} public function supportsDisplay(Subject $subject, array $optons = []): bool diff --git a/src/Bundle/ChillPersonBundle/Controller/RelationApiController.php b/src/Bundle/ChillPersonBundle/Controller/RelationApiController.php index 7a0773ec3..b494fb701 100644 --- a/src/Bundle/ChillPersonBundle/Controller/RelationApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/RelationApiController.php @@ -20,7 +20,7 @@ use Symfony\Component\Validator\ConstraintViolationListInterface; class RelationApiController extends ApiController { - public function __construct(private TriggerAuditInterface $triggerAudit) {} + public function __construct(private readonly TriggerAuditInterface $triggerAudit) {} protected function onAfterFlush(string $action, Request $request, string $_format, $entity, ConstraintViolationListInterface $errors, array $more = []): ?Response {