Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f848e4

Browse files
committed
[FrameworkBundle] add class description to debug:container command
1 parent dd2f830 commit 8f848e4

31 files changed

+78
-1
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
1313

14+
use phpDocumentor\Reflection\DocBlockFactory;
15+
use ReflectionClass;
16+
use ReflectionException;
1417
use Symfony\Component\DependencyInjection\Alias;
1518
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
1619
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
@@ -209,7 +212,15 @@ protected function getRouteData(Route $route)
209212

210213
private function getContainerDefinitionData(Definition $definition, bool $omitTags = false, bool $showArguments = false): array
211214
{
215+
try {
216+
$reflectionProperty = new ReflectionClass($definition->getClass());
217+
$classDescription = DocBlockFactory::createInstance()->create($reflectionProperty->getDocComment())->getSummary();
218+
} catch (ReflectionException $e) {
219+
$classDescription = null;
220+
}
221+
212222
$data = array(
223+
'description' => $classDescription,
213224
'class' => (string) $definition->getClass(),
214225
'public' => $definition->isPublic() && !$definition->isPrivate(),
215226
'synthetic' => $definition->isSynthetic(),

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
1313

14+
use phpDocumentor\Reflection\DocBlockFactory;
15+
use ReflectionClass;
16+
use ReflectionException;
1417
use Symfony\Component\DependencyInjection\Alias;
1518
use Symfony\Component\DependencyInjection\ContainerBuilder;
1619
use Symfony\Component\DependencyInjection\Definition;
@@ -181,7 +184,15 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
181184
*/
182185
protected function describeContainerDefinition(Definition $definition, array $options = array())
183186
{
184-
$output = '- Class: `'.$definition->getClass().'`'
187+
try {
188+
$reflectionProperty = new ReflectionClass($definition->getClass());
189+
$classDescription = DocBlockFactory::createInstance()->create($reflectionProperty->getDocComment())->getSummary();
190+
} catch (ReflectionException $e) {
191+
$classDescription = '-';
192+
}
193+
194+
$output = '- Description: `'.$classDescription.'`'
195+
."\n".'- Class: `'.$definition->getClass().'`'
185196
."\n".'- Public: '.($definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no')
186197
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no')
187198
."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no')

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
1313

14+
use phpDocumentor\Reflection\DocBlockFactory;
15+
use ReflectionClass;
16+
use ReflectionException;
1417
use Symfony\Component\Console\Formatter\OutputFormatter;
1518
use Symfony\Component\Console\Helper\Table;
1619
use Symfony\Component\Console\Style\SymfonyStyle;
@@ -260,6 +263,14 @@ protected function describeContainerDefinition(Definition $definition, array $op
260263
$options['output']->title(sprintf('Information for Service "<info>%s</info>"', $options['id']));
261264
}
262265

266+
try {
267+
$reflectionProperty = new ReflectionClass($definition->getClass());
268+
$classDescription = DocBlockFactory::createInstance()->create($reflectionProperty->getDocComment())->getSummary();
269+
} catch (ReflectionException $e) {
270+
$classDescription = '-';
271+
}
272+
$options['output']->text($classDescription."\n");
273+
263274
$tableHeaders = array('Option', 'Value');
264275

265276
$tableRows[] = array('Service ID', isset($options['id']) ? $options['id'] : '-');

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"public": true
55
},
66
{
7+
"description": null,
78
"class": "Full\\Qualified\\Class1",
89
"public": true,
910
"synthetic": false,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
### service_1
77

8+
- Description: `-`
89
- Class: `Full\Qualified\Class1`
910
- Public: yes
1011
- Synthetic: no

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Information for Service "service_1"
44
===================================
55

6+
-
7+
68
---------------- -----------------------------
79
 Option   Value 
810
---------------- -----------------------------

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"public": false
55
},
66
{
7+
"description": null,
78
"class": "Full\\Qualified\\Class2",
89
"public": false,
910
"synthetic": true,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
### .service_2
77

8+
- Description: `-`
89
- Class: `Full\Qualified\Class2`
910
- Public: no
1011
- Synthetic: yes

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Information for Service ".service_2"
44
====================================
55

6+
-
7+
68
----------------- ---------------------------------
79
 Option   Value 
810
----------------- ---------------------------------

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"definitions": {
33
"definition_1": {
4+
"description": null,
45
"class": "Full\\Qualified\\Class1",
56
"public": true,
67
"synthetic": false,
@@ -16,6 +17,7 @@
1617
},
1718
"%parameter%",
1819
{
20+
"description": null,
1921
"class": "inline_service",
2022
"public": false,
2123
"synthetic": false,
@@ -38,6 +40,7 @@
3840
"id": ".definition_2"
3941
},
4042
{
43+
"description": null,
4144
"class": "inline_service",
4245
"public": false,
4346
"synthetic": false,
@@ -68,6 +71,7 @@
6871
"tags": []
6972
},
7073
"service_container": {
74+
"description": "ContainerInterface is the interface implemented by service container classes.",
7175
"class": "Symfony\\Component\\DependencyInjection\\ContainerInterface",
7276
"public": true,
7377
"synthetic": true,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Definitions
66

77
### definition_1
88

9+
- Description: `-`
910
- Class: `Full\Qualified\Class1`
1011
- Public: yes
1112
- Synthetic: no
@@ -20,6 +21,7 @@ Definitions
2021

2122
### service_container
2223

24+
- Description: `ContainerInterface is the interface implemented by service container classes.`
2325
- Class: `Symfony\Component\DependencyInjection\ContainerInterface`
2426
- Public: yes
2527
- Synthetic: yes

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"definitions": {
33
"definition_1": {
4+
"description": null,
45
"class": "Full\\Qualified\\Class1",
56
"public": true,
67
"synthetic": false,
@@ -15,6 +16,7 @@
1516
"tags": []
1617
},
1718
"service_container": {
19+
"description": "ContainerInterface is the interface implemented by service container classes.",
1820
"class": "Symfony\\Component\\DependencyInjection\\ContainerInterface",
1921
"public": true,
2022
"synthetic": true,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Definitions
66

77
### definition_1
88

9+
- Description: `-`
910
- Class: `Full\Qualified\Class1`
1011
- Public: yes
1112
- Synthetic: no
@@ -19,6 +20,7 @@ Definitions
1920

2021
### service_container
2122

23+
- Description: `ContainerInterface is the interface implemented by service container classes.`
2224
- Class: `Symfony\Component\DependencyInjection\ContainerInterface`
2325
- Public: yes
2426
- Synthetic: yes

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"definitions": {
33
".definition_2": {
4+
"description": null,
45
"class": "Full\\Qualified\\Class2",
56
"public": false,
67
"synthetic": true,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Definitions
66

77
### .definition_2
88

9+
- Description: `-`
910
- Class: `Full\Qualified\Class2`
1011
- Public: no
1112
- Synthetic: yes

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"definitions": {
33
".definition_2": {
4+
"description": null,
45
"class": "Full\\Qualified\\Class2",
56
"public": false,
67
"synthetic": true,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Definitions
66

77
### .definition_2
88

9+
- Description: `-`
910
- Class: `Full\Qualified\Class2`
1011
- Public: no
1112
- Synthetic: yes

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"tag1": [
33
{
4+
"description": null,
45
"class": "Full\\Qualified\\Class2",
56
"public": false,
67
"synthetic": true,
@@ -19,6 +20,7 @@
1920
],
2021
"tag2": [
2122
{
23+
"description": null,
2224
"class": "Full\\Qualified\\Class2",
2325
"public": false,
2426
"synthetic": true,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ tag1
66

77
### .definition_2
88

9+
- Description: `-`
910
- Class: `Full\Qualified\Class2`
1011
- Public: no
1112
- Synthetic: yes
@@ -25,6 +26,7 @@ tag2
2526

2627
### .definition_2
2728

29+
- Description: `-`
2830
- Class: `Full\Qualified\Class2`
2931
- Public: no
3032
- Synthetic: yes

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"description": null,
23
"class": "Full\\Qualified\\Class1",
34
"public": true,
45
"synthetic": false,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Description: `-`
12
- Class: `Full\Qualified\Class1`
23
- Public: yes
34
- Synthetic: no

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-
2+
13
---------------- -----------------------------
24
 Option   Value 
35
---------------- -----------------------------

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"description": null,
23
"class": "Full\\Qualified\\Class2",
34
"public": false,
45
"synthetic": true,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Description: `-`
12
- Class: `Full\Qualified\Class2`
23
- Public: no
34
- Synthetic: yes

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-
2+
13
----------------- ---------------------------------
24
 Option   Value 
35
----------------- ---------------------------------

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"description": null,
23
"class": "Full\\Qualified\\Class1",
34
"public": true,
45
"synthetic": false,
@@ -14,6 +15,7 @@
1415
},
1516
"%parameter%",
1617
{
18+
"description": null,
1719
"class": "inline_service",
1820
"public": false,
1921
"synthetic": false,
@@ -36,6 +38,7 @@
3638
"id": ".definition_2"
3739
},
3840
{
41+
"description": null,
3942
"class": "inline_service",
4043
"public": false,
4144
"synthetic": false,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Description: `-`
12
- Class: `Full\Qualified\Class1`
23
- Public: yes
34
- Synthetic: no

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-
2+
13
---------------- -----------------------------
24
 Option   Value 
35
---------------- -----------------------------

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"description": null,
23
"class": "Full\\Qualified\\Class2",
34
"public": false,
45
"synthetic": true,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Description: `-`
12
- Class: `Full\Qualified\Class2`
23
- Public: no
34
- Synthetic: yes

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-
2+
13
----------------- ---------------------------------
24
 Option   Value 
35
----------------- ---------------------------------

0 commit comments

Comments
 (0)