From 1ade5d86583c38836f22ccf4900eb5b608a495e8 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 26 Jul 2017 09:27:50 +0200 Subject: [PATCH] [DI] Make dumped docblocks less verbose --- .../DependencyInjection/Dumper/PhpDumper.php | 29 +--- .../Tests/Fixtures/php/services10.php | 7 +- .../Tests/Fixtures/php/services12.php | 7 +- .../Tests/Fixtures/php/services13.php | 7 +- .../Tests/Fixtures/php/services19.php | 14 +- .../Tests/Fixtures/php/services20.php | 14 +- .../Tests/Fixtures/php/services9.php | 129 +++++------------- .../Tests/Fixtures/php/services9_compiled.php | 93 ++++--------- 8 files changed, 79 insertions(+), 221 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 52f6362c73..721c4dc68c 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -565,7 +565,7 @@ class PhpDumper extends Dumper if ($definition->isSynthetic()) { $return[] = '@throws RuntimeException always since this service is expected to be injected dynamically'; } elseif ($class = $definition->getClass()) { - $return[] = sprintf('@return %s A %s instance', 0 === strpos($class, '%') ? 'object' : '\\'.ltrim($class, '\\'), ltrim($class, '\\')); + $return[] = sprintf(0 === strpos($class, '%') ? '@return object A %1$s instance' : '@return \%s', ltrim($class, '\\')); } elseif ($definition->getFactory()) { $factory = $definition->getFactory(); if (is_string($factory)) { @@ -593,32 +593,13 @@ class PhpDumper extends Dumper $return = implode("\n * ", $return); - $doc = ''; - if (ContainerInterface::SCOPE_PROTOTYPE !== $scope) { - $doc .= <<<'EOF' - - * - * This service is shared. - * This method always returns the same instance of the service. -EOF; - } - - if (!$definition->isPublic()) { - $doc .= <<<'EOF' - - * - * This service is private. - * If you want to be able to request this service from the container directly, - * make it public, otherwise you might end up with broken code. -EOF; - } + $shared = ContainerInterface::SCOPE_PROTOTYPE !== $scope ? ' shared' : ''; + $public = $definition->isPublic() ? 'public' : 'private'; if ($definition->isLazy()) { $lazyInitialization = '$lazyLoad = true'; - $lazyInitializationDoc = "\n * @param bool \$lazyLoad whether to try lazy-loading the service with a proxy\n *"; } else { $lazyInitialization = ''; - $lazyInitializationDoc = ''; } // with proxies, for 5.3.3 compatibility, the getter must be public to be accessible to the initializer @@ -627,8 +608,8 @@ EOF; $code = <<docStar} - * Gets the '$id' service.$doc - *$lazyInitializationDoc + * Gets the $public '$id'$shared service. + * * $return */ {$visibility} function get{$this->camelize($id)}Service($lazyInitialization) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index f792957101..923c437bb0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -55,12 +55,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'test' service. + * Gets the public 'test' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance + * @return \stdClass */ protected function getTestService() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index 5faa1a9781..2119719828 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -59,12 +59,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'test' service. + * Gets the public 'test' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance + * @return \stdClass */ protected function getTestService() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php index 37e3e7e1a1..eaf9c4bef0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php @@ -53,12 +53,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'bar' service. + * Gets the public 'bar' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance + * @return \stdClass */ protected function getBarService() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php index 985f0a9628..a3fde04b78 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php @@ -32,12 +32,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'service_from_anonymous_factory' service. + * Gets the public 'service_from_anonymous_factory' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar\FooClass A Bar\FooClass instance + * @return \Bar\FooClass */ protected function getServiceFromAnonymousFactoryService() { @@ -45,12 +42,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'service_with_method_call_and_factory' service. + * Gets the public 'service_with_method_call_and_factory' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar\FooClass A Bar\FooClass instance + * @return \Bar\FooClass */ protected function getServiceWithMethodCallAndFactoryService() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services20.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services20.php index ec0887ecbc..ba9a8902e4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services20.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services20.php @@ -32,12 +32,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'depends_on_request' service. + * Gets the public 'depends_on_request' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance + * @return \stdClass */ protected function getDependsOnRequestService() { @@ -49,12 +46,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'request' service. + * Gets the public 'request' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Request A Request instance + * @return \Request */ protected function getRequestService() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php index ce8930b8dd..1d35260143 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php @@ -52,12 +52,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'bar' service. + * Gets the public 'bar' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar\FooClass A Bar\FooClass instance + * @return \Bar\FooClass */ protected function getBarService() { @@ -71,12 +68,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'baz' service. + * Gets the public 'baz' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Baz A Baz instance + * @return \Baz */ protected function getBazService() { @@ -88,12 +82,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'configured_service' service. + * Gets the public 'configured_service' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance + * @return \stdClass */ protected function getConfiguredServiceService() { @@ -105,12 +96,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'decorated' service. + * Gets the public 'decorated' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance + * @return \stdClass */ protected function getDecoratedService() { @@ -118,12 +106,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'decorator_service' service. + * Gets the public 'decorator_service' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance + * @return \stdClass */ protected function getDecoratorServiceService() { @@ -131,12 +116,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'decorator_service_with_name' service. + * Gets the public 'decorator_service_with_name' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance + * @return \stdClass */ protected function getDecoratorServiceWithNameService() { @@ -144,12 +126,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'factory_service' service. + * Gets the public 'factory_service' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar A Bar instance + * @return \Bar */ protected function getFactoryServiceService() { @@ -157,12 +136,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'foo' service. + * Gets the public 'foo' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar\FooClass A Bar\FooClass instance + * @return \Bar\FooClass */ protected function getFooService() { @@ -181,10 +157,7 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'foo.baz' service. - * - * This service is shared. - * This method always returns the same instance of the service. + * Gets the public 'foo.baz' shared service. * * @return object A %baz_class% instance */ @@ -198,7 +171,7 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'foo_bar' service. + * Gets the public 'foo_bar' service. * * @return object A %foo_class% instance */ @@ -210,12 +183,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'foo_with_inline' service. + * Gets the public 'foo_with_inline' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Foo A Foo instance + * @return \Foo */ protected function getFooWithInlineService() { @@ -227,12 +197,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'method_call1' service. + * Gets the public 'method_call1' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar\FooClass A Bar\FooClass instance + * @return \Bar\FooClass */ protected function getMethodCall1Service() { @@ -254,12 +221,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'new_factory_service' service. + * Gets the public 'new_factory_service' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \FooBarBaz A FooBarBaz instance + * @return \FooBarBaz */ protected function getNewFactoryServiceService() { @@ -271,10 +235,7 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'request' service. - * - * This service is shared. - * This method always returns the same instance of the service. + * Gets the public 'request' shared service. * * @throws RuntimeException always since this service is expected to be injected dynamically */ @@ -284,12 +245,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'service_from_static_method' service. + * Gets the public 'service_from_static_method' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar\FooClass A Bar\FooClass instance + * @return \Bar\FooClass */ protected function getServiceFromStaticMethodService() { @@ -297,16 +255,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'configurator_service' service. + * Gets the private 'configurator_service' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * This service is private. - * If you want to be able to request this service from the container directly, - * make it public, otherwise you might end up with broken code. - * - * @return \ConfClass A ConfClass instance + * @return \ConfClass */ protected function getConfiguratorServiceService() { @@ -318,16 +269,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'inlined' service. + * Gets the private 'inlined' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * This service is private. - * If you want to be able to request this service from the container directly, - * make it public, otherwise you might end up with broken code. - * - * @return \Bar A Bar instance + * @return \Bar */ protected function getInlinedService() { @@ -340,16 +284,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'new_factory' service. + * Gets the private 'new_factory' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * This service is private. - * If you want to be able to request this service from the container directly, - * make it public, otherwise you might end up with broken code. - * - * @return \FactoryClass A FactoryClass instance + * @return \FactoryClass */ protected function getNewFactoryService() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 559560fa6d..22d447e303 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -71,12 +71,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'bar' service. + * Gets the public 'bar' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar\FooClass A Bar\FooClass instance + * @return \Bar\FooClass */ protected function getBarService() { @@ -90,12 +87,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'baz' service. + * Gets the public 'baz' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Baz A Baz instance + * @return \Baz */ protected function getBazService() { @@ -107,12 +101,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'configured_service' service. + * Gets the public 'configured_service' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance + * @return \stdClass */ protected function getConfiguredServiceService() { @@ -127,12 +118,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'decorator_service' service. + * Gets the public 'decorator_service' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance + * @return \stdClass */ protected function getDecoratorServiceService() { @@ -140,12 +128,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'decorator_service_with_name' service. + * Gets the public 'decorator_service_with_name' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance + * @return \stdClass */ protected function getDecoratorServiceWithNameService() { @@ -153,12 +138,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'factory_service' service. + * Gets the public 'factory_service' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar A Bar instance + * @return \Bar */ protected function getFactoryServiceService() { @@ -166,12 +148,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'foo' service. + * Gets the public 'foo' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar\FooClass A Bar\FooClass instance + * @return \Bar\FooClass */ protected function getFooService() { @@ -190,12 +169,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'foo.baz' service. + * Gets the public 'foo.baz' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \BazClass A BazClass instance + * @return \BazClass */ protected function getFoo_BazService() { @@ -207,9 +183,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'foo_bar' service. + * Gets the public 'foo_bar' service. * - * @return \Bar\FooClass A Bar\FooClass instance + * @return \Bar\FooClass */ protected function getFooBarService() { @@ -217,12 +193,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'foo_with_inline' service. + * Gets the public 'foo_with_inline' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Foo A Foo instance + * @return \Foo */ protected function getFooWithInlineService() { @@ -239,12 +212,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'method_call1' service. + * Gets the public 'method_call1' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar\FooClass A Bar\FooClass instance + * @return \Bar\FooClass */ protected function getMethodCall1Service() { @@ -260,12 +230,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'new_factory_service' service. + * Gets the public 'new_factory_service' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \FooBarBaz A FooBarBaz instance + * @return \FooBarBaz */ protected function getNewFactoryServiceService() { @@ -280,10 +247,7 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'request' service. - * - * This service is shared. - * This method always returns the same instance of the service. + * Gets the public 'request' shared service. * * @throws RuntimeException always since this service is expected to be injected dynamically */ @@ -293,12 +257,9 @@ class ProjectServiceContainer extends Container } /** - * Gets the 'service_from_static_method' service. + * Gets the public 'service_from_static_method' shared service. * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \Bar\FooClass A Bar\FooClass instance + * @return \Bar\FooClass */ protected function getServiceFromStaticMethodService() {