From 087032881b819bc2a997c62fcdcbc9c442f3bf3f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 12 Feb 2024 14:50:26 +0100 Subject: [PATCH] Correct 2 phpstan errors, condition is always true and wrong typing --- .../Templating/Entity/UserRender.php | 2 +- .../AccompanyingPeriodWorkNormalizer.php | 21 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php index de9f4abbe..170116f04 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php @@ -65,7 +65,7 @@ class UserRender implements ChillEntityRenderInterface } /** - * @param array{main_scope?: bool, user_job?: bool, absence?: bool, at_date?: DateTimeImmutable|DateTimeMutable|null} $options + * @param array{main_scope?: bool, user_job?: bool, absence?: bool, at_date?: DateTimeImmutable|DateTime|null} $options */ public function renderString($entity, array $options): string { diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php index 94c440519..5d6000164 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php @@ -57,20 +57,19 @@ class AccompanyingPeriodWorkNormalizer implements ContextAwareNormalizerInterfac // add the referrers $initial['referrers'] = []; - if ($object instanceof AccompanyingPeriodWork) { - foreach ($object->getReferrersHistory() as $referrerHistory) { - if (null !== $referrerHistory->getEndDate()) { - continue; - } - - $initial['referrers'][] = $this->normalizer->normalize( - $referrerHistory->getUser(), - $format, - [...$context, UserNormalizer::AT_DATE => $referrerHistory->getStartDate()] - ); + foreach ($object->getReferrersHistory() as $referrerHistory) { + if (null !== $referrerHistory->getEndDate()) { + continue; } + + $initial['referrers'][] = $this->normalizer->normalize( + $referrerHistory->getUser(), + $format, + [...$context, UserNormalizer::AT_DATE => $referrerHistory->getStartDate()] + ); } + if ('json' === $format) { // then, we add normalization for things which are not into the entity $initial['workflows_availables'] = $this->metadataExtractor->availableWorkflowFor(