From e5b0fd37f699ba24f7b1520725c5c651ea4f41be Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 22 Mar 2019 10:34:50 +0100 Subject: [PATCH] properly describe service definitions without class --- .../Console/Descriptor/JsonDescriptor.php | 2 +- .../Console/Descriptor/MarkdownDescriptor.php | 2 +- .../Console/Descriptor/TextDescriptor.php | 2 +- .../Console/Descriptor/XmlDescriptor.php | 2 +- .../Tests/Console/Descriptor/ObjectsProvider.php | 1 + .../Fixtures/Descriptor/builder_1_arguments.json | 13 +++++++++++++ .../Fixtures/Descriptor/builder_1_arguments.md | 12 ++++++++++++ .../Fixtures/Descriptor/builder_1_arguments.txt | 15 ++++++++------- .../Fixtures/Descriptor/builder_1_arguments.xml | 1 + .../Fixtures/Descriptor/builder_1_public.json | 12 ++++++++++++ .../Tests/Fixtures/Descriptor/builder_1_public.md | 11 +++++++++++ .../Fixtures/Descriptor/builder_1_public.txt | 15 ++++++++------- .../Fixtures/Descriptor/builder_1_public.xml | 1 + .../definition_arguments_without_class.json | 13 +++++++++++++ .../definition_arguments_without_class.md | 9 +++++++++ .../definition_arguments_without_class.txt | 15 +++++++++++++++ .../definition_arguments_without_class.xml | 2 ++ .../Descriptor/definition_without_class.json | 12 ++++++++++++ .../Descriptor/definition_without_class.md | 8 ++++++++ .../Descriptor/definition_without_class.txt | 15 +++++++++++++++ .../Descriptor/definition_without_class.xml | 2 ++ 21 files changed, 147 insertions(+), 18 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.json create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.md create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.txt create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.xml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.json create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.md create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.txt create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.xml diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 44fae86bc05a7..53cb18910525f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -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; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php index 56e11b07f6aba..8d6e3bddc4c9f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php @@ -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"; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index c0ec5e412e616..0739202166196 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -255,7 +255,7 @@ protected function describeContainerDefinition(Definition $definition, array $op $options['output']->title(sprintf('Information for Service "%s"', $options['id'])); } - if ('' !== $classDescription = $this->getClassDescription($definition->getClass())) { + if ('' !== $classDescription = $this->getClassDescription((string) $definition->getClass())) { $options['output']->text($classDescription."\n"); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index 3e66b05d0ba81..d35f5c609bca3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -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)); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php index caafff6842dc5..a2b8409e8d8b7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php @@ -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(), ]; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json index 959b24b3ffe35..e07b137438464 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json @@ -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, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.md index efdc188d4315e..08676b31d9b2c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.md @@ -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.` diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.txt index 5ab36e2ebf186..74166a38706e0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.txt @@ -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 + -------------------------- ---------------------------------------------------------- diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml index 0a6cfb44a2666..061bb5d6ef219 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml @@ -23,6 +23,7 @@ + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json index d96cf59951e28..49e18b886836e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json @@ -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, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md index cf8aec87e436e..be23f839bf474 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md @@ -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.` diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt index 5ab36e2ebf186..74166a38706e0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt @@ -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 + -------------------------- ---------------------------------------------------------- diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.xml index b6f6302713c03..05f83391f6208 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.xml @@ -4,6 +4,7 @@ + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.json new file mode 100644 index 0000000000000..90a6b5dece406 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.json @@ -0,0 +1,13 @@ +{ + "class": "", + "public": false, + "synthetic": false, + "lazy": false, + "shared": true, + "abstract": false, + "autowire": false, + "autoconfigure": false, + "arguments": [], + "file": null, + "tags": [] +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.md new file mode 100644 index 0000000000000..217c965b67a31 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.md @@ -0,0 +1,9 @@ +- Class: `` +- Public: no +- Synthetic: no +- Lazy: no +- Shared: yes +- Abstract: no +- Autowired: no +- Autoconfigured: no +- Arguments: no diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.txt new file mode 100644 index 0000000000000..ed49579037fda --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.txt @@ -0,0 +1,15 @@ + ---------------- ------- +  Option   Value  + ---------------- ------- + Service ID - + Class - + Tags - + Public no + Synthetic no + Lazy no + Shared yes + Abstract no + Autowired no + Autoconfigured no + ---------------- ------- + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.xml new file mode 100644 index 0000000000000..ee6df8928e245 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_without_class.xml @@ -0,0 +1,2 @@ + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.json new file mode 100644 index 0000000000000..eda84251babd5 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.json @@ -0,0 +1,12 @@ +{ + "class": "", + "public": false, + "synthetic": false, + "lazy": false, + "shared": true, + "abstract": false, + "autowire": false, + "autoconfigure": false, + "file": null, + "tags": [] +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.md new file mode 100644 index 0000000000000..ca50a70f77111 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.md @@ -0,0 +1,8 @@ +- Class: `` +- Public: no +- Synthetic: no +- Lazy: no +- Shared: yes +- Abstract: no +- Autowired: no +- Autoconfigured: no diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.txt new file mode 100644 index 0000000000000..ed49579037fda --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.txt @@ -0,0 +1,15 @@ + ---------------- ------- +  Option   Value  + ---------------- ------- + Service ID - + Class - + Tags - + Public no + Synthetic no + Lazy no + Shared yes + Abstract no + Autowired no + Autoconfigured no + ---------------- ------- + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.xml new file mode 100644 index 0000000000000..ee6df8928e245 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_without_class.xml @@ -0,0 +1,2 @@ + +