Skip to content

Commit 381f52a

Browse files
committed
Fixed handling of default value for array property.
1 parent 2a756d1 commit 381f52a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Commands/CodeBuilder/CodeBuilderCommands.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,10 @@ protected function askQuestionForProperty($property_info, $default) {
535535
}
536536

537537
if ($property_info['format'] == 'array') {
538+
if (!is_array($default)) {
539+
$default = [$default];
540+
}
541+
538542
// Multi-valued property.
539543
// TODO: consider adding the explanation message on its own line first --
540544
// but need to work out how to format it, in the face of nonexistent
@@ -544,7 +548,8 @@ protected function askQuestionForProperty($property_info, $default) {
544548
$question = new \Symfony\Component\Console\Question\ChoiceQuestion(
545549
$this->getQuestionPromptForProperty("Enter the @label, one per line, empty line to finish", $property_info),
546550
$options,
547-
$default
551+
// Feed the default values one by one.
552+
array_shift($default)
548553
);
549554
$question->setAutocompleterValues($autocomplete_options);
550555
// Hack to work around the question not allowing an empty answer.
@@ -576,7 +581,7 @@ protected function askQuestionForProperty($property_info, $default) {
576581
// For subsequent iterations, the question should not show options.
577582
$question = new \Symfony\Component\Console\Question\Question(
578583
$this->getQuestionPromptForProperty("Enter further @label, one per line, empty line to finish", $property_info),
579-
$default
584+
array_shift($default)
580585
);
581586
$question->setAutocompleterValues($autocomplete_options);
582587
// Hack to work around the question not allowing an empty answer.

0 commit comments

Comments
 (0)