Skip to content

Commit

Permalink
[DI] Show number of elements in non debug mode even for empty iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
jschaedl committed May 3, 2019
1 parent 79ebf28 commit 7e71b96
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Expand Up @@ -137,6 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$options['show_arguments'] = $input->getOption('show-arguments');
$options['raw_text'] = $input->getOption('raw');
$options['output'] = $io;
$options['is_debug'] = $this->getApplication()->getKernel()->isDebug();
$helper->describe($io, $object, $options);

if (!$input->getArgument('name') && !$input->getOption('tag') && !$input->getOption('parameter') && $input->isInteractive()) {
Expand Down
Expand Up @@ -341,9 +341,9 @@ protected function describeContainerDefinition(Definition $definition, array $op
$argumentsInformation[] = sprintf('Service(%s)', (string) $argument);
} elseif ($argument instanceof IteratorArgument) {
if ($argument instanceof TaggedIteratorArgument) {
$argumentsInformation[] = sprintf('Tagged Iterator for "%s"', $argument->getTag());
$argumentsInformation[] = sprintf('Tagged Iterator for "%s" %s', $argument->getTag(), !$options['is_debug'] ? sprintf('(%d element(s))', \count($argument->getValues())) : '');
} else {
$argumentsInformation[] = empty($argument->getValues()) ? 'Iterator' : sprintf('Iterator (%d element(s))', \count($argument->getValues()));
$argumentsInformation[] = $options['is_debug'] ? 'Iterator' : sprintf('Iterator (%d element(s))', \count($argument->getValues()));
}
} elseif ($argument instanceof Definition) {
$argumentsInformation[] = 'Inlined Service';
Expand Down
Expand Up @@ -182,6 +182,7 @@ abstract protected function getFormat();

private function assertDescription($expectedDescription, $describedObject, array $options = [])
{
$options['is_debug'] = false;
$options['raw_output'] = true;
$options['raw_text'] = true;
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
Expand Down

0 comments on commit 7e71b96

Please sign in to comment.