Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2641778

Browse filesBrowse files
Florian-Merlenicolas-grekas
authored andcommitted
[FrameworkBundle] Always display service arguments & deprecate --show-arguments option for debug:container
1 parent 3766937 commit 2641778
Copy full SHA for 2641778
Expand file treeCollapse file tree

40 files changed

+390
-75
lines changed

‎UPGRADE-7.3.md

Copy file name to clipboardExpand all lines: UPGRADE-7.3.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ FrameworkBundle
1313

1414
* Not setting the `framework.property_info.with_constructor_extractor` option explicitly is deprecated
1515
because its default value will change in version 8.0
16+
* Deprecate the `--show-arguments` option of the `container:debug` command, as arguments are now always shown
1617

1718
Serializer
1819
----------

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* Rename `TranslationUpdateCommand` to `TranslationExtractCommand`
99
* Add JsonEncoder services and configuration
1010
* Add new `framework.property_info.with_constructor_extractor` option to allow enabling or disabling the constructor extractor integration
11+
* Deprecate the `--show-arguments` option of the `container:debug` command, as arguments are now always shown
1112

1213
7.2
1314
---

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
151151
$tag = $this->findProperTagName($input, $errorIo, $object, $tag);
152152
$options = ['tag' => $tag];
153153
} elseif ($name = $input->getArgument('name')) {
154+
if ($input->getOption('show-arguments')) {
155+
$errorIo->warning('The "--show-arguments" option is deprecated.');
156+
}
157+
154158
$name = $this->findProperServiceName($input, $errorIo, $object, $name, $input->getOption('show-hidden'));
155159
$options = ['id' => $name];
156160
} elseif ($input->getOption('deprecations')) {
@@ -161,7 +165,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
161165

162166
$helper = new DescriptorHelper();
163167
$options['format'] = $input->getOption('format');
164-
$options['show_arguments'] = $input->getOption('show-arguments');
165168
$options['show_hidden'] = $input->getOption('show-hidden');
166169
$options['raw_text'] = $input->getOption('raw');
167170
$options['output'] = $io;

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
+11-14Lines changed: 11 additions & 14 deletions
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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
+2-5Lines changed: 2 additions & 5 deletions
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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
+1-2Lines changed: 1 addition & 2 deletions
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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
+14-16Lines changed: 14 additions & 16 deletions
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->item(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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php
+2-2Lines changed: 2 additions & 2 deletions
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 = [];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.