|
15 | 15 | useSymfony\Component\Console\Helper\Dumper;
|
16 | 16 | useSymfony\Component\Console\Helper\Table;
|
17 | 17 | useSymfony\Component\Console\Helper\TableCell;
|
| 18 | +useSymfony\Component\Console\Helper\TableSeparator; |
18 | 19 | useSymfony\Component\Console\Style\SymfonyStyle;
|
19 | 20 | useSymfony\Component\DependencyInjection\Alias;
|
20 | 21 | useSymfony\Component\DependencyInjection\Argument\AbstractArgument;
|
@@ -351,45 +352,104 @@ protected function describeContainerDefinition(Definition $definition, array $op
|
351 | 352 | }
|
352 | 353 | }
|
353 | 354 |
|
| 355 | +$inEdges =null !==$container &&isset($options['id']) ?$this->getServiceEdges($container,$options['id']) : []; |
| 356 | +$tableRows[] = ['Usages',$inEdges ?implode(\PHP_EOL,$inEdges) :'none']; |
| 357 | + |
| 358 | +$options['output']->table($tableHeaders,$tableRows); |
| 359 | + |
354 | 360 | $showArguments =isset($options['show_arguments']) &&$options['show_arguments'];
|
355 |
| -$argumentsInformation = []; |
| 361 | + |
356 | 362 | if ($showArguments && ($arguments =$definition->getArguments())) {
|
357 |
| -foreach ($argumentsas$argument) { |
358 |
| -if ($argumentinstanceof ServiceClosureArgument) { |
359 |
| -$argument =$argument->getValues()[0]; |
360 |
| - } |
| 363 | +$table =newTable($this->getOutput()); |
| 364 | +$table->setHeaderTitle('Arguments'); |
| 365 | +$table->setHeaders(['#','Service','Argument(s)']); |
| 366 | + |
| 367 | +foreach ($argumentsas$position =>$argument) { |
361 | 368 | if ($argumentinstanceof Reference) {
|
362 |
| -$argumentsInformation[] =\sprintf('Service(%s)', (string)$argument); |
| 369 | +if (null ===$container |
| 370 | + || !($argumentDefinition =$container->getDefinition($argument))->hasTag('container.service_locator') |
| 371 | + ) { |
| 372 | +$table->addRow([++$position,\sprintf('Service(%s)',$argument),'-']); |
| 373 | + }else { |
| 374 | +$argumentCollection =$argumentDefinition->getArguments()[0]; |
| 375 | +$description =\sprintf('Service locator (%d element(s))',\count($argumentCollection)); |
| 376 | + |
| 377 | +foreach ($argumentCollectionas$key =>$argumentUnit) { |
| 378 | +$argumentValue =$argumentUnit->getValues()[0]; |
| 379 | +$argumentDescription = !($argumentValueinstanceof Reference) ?json_encode($argumentValue) :$argumentValue; |
| 380 | + |
| 381 | +if (array_key_first($argumentCollection) ===$key) { |
| 382 | +$table->addRow([++$position,$description,$argumentDescription]); |
| 383 | + }else { |
| 384 | +$table->addRow(['','',$argumentDescription]); |
| 385 | + } |
| 386 | + } |
| 387 | + } |
363 | 388 | }elseif ($argumentinstanceof IteratorArgument) {
|
| 389 | +$argumentValues =$argument->getValues(); |
| 390 | + |
364 | 391 | if ($argumentinstanceof TaggedIteratorArgument) {
|
365 |
| -$argumentsInformation[] =\sprintf('Tagged Iterator for "%s"%s',$argument->getTag(),$options['is_debug'] ?'' :\sprintf(' (%d element(s))',\count($argument->getValues()))); |
| 392 | +if (null ===$container) { |
| 393 | +$description =\sprintf('Tagged Iterator for "%s"',$argument->getTag()); |
| 394 | + |
| 395 | +$table->addRow([++$position,$description,'-']); |
| 396 | + }else { |
| 397 | +$services =array_keys($container->findTaggedServiceIds($argument->getTag())); |
| 398 | +$description =\sprintf('Tagged Iterator for "%s"%s',$argument->getTag(),$options['is_debug'] ?'' :\sprintf(' (%d element(s))',\count($services))); |
| 399 | + |
| 400 | +foreach ($servicesas$order =>$ref) { |
| 401 | +if (array_key_first($services) ===$order) { |
| 402 | +$table->addRow([++$position,$description,$ref]); |
| 403 | + }else { |
| 404 | +$table->addRow(['','',$ref]); |
| 405 | + } |
| 406 | + } |
| 407 | + } |
366 | 408 | }else {
|
367 |
| -$argumentsInformation[] =\sprintf('Iterator (%d element(s))',\count($argument->getValues())); |
| 409 | +$description =\sprintf('Iterator (%d element(s))',\count($argumentValues)); |
| 410 | +$table->addRow([++$position,$description,'-']); |
368 | 411 | }
|
| 412 | + }elseif ($argumentinstanceof ServiceLocatorArgument) { |
| 413 | +if (null ===$container) { |
| 414 | +$description ='Service locator'; |
| 415 | + |
| 416 | +if (null ===$argument->getTaggedIteratorArgument()) { |
| 417 | +$description =\sprintf('Service locator (%d element(s))',\count($argument->getValues())); |
| 418 | + } |
369 | 419 |
|
370 |
| -foreach ($argument->getValues()as$ref) { |
371 |
| -$argumentsInformation[] =\sprintf('- Service(%s)',$ref); |
| 420 | +$table->addRow([++$position,$description,'-']); |
| 421 | + }else { |
| 422 | +$services =null !==$argument->getTaggedIteratorArgument() ?array_keys($container->findTaggedServiceIds($argument->getTaggedIteratorArgument()->getTag())) :$argument->getValues(); |
| 423 | +$description =\sprintf('Service locator (%d element(s))',\count($services)); |
| 424 | + |
| 425 | +foreach ($servicesas$order =>$ref) { |
| 426 | +if (array_key_first($services) ===$order) { |
| 427 | +$table->addRow([++$position,$description,$ref]); |
| 428 | + }else { |
| 429 | +$table->addRow(['','',$ref]); |
| 430 | + } |
| 431 | + } |
372 | 432 | }
|
373 |
| - }elseif ($argumentinstanceof ServiceLocatorArgument) { |
374 |
| -$argumentsInformation[] =\sprintf('Service locator (%d element(s))',\count($argument->getValues())); |
375 | 433 | }elseif ($argumentinstanceof Definition) {
|
376 |
| -$argumentsInformation[] ='Inlined Service'; |
| 434 | +$table->addRow([++$position,'Inlined Service','-']); |
377 | 435 | }elseif ($argumentinstanceof \UnitEnum) {
|
378 |
| -$argumentsInformation[] =ltrim(var_export($argument,true),'\\'); |
| 436 | +$table->addRow([++$position,ltrim(var_export($argument,true),'\\'),'-']); |
379 | 437 | }elseif ($argumentinstanceof AbstractArgument) {
|
380 |
| -$argumentsInformation[] =\sprintf('Abstract argument (%s)',$argument->getText()); |
| 438 | +$table->addRow([++$position,\sprintf('Abstract argument (%s)',$argument->getText()),'-']); |
| 439 | + }elseif ($argumentinstanceof ServiceClosureArgument) { |
| 440 | +$table->addRow([++$position,\sprintf('Closure argument (%s)',$argument->getValues()[0]),'-']); |
| 441 | + }elseif (\is_array($argument)) { |
| 442 | +$table->addRow([++$position,\sprintf('Array (%d element(s))',\count($argument)),'-']); |
381 | 443 | }else {
|
382 |
| -$argumentsInformation[] =\is_array($argument) ?\sprintf('Array (%d element(s))',\count($argument)) :$argument; |
| 444 | +$table->addRow([++$position,$argument,'-']); |
383 | 445 | }
|
384 |
| - } |
385 | 446 |
|
386 |
| -$tableRows[] = ['Arguments',implode("\n",$argumentsInformation)]; |
| 447 | +if (--$position !==array_key_last($arguments)) { |
| 448 | +$table->addRow(newTableSeparator()); |
| 449 | + } |
| 450 | + } |
| 451 | +$table->render(); |
387 | 452 | }
|
388 |
| - |
389 |
| -$inEdges =null !==$container &&isset($options['id']) ?$this->getServiceEdges($container,$options['id']) : []; |
390 |
| -$tableRows[] = ['Usages',$inEdges ?implode(\PHP_EOL,$inEdges) :'none']; |
391 |
| - |
392 |
| -$options['output']->table($tableHeaders,$tableRows); |
393 | 453 | }
|
394 | 454 |
|
395 | 455 | protectedfunctiondescribeContainerDeprecations(ContainerBuilder$container,array$options = []):void
|
|