Skip to content

Commit 22e6073

Browse files
Fix some mistakes
As mentioned in #6: we can't use Assert in production code. Also, the Behat scenarios didn't pass
1 parent 125fd92 commit 22e6073

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

features/interactive.feature

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ Feature: It is possible to interactively fill in a form from the CLI
6464
And the output should be
6565
"""
6666
Select color [red]:
67-
[0] Red
68-
[1] Blue
69-
[2] Yellow
67+
[0] Red (red)
68+
[1] Blue (blue)
69+
[2] Yellow (yellow)
7070
> Array
7171
(
7272
[color] => blue
@@ -83,9 +83,9 @@ Feature: It is possible to interactively fill in a form from the CLI
8383
And the output should be
8484
"""
8585
Select color [red]:
86-
[0] Red
87-
[1] Blue
88-
[2] Yellow
86+
[0] Red (red)
87+
[1] Blue (blue)
88+
[2] Yellow (yellow)
8989
> Array
9090
(
9191
[color] => red

src/Console/Helper/Question/AlwaysReturnKeyOfChoiceQuestion.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ class AlwaysReturnKeyOfChoiceQuestion extends ChoiceQuestion
1717

1818
public function __construct($question, array $choiceViews, $default = null)
1919
{
20-
\Assert\that($choiceViews)
21-
->all()
22-
->isInstanceOf(
23-
'Symfony\Component\Form\Extension\Core\View\ChoiceView',
24-
'Only a flat choice hierarchy is supported'
25-
);
20+
$this->assertFlatChoiceViewsArray($choiceViews);
2621

2722
$this->choiceViews = $choiceViews;
2823

@@ -117,4 +112,13 @@ private function prepareAutocompleteValues()
117112

118113
return $autocompleteValues;
119114
}
115+
116+
private function assertFlatChoiceViewsArray(array $choiceViews)
117+
{
118+
foreach ($choiceViews as $choiceView) {
119+
if (!$choiceView instanceof ChoiceView) {
120+
throw new \InvalidArgumentException('Only a flat choice hierarchy is supported');
121+
}
122+
}
123+
}
120124
}

0 commit comments

Comments
 (0)