From 5651efe44d3847d8c1ec8c4e4dd4d68df58db21f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 12 Nov 2021 17:50:12 +0100 Subject: [PATCH] fix phpstan errors --- phpstan-baseline.neon | 5 ----- .../Controller/AccompanyingCourseWorkController.php | 7 ++++--- .../ChillPersonBundle/Entity/AccompanyingPeriod.php | 9 +++++---- .../AccompanyingPeriod/ParticipationOverlapValidator.php | 9 +++++---- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e578c1d45..d2128437a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -905,11 +905,6 @@ parameters: count: 1 path: src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php - - - message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Bundle/ChillMainBundle/Util/DateRangeCovering.php - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" count: 2 diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php index 3625c7cca..cf935b7c3 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php @@ -22,7 +22,7 @@ class AccompanyingCourseWorkController extends AbstractController private SerializerInterface $serializer; private AccompanyingPeriodWorkRepository $workRepository; private PaginatorFactory $paginator; - protected LoggerInterface $logger; + private LoggerInterface $chillLogger; public function __construct( TranslatorInterface $trans, @@ -35,7 +35,7 @@ class AccompanyingCourseWorkController extends AbstractController $this->serializer = $serializer; $this->workRepository = $workRepository; $this->paginator = $paginator; - $this->logger = $logger; + $this->chillLogger = $chillLogger; } /** @@ -133,7 +133,7 @@ class AccompanyingCourseWorkController extends AbstractController if ($form->isValid()) { - $this->logger->notice("An accompanying period work has been removed", [ + $this->chillLogger->notice("An accompanying period work has been removed", [ 'by_user' => $this->getUser()->getUsername(), 'work_id' => $work->getId(), 'accompanying_period_id' => $work->getAccompanyingPeriod()->getId() @@ -162,6 +162,7 @@ class AccompanyingCourseWorkController extends AbstractController private function createDeleteForm(int $id): Form { + $params = []; $params['id'] = $id; return $this->createFormBuilder() diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index dab1dcb9d..6c9c84b56 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -1137,14 +1137,15 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface public function getGroupSequence() { - if($this->getStep() == self::STEP_DRAFT) + if ($this->getStep() == self::STEP_DRAFT) { return [[self::STEP_DRAFT]]; - } - - if($this->getStep() == self::STEP_CONFIRMED) + } elseif ($this->getStep() == self::STEP_CONFIRMED) { return [[self::STEP_DRAFT, self::STEP_CONFIRMED]]; } + + throw new \LogicException("no validation group permitted with this step"); + } } diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php index ef9868420..50c71998b 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php @@ -30,6 +30,7 @@ class ParticipationOverlapValidator extends ConstraintValidator } $overlaps = new DateRangeCovering(self::MAX_PARTICIPATION, $participations[0]->getStartDate()->getTimezone()); + $participationList = []; foreach ($participations as $participation) { @@ -38,12 +39,12 @@ class ParticipationOverlapValidator extends ConstraintValidator } $personId = $participation->getPerson()->getId(); - - $particpationList[$personId][] = $participation; + + $participationList[$personId][] = $participation; } - foreach ($particpationList as $group) { + foreach ($participationList as $group) { if (count($group) > 1) { foreach ($group as $p) { $overlaps->add($p->getStartDate(), $p->getEndDate(), $p->getId()); @@ -69,4 +70,4 @@ class ParticipationOverlapValidator extends ConstraintValidator } } -} \ No newline at end of file +}