Repository: symfony/symfony
File: src/Symfony/Bridge/Twig/Extension/FormExtension.php (PHP)

Code before:
        return $this->getFormFlowCursor($view)?->getCurrentStep();
    }

    public function getFormFlowStepIndex(FormView $view): ?int
    {
        return $this->getFormFlowCursor($view)?->getStepIndex();
    }

    public function getFormFlowNextStep(FormView $view): ?string
    {
        return $this->getFormFlowCursor($view)?->getNextStep();
    }

    public function getFormFlowPreviousStep(FormView $view): ?string
    {
        return $this->getFormFlowCursor($view)?->getPreviousStep();
    }

    public function getFormFlowFirstStep(FormView $view): ?string
    {
        return $this->getFormFlowCursor($view)?->getFirstStep();
    }

    public function getFormFlowLastStep(FormView $view): ?string
    {
        return $this->getFormFlowCursor($view)?->getLastStep();
    }

    private function createFieldChoicesList(iterable $choices, string|false|null $translationDomain): iterable
    {
        foreach ($choices as $choice) {
            if ($choice instanceof ChoiceGroupView) {
                $translatableLabel = $this->createFieldTranslation($choice->label, [], $translationDomain);
                yield $translatableLabel => $this->createFieldChoicesList($choice, $translationDomain);

                continue;
            }

            /** @var ChoiceView $choice */
            $translatableLabel = $this->createFieldTranslation($choice->label, $choice->labelTranslationParameters, $translationDomain);
            yield $translatableLabel => $choice->value;
        }
    }

    private function createFieldTranslation(TranslatableInterface|string|null $value, array $parameters, string|false|null $domain): ?string
    {
        if (!$this->translator || !$value || false === $domain) {
            return null !== $value ? (string) $value : null;
        }
        if ($value instanceof TranslatableInterface) {
            return $value->trans($this->translator);

Review comment (suggestion):
I don't think the private method is useful:
```suggestion
        return ($view->vars['cursor'] ?? null)?->getLastStep();
```

Code after:
    }

    public function getFormFlowStepIndex(FormView $view): ?int
    {
        return ($view->vars['cursor'] ?? null)?->getStepIndex();
    }

    public function getFormFlowNextStep(FormView $view): ?string
    {
        return ($view->vars['cursor'] ?? null)?->getNextStep();
    }

    public function getFormFlowPreviousStep(FormView $view): ?string
    {
        return ($view->vars['cursor'] ?? null)?->getPreviousStep();
    }

    public function getFormFlowFirstStep(FormView $view): ?string
    {
        return ($view->vars['cursor'] ?? null)?->getFirstStep();
    }

    public function getFormFlowLastStep(FormView $view): ?string
    {
        return ($view->vars['cursor'] ?? null)?->getLastStep();
    }

    private function createFieldChoicesList(iterable $choices, string|false|null $translationDomain): iterable
    {
        foreach ($choices as $choice) {
            if ($choice instanceof ChoiceGroupView) {
                $translatableLabel = $this->createFieldTranslation($choice->label, [], $translationDomain);
                yield $translatableLabel => $this->createFieldChoicesList($choice, $translationDomain);

                continue;
            }

            /** @var ChoiceView $choice */
            $translatableLabel = $this->createFieldTranslation($choice->label, $choice->labelTranslationParameters, $translationDomain);
            yield $translatableLabel => $choice->value;
        }
    }

    private function createFieldTranslation(TranslatableInterface|string|null $value, array $parameters, string|false|null $domain): ?string
    {
        if (!$this->translator || !$value || false === $domain) {
            return null !== $value ? (string) $value : null;
        }
        if ($value instanceof TranslatableInterface) {
            return $value->trans($this->translator);
        }