diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php index 9ab39db5b..e592b453e 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php @@ -18,8 +18,6 @@ use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Templating\Entity\UserRender; -use DateTime; -use DateTimeImmutable; use libphonenumber\PhoneNumber; use Symfony\Component\Clock\ClockInterface; use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; @@ -48,11 +46,13 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware } /** + * @param mixed|null $format + * * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface */ public function normalize($object, $format = null, array $context = []) { - /** @var array{"chill:user:at_date"?: DateTimeImmutable|DateTime} $context */ + /** @var array{"chill:user:at_date"?: \DateTimeImmutable|\DateTime} $context */ /** @var User $object */ $userJobContext = array_merge( $context, @@ -84,8 +84,8 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware } $at = $context[self::AT_DATE] ?? $this->clock->now(); - if ($at instanceof DateTime) { - $at = DateTimeImmutable::createFromMutable($at); + if ($at instanceof \DateTime) { + $at = \DateTimeImmutable::createFromMutable($at); } $data = [ diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php index 949d0c052..f8dd55bf2 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php @@ -53,7 +53,7 @@ class UserRender implements ChillEntityRenderInterface if (null === $opts['at_date']) { $opts['at_date'] = $this->clock->now(); } elseif ($opts['at_date'] instanceof \DateTime) { - $opts['at_date'] = DateTimeImmutable::createFromMutable($opts['at_date']); + $opts['at_date'] = \DateTimeImmutable::createFromMutable($opts['at_date']); } return $this->engine->render('@ChillMain/Entity/user.html.twig', [ @@ -71,7 +71,7 @@ class UserRender implements ChillEntityRenderInterface if (null === $opts['at_date']) { $opts['at_date'] = $this->clock->now(); } elseif ($opts['at_date'] instanceof \DateTime) { - $opts['at_date'] = DateTimeImmutable::createFromMutable($opts['at_date']); + $opts['at_date'] = \DateTimeImmutable::createFromMutable($opts['at_date']); } $str = $entity->getLabel(); diff --git a/src/Bundle/ChillMainBundle/Tests/Templating/Entity/UserRenderTest.php b/src/Bundle/ChillMainBundle/Tests/Templating/Entity/UserRenderTest.php index 1d6c91e13..2b0e07732 100644 --- a/src/Bundle/ChillMainBundle/Tests/Templating/Entity/UserRenderTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Templating/Entity/UserRenderTest.php @@ -82,7 +82,7 @@ class UserRenderTest extends TestCase // Create renderer $translatableStringHelperMock = $this->prophesize(TranslatableStringHelperInterface::class); - $translatableStringHelperMock->localize(Argument::type('array'))->will(fn($args) => $args[0]['fr']); + $translatableStringHelperMock->localize(Argument::type('array'))->will(fn ($args) => $args[0]['fr']); $engineMock = $this->createMock(Environment::class); $translatorMock = $this->createMock(TranslatorInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 50213dd6c..03a587620 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -1514,7 +1514,7 @@ class AccompanyingPeriod implements public function getCurrentUserHistory(): ?UserHistory { - return $this->getUserHistories()->findFirst(fn (int $key, UserHistory $userHistory) => $userHistory->getEndDate() === null); + return $this->getUserHistories()->findFirst(fn (int $key, UserHistory $userHistory) => null === $userHistory->getEndDate()); } private function addStepHistory(AccompanyingPeriodStepHistory $stepHistory, array $context = []): self diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php index a0f0f9a8e..c20d48984 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php @@ -18,9 +18,7 @@ use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher; use Chill\MainBundle\Serializer\Normalizer\UserNormalizer; -use Chill\MainBundle\Templating\Entity\UserRender; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Chill\PersonBundle\AccompanyingPeriod\Events\UserRefEventSubscriber; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\Person;