Skip to content

Commit

Permalink
bug #30641 [FrameworkBundle] properly describe service definitions wi…
Browse files Browse the repository at this point in the history
…thout class (xabbuh)

This PR was merged into the 4.2 branch.

Discussion
----------

[FrameworkBundle] properly describe service definitions without class

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30638
| License       | MIT
| Doc PR        |

Commits
-------

e5b0fd37f6 properly describe service definitions without class
  • Loading branch information
fabpot committed Mar 26, 2019
2 parents 6c74c52 + abe024f commit f7962d0
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Console/Descriptor/JsonDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private function getContainerDefinitionData(Definition $definition, bool $omitTa
'autoconfigure' => $definition->isAutoconfigured(),
];

if ('' !== $classDescription = $this->getClassDescription($definition->getClass())) {
if ('' !== $classDescription = $this->getClassDescription((string) $definition->getClass())) {
$data['description'] = $classDescription;
}

Expand Down
2 changes: 1 addition & 1 deletion Console/Descriptor/MarkdownDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
{
$output = '';

if ('' !== $classDescription = $this->getClassDescription($definition->getClass())) {
if ('' !== $classDescription = $this->getClassDescription((string) $definition->getClass())) {
$output .= '- Description: `'.$classDescription.'`'."\n";
}

Expand Down
2 changes: 1 addition & 1 deletion Console/Descriptor/TextDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
$options['output']->title(sprintf('Information for Service "<info>%s</info>"', $options['id']));
}

if ('' !== $classDescription = $this->getClassDescription($definition->getClass())) {
if ('' !== $classDescription = $this->getClassDescription((string) $definition->getClass())) {
$options['output']->text($classDescription."\n");
}

Expand Down
2 changes: 1 addition & 1 deletion Console/Descriptor/XmlDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ private function getContainerDefinitionDocument(Definition $definition, string $
$serviceXML->setAttribute('id', $id);
}

if ('' !== $classDescription = $this->getClassDescription($definition->getClass())) {
if ('' !== $classDescription = $this->getClassDescription((string) $definition->getClass())) {
$serviceXML->appendChild($descriptionXML = $dom->createElement('description'));
$descriptionXML->appendChild($dom->createCDATASection($classDescription));
}
Expand Down
1 change: 1 addition & 0 deletions Tests/Console/Descriptor/ObjectsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public static function getContainerDefinitions()
->addTag('tag2')
->addMethodCall('setMailer', [new Reference('mailer')])
->setFactory([new Reference('factory.service'), 'get']),
'definition_without_class' => new Definition(),
];
}

Expand Down
13 changes: 13 additions & 0 deletions Tests/Fixtures/Descriptor/builder_1_arguments.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@
"factory_method": "get",
"tags": []
},
"definition_without_class": {
"class": "",
"public": false,
"synthetic": false,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": false,
"autoconfigure": false,
"arguments": [],
"file": null,
"tags": []
},
"service_container": {
"class": "Symfony\\Component\\DependencyInjection\\ContainerInterface",
"public": true,
Expand Down
12 changes: 12 additions & 0 deletions Tests/Fixtures/Descriptor/builder_1_arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ Definitions
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`

### definition_without_class

- Class: ``
- Public: no
- Synthetic: no
- Lazy: no
- Shared: yes
- Abstract: no
- Autowired: no
- Autoconfigured: no
- Arguments: no

### service_container

- Description: `ContainerInterface is the interface implemented by service container classes.`
Expand Down
15 changes: 8 additions & 7 deletions Tests/Fixtures/Descriptor/builder_1_arguments.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
Symfony Container Services
==========================

------------------- ----------------------------------------------------------
 Service ID   Class name 
------------------- ----------------------------------------------------------
alias_1 alias for "service_1"
definition_1 Full\Qualified\Class1
service_container Symfony\Component\DependencyInjection\ContainerInterface
------------------- ----------------------------------------------------------
-------------------------- ----------------------------------------------------------
 Service ID   Class name 
-------------------------- ----------------------------------------------------------
alias_1 alias for "service_1"
definition_1 Full\Qualified\Class1
definition_without_class
service_container Symfony\Component\DependencyInjection\ContainerInterface
-------------------------- ----------------------------------------------------------

1 change: 1 addition & 0 deletions Tests/Fixtures/Descriptor/builder_1_arguments.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<argument type="service" id=".definition_2"/>
</argument>
</definition>
<definition id="definition_without_class" class="" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/>
<definition id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="">
<description><![CDATA[ContainerInterface is the interface implemented by service container classes.]]></description>
</definition>
Expand Down
12 changes: 12 additions & 0 deletions Tests/Fixtures/Descriptor/builder_1_public.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
"factory_method": "get",
"tags": []
},
"definition_without_class": {
"class": "",
"public": false,
"synthetic": false,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": false,
"autoconfigure": false,
"file": null,
"tags": []
},
"service_container": {
"class": "Symfony\\Component\\DependencyInjection\\ContainerInterface",
"public": true,
Expand Down
11 changes: 11 additions & 0 deletions Tests/Fixtures/Descriptor/builder_1_public.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ Definitions
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`

### definition_without_class

- Class: ``
- Public: no
- Synthetic: no
- Lazy: no
- Shared: yes
- Abstract: no
- Autowired: no
- Autoconfigured: no

### service_container

- Description: `ContainerInterface is the interface implemented by service container classes.`
Expand Down
15 changes: 8 additions & 7 deletions Tests/Fixtures/Descriptor/builder_1_public.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
Symfony Container Services
==========================

------------------- ----------------------------------------------------------
 Service ID   Class name 
------------------- ----------------------------------------------------------
alias_1 alias for "service_1"
definition_1 Full\Qualified\Class1
service_container Symfony\Component\DependencyInjection\ContainerInterface
------------------- ----------------------------------------------------------
-------------------------- ----------------------------------------------------------
 Service ID   Class name 
-------------------------- ----------------------------------------------------------
alias_1 alias for "service_1"
definition_1 Full\Qualified\Class1
definition_without_class
service_container Symfony\Component\DependencyInjection\ContainerInterface
-------------------------- ----------------------------------------------------------

1 change: 1 addition & 0 deletions Tests/Fixtures/Descriptor/builder_1_public.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/>
</definition>
<definition id="definition_without_class" class="" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/>
<definition id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="">
<description><![CDATA[ContainerInterface is the interface implemented by service container classes.]]></description>
</definition>
Expand Down
13 changes: 13 additions & 0 deletions Tests/Fixtures/Descriptor/definition_arguments_without_class.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"class": "",
"public": false,
"synthetic": false,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": false,
"autoconfigure": false,
"arguments": [],
"file": null,
"tags": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Class: ``
- Public: no
- Synthetic: no
- Lazy: no
- Shared: yes
- Abstract: no
- Autowired: no
- Autoconfigured: no
- Arguments: no
15 changes: 15 additions & 0 deletions Tests/Fixtures/Descriptor/definition_arguments_without_class.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---------------- -------
 Option   Value 
---------------- -------
Service ID -
Class -
Tags -
Public no
Synthetic no
Lazy no
Shared yes
Abstract no
Autowired no
Autoconfigured no
---------------- -------

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<definition class="" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/>
12 changes: 12 additions & 0 deletions Tests/Fixtures/Descriptor/definition_without_class.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"class": "",
"public": false,
"synthetic": false,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": false,
"autoconfigure": false,
"file": null,
"tags": []
}
8 changes: 8 additions & 0 deletions Tests/Fixtures/Descriptor/definition_without_class.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- Class: ``
- Public: no
- Synthetic: no
- Lazy: no
- Shared: yes
- Abstract: no
- Autowired: no
- Autoconfigured: no
15 changes: 15 additions & 0 deletions Tests/Fixtures/Descriptor/definition_without_class.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---------------- -------
 Option   Value 
---------------- -------
Service ID -
Class -
Tags -
Public no
Synthetic no
Lazy no
Shared yes
Abstract no
Autowired no
Autoconfigured no
---------------- -------

2 changes: 2 additions & 0 deletions Tests/Fixtures/Descriptor/definition_without_class.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<definition class="" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/>

0 comments on commit f7962d0

Please sign in to comment.