feature #31353 [FrameworkBundle] Show injected services for iterator and array arguments (jschaedl)
This PR was merged into the 4.3-dev branch.
Discussion
----------
[FrameworkBundle] Show injected services for iterator and array arguments
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? |no
| New feature? | yes<!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? |no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | #31340 <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | tbd.
When I have the following service configuration:
```yaml
App\Word\Checker\StaticWordChecker:
tags: [app.checker]
App\Word\Checker\BannedWorldListChecker:
tags: [app.checker]
App\Word\WordCheckerTaggedIterator:
arguments: [!tagged app.checker]
App\Word\WordCheckerArray:
arguments:
- App\Word\Checker\StaticWordChecker: ~
App\Word\Checker\BannedWorldListChecker: ~
```
and I run:
`./bin/console debug:container App\Word\WordCheckerArray --show-arguments`
```bash
Information for Service "App\Word\WordCheckerArray"
===================================================
---------------- -------------------------------------------
Option Value
---------------- -------------------------------------------
Service ID App\Word\WordCheckerArray
Class App\Word\WordCheckerArray
Tags -
Public no
Synthetic no
Lazy no
Shared yes
Abstract no
Autowired yes
Autoconfigured yes
Arguments Array (2 element(s))
- App\Word\Checker\StaticWordChecker
- App\Word\Checker\BannedWorldListChecker
---------------- -------------------------------------------
```
or
`./bin/console debug:container App\Word\WordCheckerTaggedIterator --show-arguments`
```bash
Information for Service "App\Word\WordCheckerTaggedIterator"
============================================================
---------------- -------------------------------------------
Option Value
---------------- -------------------------------------------
Service ID App\Word\WordCheckerTaggedIterator
Class App\Word\WordCheckerTaggedIterator
Tags -
Public no
Synthetic no
Lazy no
Shared yes
Abstract no
Autowired yes
Autoconfigured yes
Arguments Iterator (2 element(s))
- App\Word\Checker\BannedWorldListChecker
- App\Word\Checker\StaticWordChecker
---------------- -------------------------------------------
```
I can now see the the objects injected into the iterator and array arguments.
Commits
-------
db5fb200ce
[FrameworkBundle] Show injected services for Iterator and Array
This commit is contained in:
commit
26e1d8948e
@ -348,12 +348,20 @@ class TextDescriptor extends Descriptor
|
|||||||
$argumentsInformation[] = sprintf('Service(%s)', (string) $argument);
|
$argumentsInformation[] = sprintf('Service(%s)', (string) $argument);
|
||||||
} elseif ($argument instanceof IteratorArgument) {
|
} elseif ($argument instanceof IteratorArgument) {
|
||||||
$argumentsInformation[] = sprintf('Iterator (%d element(s))', \count($argument->getValues()));
|
$argumentsInformation[] = sprintf('Iterator (%d element(s))', \count($argument->getValues()));
|
||||||
|
foreach (array_map(function (Reference $value) {return (string) $value; }, $argument->getValues()) as $service) {
|
||||||
|
$argumentsInformation[] = sprintf('- %s', $service);
|
||||||
|
}
|
||||||
} elseif ($argument instanceof ServiceLocatorArgument) {
|
} elseif ($argument instanceof ServiceLocatorArgument) {
|
||||||
$argumentsInformation[] = sprintf('Service locator (%d element(s))', \count($argument->getValues()));
|
$argumentsInformation[] = sprintf('Service locator (%d element(s))', \count($argument->getValues()));
|
||||||
} elseif ($argument instanceof Definition) {
|
} elseif ($argument instanceof Definition) {
|
||||||
$argumentsInformation[] = 'Inlined Service';
|
$argumentsInformation[] = 'Inlined Service';
|
||||||
} else {
|
} else {
|
||||||
$argumentsInformation[] = \is_array($argument) ? sprintf('Array (%d element(s))', \count($argument)) : $argument;
|
$argumentsInformation[] = \is_array($argument) ? sprintf('Array (%d element(s))', \count($argument)) : $argument;
|
||||||
|
if (\is_array($argument)) {
|
||||||
|
foreach (array_keys($argument) as $service) {
|
||||||
|
$argumentsInformation[] = sprintf('- %s', $service);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
[39;49m [39;49m[39;49m%parameter%[39;49m[39;49m [39;49m
|
[39;49m [39;49m[39;49m%parameter%[39;49m[39;49m [39;49m
|
||||||
[39;49m [39;49m[39;49mInlined Service[39;49m[39;49m [39;49m
|
[39;49m [39;49m[39;49mInlined Service[39;49m[39;49m [39;49m
|
||||||
[39;49m [39;49m[39;49mArray (3 element(s))[39;49m[39;49m [39;49m
|
[39;49m [39;49m[39;49mArray (3 element(s))[39;49m[39;49m [39;49m
|
||||||
[39;49m [39;49mIterator (2 element(s))
|
[39;49m [39;49m[39;49m- 0[39;49m[39;49m [39;49m
|
||||||
---------------- -----------------------------
|
[39;49m [39;49m[39;49m- 1[39;49m[39;49m [39;49m
|
||||||
|
[39;49m [39;49m[39;49m- 2[39;49m[39;49m [39;49m
|
||||||
|
[39;49m [39;49m[39;49mIterator (2 element(s))[39;49m[39;49m [39;49m
|
||||||
|
[39;49m [39;49m[39;49m- definition_1[39;49m[39;49m [39;49m
|
||||||
|
[39;49m [39;49m- .definition_2
|
||||||
|
---------------- -----------------------------
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user