Skip to content

Commit 083c8af

Browse files
committed
Remove group options without data and fix normalization
1 parent ecf54d5 commit 083c8af

File tree

5 files changed

+83
-9
lines changed

5 files changed

+83
-9
lines changed

src/Symfony/Component/Form/Console/Descriptor/Descriptor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ protected function collectOptions(ResolvedFormTypeInterface $type)
9898
}
9999

100100
$this->overriddenOptions = array_filter($this->overriddenOptions);
101+
$this->parentOptions = array_filter($this->parentOptions);
102+
$this->extensionOptions = array_filter($this->extensionOptions);
101103
$this->requiredOptions = $optionsResolver->getRequiredOptions();
102104

103105
$this->parents = array_keys($this->parents);

src/Symfony/Component/Form/Console/Descriptor/TextDescriptor.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,30 +126,32 @@ protected function describeOption(OptionsResolver $optionsResolver, array $optio
126126

127127
private function normalizeAndSortOptionsColumns(array $options)
128128
{
129-
foreach ($options as $group => &$opts) {
129+
foreach ($options as $group => $opts) {
130130
$sorted = false;
131131
foreach ($opts as $class => $opt) {
132+
if (is_string($class)) {
133+
unset($options[$group][$class]);
134+
}
135+
132136
if (!is_array($opt) || 0 === count($opt)) {
133137
continue;
134138
}
135139

136-
unset($opts[$class]);
137-
138140
if (!$sorted) {
139-
$opts = array();
141+
$options[$group] = array();
140142
} else {
141-
$opts[] = null;
143+
$options[$group][] = null;
142144
}
143-
$opts[] = sprintf('<info>%s</info>', (new \ReflectionClass($class))->getShortName());
144-
$opts[] = new TableSeparator();
145+
$options[$group][] = sprintf('<info>%s</info>', (new \ReflectionClass($class))->getShortName());
146+
$options[$group][] = new TableSeparator();
145147

146148
sort($opt);
147149
$sorted = true;
148-
$opts = array_merge($opts, $opt);
150+
$options[$group] = array_merge($options[$group], $opt);
149151
}
150152

151153
if (!$sorted) {
152-
sort($opts);
154+
sort($options[$group]);
153155
}
154156
}
155157

src/Symfony/Component/Form/Tests/Console/Descriptor/AbstractDescriptorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function getDescribeResolvedFormTypeTestData()
8484
$parent = new ResolvedFormType(new FormType(), $typeExtensions);
8585

8686
yield array(new ResolvedFormType(new ChoiceType(), array(), $parent), array('decorated' => false), 'resolved_form_type_1');
87+
yield array(new ResolvedFormType(new FormType()), array('decorated' => false), 'resolved_form_type_2');
8788
}
8889

8990
public function getDescribeOptionTestData()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"class": "Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType",
3+
"block_prefix": "form",
4+
"options": {
5+
"own": [
6+
"action",
7+
"attr",
8+
"auto_initialize",
9+
"block_name",
10+
"by_reference",
11+
"compound",
12+
"data",
13+
"data_class",
14+
"disabled",
15+
"empty_data",
16+
"error_bubbling",
17+
"inherit_data",
18+
"label",
19+
"label_attr",
20+
"label_format",
21+
"mapped",
22+
"method",
23+
"post_max_size_message",
24+
"property_path",
25+
"required",
26+
"translation_domain",
27+
"trim",
28+
"upload_max_size_message"
29+
],
30+
"overridden": [],
31+
"parent": [],
32+
"extension": [],
33+
"required": []
34+
},
35+
"parent_types": [],
36+
"type_extensions": []
37+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
Symfony\Component\Form\Extension\Core\Type\FormType (Block prefix: "form")
3+
==========================================================================
4+
5+
-------------------------
6+
Options
7+
-------------------------
8+
action
9+
attr
10+
auto_initialize
11+
block_name
12+
by_reference
13+
compound
14+
data
15+
data_class
16+
disabled
17+
empty_data
18+
error_bubbling
19+
inherit_data
20+
label
21+
label_attr
22+
label_format
23+
mapped
24+
method
25+
post_max_size_message
26+
property_path
27+
required
28+
translation_domain
29+
trim
30+
upload_max_size_message
31+
-------------------------
32+

0 commit comments

Comments
 (0)