Skip to content

[Form] Add MultiStepType #59548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Prev Previous commit
Next Next commit
Fix
  • Loading branch information
silasjoisten committed Jan 18, 2025
commit bc77606b32f33fcbb7b4b56698c05a2c405e8ff2
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

/*
Expand Down Expand Up @@ -30,8 +39,8 @@
public function configureOptions(OptionsResolver $resolver): void
{
$resolver
->setDefault('current_step_name', static function (Options $options): string {

Check failure on line 42 in src/Symfony/Component/Form/Extension/Core/Type/MultiStepType.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidNullableReturnType

src/Symfony/Component/Form/Extension/Core/Type/MultiStepType.php:42:83: InvalidNullableReturnType: The declared return type 'string' for /home/runner/work/symfony/symfony/src/symfony/component/form/extension/core/type/multisteptype.php:42:1158:-:closure is not nullable, but 'key-of<TArray>|null' contains null (see https://psalm.dev/144)

Check failure on line 42 in src/Symfony/Component/Form/Extension/Core/Type/MultiStepType.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidNullableReturnType

src/Symfony/Component/Form/Extension/Core/Type/MultiStepType.php:42:83: InvalidNullableReturnType: The declared return type 'string' for /home/runner/work/symfony/symfony/src/symfony/component/form/extension/core/type/multisteptype.php:42:1158:-:closure is not nullable, but 'key-of<TArray>|null' contains null (see https://psalm.dev/144)
return array_key_first($options['steps']);

Check failure on line 43 in src/Symfony/Component/Form/Extension/Core/Type/MultiStepType.php

View workflow job for this annotation

GitHub Actions / Psalm

NullableReturnStatement

src/Symfony/Component/Form/Extension/Core/Type/MultiStepType.php:43:24: NullableReturnStatement: The declared return type 'string' for /home/runner/work/symfony/symfony/src/symfony/component/form/extension/core/type/multisteptype.php:42:1158:-:closure is not nullable, but the function returns '(key-of<array<TKey:fn-array_key_first as array-key, mixed>>)|null' (see https://psalm.dev/139)

Check failure on line 43 in src/Symfony/Component/Form/Extension/Core/Type/MultiStepType.php

View workflow job for this annotation

GitHub Actions / Psalm

NullableReturnStatement

src/Symfony/Component/Form/Extension/Core/Type/MultiStepType.php:43:24: NullableReturnStatement: The declared return type 'string' for /home/runner/work/symfony/symfony/src/symfony/component/form/extension/core/type/multisteptype.php:42:1158:-:closure is not nullable, but the function returns '(key-of<array<TKey:fn-array_key_first as array-key, mixed>>)|null' (see https://psalm.dev/139)
})
->setRequired('steps');
}
Expand All @@ -42,9 +51,9 @@

if (\is_callable($currentStep)) {
$currentStep($builder, $options);
} elseif(\is_string($currentStep)) {
} elseif (\is_string($currentStep)) {
if (!class_exists($currentStep) || !is_a($currentStep, AbstractType::class)) {
throw new \InvalidArgumentException(sprintf('The form class "%s" does not exist.', $currentStep));
throw new \InvalidArgumentException(\sprintf('The form class "%s" does not exist.', $currentStep));
}

$builder->add($options['current_step_name'], $currentStep, $options);
Expand Down
Loading