[DI] Make dumped docblocks less verbose

This commit is contained in:
Nicolas Grekas 2017-07-26 09:27:50 +02:00
parent 072c866d70
commit 1ade5d8658
8 changed files with 79 additions and 221 deletions

View File

@ -565,7 +565,7 @@ class PhpDumper extends Dumper
if ($definition->isSynthetic()) { if ($definition->isSynthetic()) {
$return[] = '@throws RuntimeException always since this service is expected to be injected dynamically'; $return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
} elseif ($class = $definition->getClass()) { } 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()) { } elseif ($definition->getFactory()) {
$factory = $definition->getFactory(); $factory = $definition->getFactory();
if (is_string($factory)) { if (is_string($factory)) {
@ -593,32 +593,13 @@ class PhpDumper extends Dumper
$return = implode("\n * ", $return); $return = implode("\n * ", $return);
$doc = ''; $shared = ContainerInterface::SCOPE_PROTOTYPE !== $scope ? ' shared' : '';
if (ContainerInterface::SCOPE_PROTOTYPE !== $scope) { $public = $definition->isPublic() ? 'public' : 'private';
$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;
}
if ($definition->isLazy()) { if ($definition->isLazy()) {
$lazyInitialization = '$lazyLoad = true'; $lazyInitialization = '$lazyLoad = true';
$lazyInitializationDoc = "\n * @param bool \$lazyLoad whether to try lazy-loading the service with a proxy\n *";
} else { } else {
$lazyInitialization = ''; $lazyInitialization = '';
$lazyInitializationDoc = '';
} }
// with proxies, for 5.3.3 compatibility, the getter must be public to be accessible to the initializer // with proxies, for 5.3.3 compatibility, the getter must be public to be accessible to the initializer
@ -627,8 +608,8 @@ EOF;
$code = <<<EOF $code = <<<EOF
/*{$this->docStar} /*{$this->docStar}
* Gets the '$id' service.$doc * Gets the $public '$id'$shared service.
*$lazyInitializationDoc *
* $return * $return
*/ */
{$visibility} function get{$this->camelize($id)}Service($lazyInitialization) {$visibility} function get{$this->camelize($id)}Service($lazyInitialization)

View File

@ -55,12 +55,9 @@ class ProjectServiceContainer extends Container
} }
/** /**
* Gets the 'test' service. * Gets the public 'test' shared service.
* *
* This service is shared. * @return \stdClass
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
*/ */
protected function getTestService() protected function getTestService()
{ {

View File

@ -59,12 +59,9 @@ class ProjectServiceContainer extends Container
} }
/** /**
* Gets the 'test' service. * Gets the public 'test' shared service.
* *
* This service is shared. * @return \stdClass
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
*/ */
protected function getTestService() protected function getTestService()
{ {

View File

@ -53,12 +53,9 @@ class ProjectServiceContainer extends Container
} }
/** /**
* Gets the 'bar' service. * Gets the public 'bar' shared service.
* *
* This service is shared. * @return \stdClass
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
*/ */
protected function getBarService() protected function getBarService()
{ {

View File

@ -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. * @return \Bar\FooClass
* This method always returns the same instance of the service.
*
* @return \Bar\FooClass A Bar\FooClass instance
*/ */
protected function getServiceFromAnonymousFactoryService() 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. * @return \Bar\FooClass
* This method always returns the same instance of the service.
*
* @return \Bar\FooClass A Bar\FooClass instance
*/ */
protected function getServiceWithMethodCallAndFactoryService() protected function getServiceWithMethodCallAndFactoryService()
{ {

View File

@ -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. * @return \stdClass
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
*/ */
protected function getDependsOnRequestService() 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. * @return \Request
* This method always returns the same instance of the service.
*
* @return \Request A Request instance
*/ */
protected function getRequestService() protected function getRequestService()
{ {

View File

@ -52,12 +52,9 @@ class ProjectServiceContainer extends Container
} }
/** /**
* Gets the 'bar' service. * Gets the public 'bar' shared service.
* *
* This service is shared. * @return \Bar\FooClass
* This method always returns the same instance of the service.
*
* @return \Bar\FooClass A Bar\FooClass instance
*/ */
protected function getBarService() 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. * @return \Baz
* This method always returns the same instance of the service.
*
* @return \Baz A Baz instance
*/ */
protected function getBazService() 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. * @return \stdClass
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
*/ */
protected function getConfiguredServiceService() 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. * @return \stdClass
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
*/ */
protected function getDecoratedService() 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. * @return \stdClass
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
*/ */
protected function getDecoratorServiceService() 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. * @return \stdClass
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
*/ */
protected function getDecoratorServiceWithNameService() 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. * @return \Bar
* This method always returns the same instance of the service.
*
* @return \Bar A Bar instance
*/ */
protected function getFactoryServiceService() 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. * @return \Bar\FooClass
* This method always returns the same instance of the service.
*
* @return \Bar\FooClass A Bar\FooClass instance
*/ */
protected function getFooService() protected function getFooService()
{ {
@ -181,10 +157,7 @@ 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 object A %baz_class% instance * @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 * @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. * @return \Foo
* This method always returns the same instance of the service.
*
* @return \Foo A Foo instance
*/ */
protected function getFooWithInlineService() 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. * @return \Bar\FooClass
* This method always returns the same instance of the service.
*
* @return \Bar\FooClass A Bar\FooClass instance
*/ */
protected function getMethodCall1Service() 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. * @return \FooBarBaz
* This method always returns the same instance of the service.
*
* @return \FooBarBaz A FooBarBaz instance
*/ */
protected function getNewFactoryServiceService() protected function getNewFactoryServiceService()
{ {
@ -271,10 +235,7 @@ 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.
* *
* @throws RuntimeException always since this service is expected to be injected dynamically * @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. * @return \Bar\FooClass
* This method always returns the same instance of the service.
*
* @return \Bar\FooClass A Bar\FooClass instance
*/ */
protected function getServiceFromStaticMethodService() 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. * @return \ConfClass
* 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
*/ */
protected function getConfiguratorServiceService() 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. * @return \Bar
* 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
*/ */
protected function getInlinedService() 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. * @return \FactoryClass
* 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
*/ */
protected function getNewFactoryService() protected function getNewFactoryService()
{ {

View File

@ -71,12 +71,9 @@ class ProjectServiceContainer extends Container
} }
/** /**
* Gets the 'bar' service. * Gets the public 'bar' shared service.
* *
* This service is shared. * @return \Bar\FooClass
* This method always returns the same instance of the service.
*
* @return \Bar\FooClass A Bar\FooClass instance
*/ */
protected function getBarService() 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. * @return \Baz
* This method always returns the same instance of the service.
*
* @return \Baz A Baz instance
*/ */
protected function getBazService() 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. * @return \stdClass
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
*/ */
protected function getConfiguredServiceService() 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. * @return \stdClass
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
*/ */
protected function getDecoratorServiceService() 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. * @return \stdClass
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
*/ */
protected function getDecoratorServiceWithNameService() 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. * @return \Bar
* This method always returns the same instance of the service.
*
* @return \Bar A Bar instance
*/ */
protected function getFactoryServiceService() 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. * @return \Bar\FooClass
* This method always returns the same instance of the service.
*
* @return \Bar\FooClass A Bar\FooClass instance
*/ */
protected function getFooService() 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. * @return \BazClass
* This method always returns the same instance of the service.
*
* @return \BazClass A BazClass instance
*/ */
protected function getFoo_BazService() 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() 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. * @return \Foo
* This method always returns the same instance of the service.
*
* @return \Foo A Foo instance
*/ */
protected function getFooWithInlineService() 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. * @return \Bar\FooClass
* This method always returns the same instance of the service.
*
* @return \Bar\FooClass A Bar\FooClass instance
*/ */
protected function getMethodCall1Service() 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. * @return \FooBarBaz
* This method always returns the same instance of the service.
*
* @return \FooBarBaz A FooBarBaz instance
*/ */
protected function getNewFactoryServiceService() protected function getNewFactoryServiceService()
{ {
@ -280,10 +247,7 @@ 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.
* *
* @throws RuntimeException always since this service is expected to be injected dynamically * @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. * @return \Bar\FooClass
* This method always returns the same instance of the service.
*
* @return \Bar\FooClass A Bar\FooClass instance
*/ */
protected function getServiceFromStaticMethodService() protected function getServiceFromStaticMethodService()
{ {