8000 [FrameworkBundle] debug:container make --show-arguments noop · symfony/symfony@c090137 · GitHub
[go: up one dir, main page]

Skip to content

Commit c090137

Browse files
committed
[FrameworkBundle] debug:container make --show-arguments noop
1 parent 91d7211 commit c090137

37 files changed

+366
-75
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
165165

166166
$helper = new DescriptorHelper();
167167
$options['format'] = $input->getOption('format');
168-
$options['show_arguments'] = $input->getOption('show-arguments');
169168
$options['show_hidden'] = $input->getOption('show-hidden');
170169
$options['raw_text'] = $input->getOption('raw');
171170
$options['output'] = $io;

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php

+11-14
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function describeContainerTags(ContainerBuilder $container, array $opt
6363
foreach ($this->findDefinitionsByTag($container, $showHidden) as $tag => $definitions) {
6464
$data[$tag] = [];
6565
foreach ($definitions as $definition) {
66-
$data[$tag][] = $this->getContainerDefinitionData($definition, true, false, $container, $options['id'] ?? null);
66+
$data[$tag][] = $this->getContainerDefinitionData($definition, true, $container, $options['id'] ?? null);
6767
}
6868
}
6969

@@ -79,7 +79,7 @@ protected function describeContainerService(object $service, array $options = []
7979
if ($service instanceof Alias) {
8080
$this->describeContainerAlias($service, $options, $container);
8181
} elseif ($service instanceof Definition) {
82-
$this->writeData($this->getContainerDefinitionData($service, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $container, $options['id']), $options);
82+
$this->writeData($this->getContainerDefinitionData($service, isset($options['omit_tags']) && $options['omit_tags'], $container, $options['id']), $options);
8383
} else {
8484
$this->writeData($service::class, $options);
8585
}
@@ -92,7 +92,6 @@ protected function describeContainerServices(ContainerBuilder $container, array
9292
: $this->sortServiceIds($container->getServiceIds());
9393
$showHidden = isset($options['show_hidden']) && $options['show_hidden'];
9494
$omitTags = isset($options['omit_tags']) && $options['omit_tags'];
95-
$showArguments = isset($options['show_arguments']) && $options['show_arguments'];
9695
$data = ['definitions' => [], 'aliases' => [], 'services' => []];
9796

9897
if (isset($options['filter'])) {
@@ -112,7 +111,7 @@ protected function describeContainerServices(ContainerBuilder $container, array
112111
if ($service->hasTag('container.excluded')) {
113112
continue;
114113
}
115-
$data['definitions'][$serviceId] = $this->getContainerDefinitionData($service, $omitTags, $showArguments, $container, $serviceId);
114+
$data['definitions'][$serviceId] = $this->getContainerDefinitionData($service, $omitTags, $container, $serviceId);
116115
} else {
117116
$data['services'][$serviceId] = $service::class;
118117
}
@@ -123,7 +122,7 @@ protected function describeContainerServices(ContainerBuilder $container, array
123122

124123
protected function describeContainerDefinition(Definition $definition, array $options = [], ?ContainerBuilder $container = null): void
125124
{
126-
$this->writeData($this->getContainerDefinitionData($definition, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $container, $options['id'] ?? null), $options);
125+
$this->writeData($this->getContainerDefinitionData($definition, isset($options['omit_tags']) && $options['omit_tags'], $container, $options['id'] ?? null), $options);
127126
}
128127

129128
protected function describeContainerAlias(Alias $alias, array $options = [], ?ContainerBuilder $container = null): void
@@ -135,7 +134,7 @@ protected function describeContainerAlias(Alias $alias, array $options = [], ?Co
135134
}
136135

137136
$this->writeData(
138-
[$this->getContainerAliasData($alias), $this->getContainerDefinitionData($container->getDefinition((string) $alias), isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $container, (string) $alias)],
137+
[$this->getContainerAliasData($alias), $this->getContainerDefinitionData($container->getDefinition((string) $alias), isset($options['omit_tags']) && $options['omit_tags'], $container, (string) $alias)],
139138
array_merge($options, ['id' => (string) $alias])
140139
);
141140
}
@@ -245,7 +244,7 @@ protected function sortParameters(ParameterBag $parameters): array
245244
return $sortedParameters;
246245
}
247246

248-
private function getContainerDefinitionData(Definition $definition, bool $omitTags = false, bool $showArguments = false, ?ContainerBuilder $container = null, ?string $id = null): array
247+
private function getContainerDefinitionData(Definition $definition, bool $omitTags = false, ?ContainerBuilder $container = null, ?string $id = null): array
249248
{
250249
$data = [
251250
'class' => (string) $definition->getClass(),
@@ -269,9 +268,7 @@ private function getContainerDefinitionData(Definition $definition, bool $omitTa
269268
$data['description'] = $classDescription;
270269
}
271270

272-
if ($showArguments) {
273-
$data['arguments'] = $this->describeValue($definition->getArguments(), $omitTags, $showArguments, $container, $id);
274-
}
271+
$data['arguments'] = $this->describeValue($definition->getArguments(), $omitTags, $container, $id);
275272

276273
$data['file'] = $definition->getFile();
277274

@@ -418,12 +415,12 @@ private function getCallableData(mixed $callable): array
418415
throw new \InvalidArgumentException('Callable is not describable.');
419416
}
420417

421-
private function describeValue($value, bool $omitTags, bool $showArguments, ?ContainerBuilder $container = null, ?string $id = null): mixed
418+
private function describeValue($value, bool $omitTags, ?ContainerBuilder $container = null, ?string $id = null): mixed
422419
{
423420
if (\is_array($value)) {
424421
$data = [];
425422
foreach ($value as $k => $v) {
426-
$data[$k] = $this->describeValue($v, $omitTags, $showArguments, $container, $id);
423+
$data[$k] = $this->describeValue($v, $omitTags, $container, $id);
427424
}
428425

429426
return $data;
@@ -445,11 +442,11 @@ private function describeValue($value, bool $omitTags, bool $showArguments, ?Con
445442
}
446443

447444
if ($value instanceof ArgumentInterface) {
448-
return $this->describeValue($value->getValues(), $omitTags, $showArguments, $container, $id);
445+
return $this->describeValue($value->getValues(), $omitTags, $container, $id);
449446
}
450447

451448
if ($value instanceof Definition) {
452-
return $this->getContainerDefinitionData($value, $omitTags, $showArguments, $container, $id);
449+
return $this->getContainerDefinitionData($value, $omitTags, $container, $id);
453450
}
454451

455452
return $value;

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ protected function describeContainerServices(ContainerBuilder $container, array
155155
$serviceIds = isset($options['tag']) && $options['tag']
156156
? $this->sortTaggedServicesByPriority($container->findTaggedServiceIds($options['tag']))
157157
: $this->sortServiceIds($container->getServiceIds());
158-
$showArguments = isset($options['show_arguments']) && $options['show_arguments'];
159158
$services = ['definitions' => [], 'aliases' => [], 'services' => []];
160159

161160
if (isset($options['filter'])) {
@@ -185,7 +184,7 @@ protected function describeContainerServices(ContainerBuilder $container, array
185184
$this->write("\n\nDefinitions\n-----------\n");
186185
foreach ($services['definitions'] as $id => $service) {
187186
$this->write("\n");
188-
$this->describeContainerDefinition($service, ['id' => $id, 'show_arguments' => $showArguments], $container);
187+
$this->describeContainerDefinition($service, ['id' => $id], $container);
189188
}
190189
}
191190

@@ -231,9 +230,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
231230
$output .= "\n".'- Deprecated: no';
232231
}
233232

234-
if (isset($options['show_arguments']) && $options['show_arguments']) {
235-
$output .= "\n".'- Arguments: '.($definition->getArguments() ? 'yes' : 'no');
236-
}
233+
$output .= "\n".'- Arguments: '.($definition->getArguments() ? 'yes' : 'no');
237234

238235
if ($definition->getFile()) {
239236
$output .= "\n".'- File: `'.$definition->getFile().'`';

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,8 @@ protected function describeContainerDefinition(Definition $definition, array $op
351351
}
352352
}
353353

354-
$showArguments = isset($options['show_arguments']) && $options['show_arguments'];
355354
$argumentsInformation = [];
356-
if ($showArguments && ($arguments = $definition->getArguments())) {
355+
if ($arguments = $definition->getArguments()) {
357356
foreach ($arguments as $argument) {
358357
if ($argument instanceof ServiceClosureArgument) {
359358
$argument = $argument->getValues()[0];

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php

+14-16
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ protected function describeContainerService(object $service, array $options = []
5959
throw new \InvalidArgumentException('An "id" option must be provided.');
6060
}
6161

62-
$this->writeDocument($this->getContainerServiceDocument($service, $options['id'], $container, isset($options['show_arguments']) && $options['show_arguments']));
62+
$this->writeDocument($this->getContainerServiceDocument($service, $options['id'], $container));
6363
}
6464

6565
protected function describeContainerServices(ContainerBuilder $container, array $options = []): void
6666
{
67-
$this->writeDocument($this->getContainerServicesDocument($container, $options['tag'] ?? null, isset($options['show_hidden']) && $options['show_hidden'], isset($options['show_arguments']) && $options['show_arguments'], $options['filter'] ?? null));
67+
$this->writeDocument($this->getContainerServicesDocument($container, $options['tag'] ?? null, isset($options['show_hidden']) && $options['show_hidden'], $options['filter'] ?? null));
6868
}
6969

7070
protected function describeContainerDefinition(Definition $definition, array $options = [], ?ContainerBuilder $container = null): void
7171
{
72-
$this->writeDocument($this->getContainerDefinitionDocument($definition, $options['id'] ?? null, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $container));
72+
$this->writeDocument($this->getContainerDefinitionDocument($definition, $options['id'] ?? null, isset($options['omit_tags']) && $options['omit_tags'], $container));
7373
}
7474

7575
protected function describeContainerAlias(Alias $alias, array $options = [], ?ContainerBuilder $container = null): void
@@ -83,7 +83,7 @@ protected function describeContainerAlias(Alias $alias, array $options = [], ?Co
8383
return;
8484
}
8585

86-
$dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($container->getDefinition((string) $alias), (string) $alias, false, false, $container)->childNodes->item(0), true));
86+
$dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($container->getDefinition((string) $alias), (string) $alias, false, $container)->childNodes->i 10000 tem(0), true));
8787

8888
$this->writeDocument($dom);
8989
}
@@ -260,25 +260,25 @@ private function getContainerTagsDocument(ContainerBuilder $container, bool $sho
260260
$tagXML->setAttribute('name', $tag);
261261

262262
foreach ($definitions as $serviceId => $definition) {
263-
$definitionXML = $this->getContainerDefinitionDocument($definition, $serviceId, true, false, $container);
263+
$definitionXML = $this->getContainerDefinitionDocument($definition, $serviceId, true, $container);
264264
$tagXML->appendChild($dom->importNode($definitionXML->childNodes->item(0), true));
265265
}
266266
}
267267

268268
return $dom;
269269
}
270270

271-
private function getContainerServiceDocument(object $service, string $id, ?ContainerBuilder $container = null, bool $showArguments = false): \DOMDocument
271+
private function getContainerServiceDocument(object $service, string $id, ?ContainerBuilder $container = null): \DOMDocument
272272
{
273273
$dom = new \DOMDocument('1.0', 'UTF-8');
274274

275275
if ($service instanceof Alias) {
276276
$dom->appendChild($dom->importNode($this->getContainerAliasDocument($service, $id)->childNodes->item(0), true));
277277
if ($container) {
278-
$dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($container->getDefinition((string) $service), (string) $service, false, $showArguments, $container)->childNodes->item(0), true));
278+
$dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($container->getDefinition((string) $service), (string) $service, false, $container)->childNodes->item(0), true));
279279
}
280280
} elseif ($service instanceof Definition) {
281-
$dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($service, $id, false, $showArguments, $container)->childNodes->item(0), true));
281+
$dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($service, $id, false, $container)->childNodes->item(0), true));
282282
} else {
283283
$dom->appendChild($serviceXML = $dom->createElement('service'));
284284
$serviceXML->setAttribute('id', $id);
@@ -288,7 +288,7 @@ private function getContainerServiceDocument(object $service, string $id, ?Conta
288288
return $dom;
289289
}
290290

291-
private function getContainerServicesDocument(ContainerBuilder $container, ?string $tag = null, bool $showHidden = false, bool $showArguments = false, ?callable $filter = null): \DOMDocument
291+
private function getContainerServicesDocument(ContainerBuilder $container, ?string $tag = null, bool $showHidden = false, ?callable $filter = null): \DOMDocument
292292
{
293293
$dom = new \DOMDocument('1.0', 'UTF-8');
294294
$dom->appendChild($containerXML = $dom->createElement('container'));
@@ -311,14 +311,14 @@ private function getContainerServicesDocument(ContainerBuilder $container, ?stri
311311
continue;
312312
}
313313

314-
$serviceXML = $this->getContainerServiceDocument($service, $serviceId, null, $showArguments);
314+
$serviceXML = $this->getContainerServiceDocument($service, $serviceId, null);
315315
$containerXML->appendChild($containerXML->ownerDocument->importNode($serviceXML->childNodes->item(0), true));
316316
}
317317

318318
return $dom;
319319
}
320320

321-
private function getContainerDefinitionDocument(Definition $definition, ?string $id = null, bool $omitTags = false, bool $showArguments = false, ?ContainerBuilder $container = null): \DOMDocument
321+
private function getContainerDefinitionDocument(Definition $definition, ?string $id = null, bool $omitTags = false, ?ContainerBuilder $container = null): \DOMDocument
322322
{
323323
$dom = new \DOMDocument('1.0', 'UTF-8');
324324
$dom->appendChild($serviceXML = $dom->createElement('definition'));
@@ -378,10 +378,8 @@ private function getContainerDefinitionDocument(Definition $definition, ?string
378378
}
379379
}
380380

381-
if ($showArguments) {
382-
foreach ($this->getArgumentNodes($definition->getArguments(), $dom, $container) as $node) {
383-
$serviceXML->appendChild($node);
384-
}
381+
foreach ($this->getArgumentNodes($definition->getArguments(), $dom, $container) as $node) {
382+
$serviceXML->appendChild($node);
385383
}
386384

387385
if (!$omitTags) {
@@ -443,7 +441,7 @@ private function getArgumentNodes(array $arguments, \DOMDocument $dom, ?Containe
443441
$argumentXML->appendChild($childArgumentXML);
444442
}
445443
} elseif ($argument instanceof Definition) {
446-
$argumentXML->appendChild($dom->importNode($this->getContainerDefinitionDocument($argument, null, false, true, $container)->childNodes->item(0), true));
444+
$argumentXML->appendChild($dom->importNode($this->getContainerDefinitionDocument($argument, null, false, $container)->childNodes->item(0), true));
447445
} elseif ($argument instanceof AbstractArgument) {
448446
$argumentXML->setAttribute('type', 'abstract');
449447
$argumentXML->appendChild(new \DOMText($argument->getText()));

src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static function getDescribeContainerDefinitionTestData(): array
110110
/** @dataProvider getDescribeContainerDefinitionWithArgumentsShownTestData */
111111
public function testDescribeContainerDefinitionWithArgumentsShown(Definition $definition, $expectedDescription)
112112
{
113-
$this->assertDescription($expectedDescription, $definition, ['show_arguments' => true]);
113+
$this->assertDescription($expectedDescription, $definition, []);
114114
}
115115

116116
public static function getDescribeContainerDefinitionWithArgumentsShownTestData(): array
@@ -307,7 +307,7 @@ private static function getContainerBuilderDescriptionTestData(array $objects):
307307
'public' => ['show_hidden' => false],
308308
'tag1' => ['show_hidden' => true, 'tag' => 'tag1'],
309309
'tags' => ['group_by' => 'tags', 'show_hidden' => true],
310-
'arguments' => ['show_hidden' => false, 'show_arguments' => true],
310+
'arguments' => ['show_hidden' => false],
311311
];
312312

313313
$data = [];

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.json

+65
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,71 @@
1313
"autowire": false,
1414
"autoconfigure": false,
1515
"deprecated": false,
16+
"arguments": [
17+
{
18+
"type": "service",
19+
"id": ".definition_2"
20+
},
21+
"%parameter%",
22+
{
23+
"class": "inline_service",
24+
"public": false,
25+
"synthetic": false,
26+
"lazy": false,
27+
"shared": true,
28+
"abstract": false,
29+
"autowire": false,
30+
"autoconfigure": false,
31+
"deprecated": false,
32+
"arguments": [
33+
"arg1",
34+
"arg2"
35+
],
36+
"file": null,
37+
"tags": [],
38+
"usages": [
39+
"alias_1"
40+
]
41+
},
42+
[
43+
"foo",
44+
{
45+
"type": "service",
46+
"id": ".definition_2"
47+
},
48+
{
49+
"class": "inline_service",
50+
"public": false,
51+
"synthetic": false,
52+
"lazy": false,
53+
"shared": true,
54+
"abstract": false,
55+
"autowire": false,
56+
"autoconfigure": false,
57+
"deprecated": false,
58+
"arguments": [],
59+
"file": null,
60+
"tags": [],
61+
"usages": [
62+
"alias_1"
63+
]
64+
}
65+
],
66+
[
67+
{
68+
"type": "service",
69+
"id": "definition_1"
70+
},
71+
{
72+
"type": "service",
73+
"id": ".definition_2"
74+
}
75+
],
76+
{
77+
"type": "abstract",
78+
"text": "placeholder"
79+
}
80+
],
1681
"file": null,
1782
"factory_class": "Full\\Qualified\\FactoryClass",
1883
"factory_method": "get",

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Autowired: no
1515
- Autoconfigured: no
1616
- Deprecated: no
17+
- Arguments: yes
1718
- Factory Class: `Full\Qualified\FactoryClass`
1819
- Factory Method: `get`
1920
- Usages: alias_1

0 commit comments

Comments
 (0)
0