minor #23673 [DI] Make dumped docblocks less verbose (nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[DI] Make dumped docblocks less verbose

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

When I open a dumped container, I always find there are too much noise in docblocs.
As a bonus side effect, this will reduce the memory requirement in dev :)

Commits
-------

1ade5d8658 [DI] Make dumped docblocks less verbose
This commit is contained in:
Fabien Potencier 2017-07-26 09:36:19 +02:00
commit a90250d8da
8 changed files with 79 additions and 221 deletions

View File

@ -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 = <<<EOF
/*{$this->docStar}
* Gets the '$id' service.$doc
*$lazyInitializationDoc
* Gets the $public '$id'$shared service.
*
* $return
*/
{$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.
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
* @return \stdClass
*/
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.
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
* @return \stdClass
*/
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.
* This method always returns the same instance of the service.
*
* @return \stdClass A stdClass instance
* @return \stdClass
*/
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.
* 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()
{

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.
* 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()
{

View File

@ -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()
{

View File

@ -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()
{