Skip to content

Commit a139ad7

Browse files
Fix type issue with default value for InputOption
1 parent c5568ac commit a139ad7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Console/Input/FormBasedInputDefinitionFactory.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function createForFormType(string $formType, array &$resources = []): Inp
4141
}
4242

4343
$type = InputOption::VALUE_REQUIRED;
44-
$default = $field->getConfig()->getOption('data', null);
44+
$default = $this->resolveDefaultValue($field);
4545
$description = FormUtil::label($field);
4646

4747
$inputDefinition->addOption(new InputOption($name, null, $type, $description, $default));
@@ -62,4 +62,15 @@ private function isFormFieldSupported(FormInterface $field): bool
6262

6363
return true;
6464
}
65+
66+
private function resolveDefaultValue(FormInterface $field): string|bool|int|float|array|null
67+
{
68+
$default = $field->getConfig()->getOption('data', null);
69+
70+
if (is_scalar($default) || is_null($default)) {
71+
return $default;
72+
}
73+
74+
return null;
75+
}
6576
}

0 commit comments

Comments
 (0)