From 4f2d6758623f1fa56b33798867c6ee6e406cb0e7 Mon Sep 17 00:00:00 2001 From: "M. Vondano" Date: Thu, 3 Feb 2022 09:58:21 +0100 Subject: [PATCH] help psalm understand the code --- src/Controller/SurveyFragment.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Controller/SurveyFragment.php b/src/Controller/SurveyFragment.php index d6f29f0..7267911 100644 --- a/src/Controller/SurveyFragment.php +++ b/src/Controller/SurveyFragment.php @@ -22,6 +22,7 @@ use Mvo\ContaoSurvey\Form\SurveyManagerFactory; use Mvo\ContaoSurvey\Registry; use Mvo\ContaoSurvey\Repository\SurveyRepository; +use Symfony\Component\Form\SubmitButton; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; @@ -127,14 +128,20 @@ private function proceedUntilCompleted(SurveyManager $manager): bool } // reset (back to the first step) - if ($manager->form['reset']->isClicked()) { + /** @var SubmitButton $resetButton */ + $resetButton = $manager->form['reset']; + + if ($resetButton->isClicked()) { $manager->reset(); return false; } // back to the previous step - if (isset($manager->form['previous']) && $manager->form['previous']->isClicked() && $manager->previousStep()) { + /** @var SubmitButton|null $backButton */ + $backButton = $manager->form['previous'] ?? null; + + if ($backButton && $backButton->isClicked() && $manager->previousStep()) { return false; }