Skip to content

Commit a90250d

Browse files
committed
minor symfony#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 ------- 1ade5d8 [DI] Make dumped docblocks less verbose
2 parents 072c866 + 1ade5d8 commit a90250d

File tree

8 files changed

+79
-221
lines changed

8 files changed

+79
-221
lines changed

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ private function addService($id, Definition $definition)
565565
if ($definition->isSynthetic()) {
566566
$return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
567567
} elseif ($class = $definition->getClass()) {
568-
$return[] = sprintf('@return %s A %s instance', 0 === strpos($class, '%') ? 'object' : '\\'.ltrim($class, '\\'), ltrim($class, '\\'));
568+
$return[] = sprintf(0 === strpos($class, '%') ? '@return object A %1$s instance' : '@return \%s', ltrim($class, '\\'));
569569
} elseif ($definition->getFactory()) {
570570
$factory = $definition->getFactory();
571571
if (is_string($factory)) {
@@ -593,32 +593,13 @@ private function addService($id, Definition $definition)
593593

594594
$return = implode("\n * ", $return);
595595

596-
$doc = '';
597-
if (ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
598-
$doc .= <<<'EOF'
599-
600-
*
601-
* This service is shared.
602-
* This method always returns the same instance of the service.
603-
EOF;
604-
}
605-
606-
if (!$definition->isPublic()) {
607-
$doc .= <<<'EOF'
608-
609-
*
610-
* This service is private.
611-
* If you want to be able to request this service from the container directly,
612-
* make it public, otherwise you might end up with broken code.
613-
EOF;
614-
}
596+
$shared = ContainerInterface::SCOPE_PROTOTYPE !== $scope ? ' shared' : '';
597+
$public = $definition->isPublic() ? 'public' : 'private';
615598

616599
if ($definition->isLazy()) {
617600
$lazyInitialization = '$lazyLoad = true';
618-
$lazyInitializationDoc = "\n * @param bool \$lazyLoad whether to try lazy-loading the service with a proxy\n *";
619601
} else {
620602
$lazyInitialization = '';
621-
$lazyInitializationDoc = '';
622603
}
623604

624605
// with proxies, for 5.3.3 compatibility, the getter must be public to be accessible to the initializer
@@ -627,8 +608,8 @@ private function addService($id, Definition $definition)
627608
$code = <<<EOF
628609
629610
/*{$this->docStar}
630-
* Gets the '$id' service.$doc
631-
*$lazyInitializationDoc
611+
* Gets the $public '$id'$shared service.
612+
*
632613
* $return
633614
*/
634615
{$visibility} function get{$this->camelize($id)}Service($lazyInitialization)

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,9 @@ public function isFrozen()
5555
}
5656

5757
/**
58-
* Gets the 'test' service.
58+
* Gets the public 'test' shared service.
5959
*
60-
* This service is shared.
61-
* This method always returns the same instance of the service.
62-
*
63-
* @return \stdClass A stdClass instance
60+
* @return \stdClass
6461
*/
6562
protected function getTestService()
6663
{

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,9 @@ public function isFrozen()
5959
}
6060

6161
/**
62-
* Gets the 'test' service.
62+
* Gets the public 'test' shared service.
6363
*
64-
* This service is shared.
65-
* This method always returns the same instance of the service.
66-
*
67-
* @return \stdClass A stdClass instance
64+
* @return \stdClass
6865
*/
6966
protected function getTestService()
7067
{

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ public function isFrozen()
5353
}
5454

5555
/**
56-
* Gets the 'bar' service.
56+
* Gets the public 'bar' shared service.
5757
*
58-
* This service is shared.
59-
* This method always returns the same instance of the service.
60-
*
61-
* @return \stdClass A stdClass instance
58+
* @return \stdClass
6259
*/
6360
protected function getBarService()
6461
{

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,19 @@ public function __construct()
3232
}
3333

3434
/**
35-
* Gets the 'service_from_anonymous_factory' service.
35+
* Gets the public 'service_from_anonymous_factory' shared service.
3636
*
37-
* This service is shared.
38-
* This method always returns the same instance of the service.
39-
*
40-
* @return \Bar\FooClass A Bar\FooClass instance
37+
* @return \Bar\FooClass
4138
*/
4239
protected function getServiceFromAnonymousFactoryService()
4340
{
4441
return $this->services['service_from_anonymous_factory'] = call_user_func(array(new \Bar\FooClass(), 'getInstance'));
4542
}
4643

4744
/**
48-
* Gets the 'service_with_method_call_and_factory' service.
49-
*
50-
* This service is shared.
51-
* This method always returns the same instance of the service.
45+
* Gets the public 'service_with_method_call_and_factory' shared service.
5246
*
53-
* @return \Bar\FooClass A Bar\FooClass instance
47+
* @return \Bar\FooClass
5448
*/
5549
protected function getServiceWithMethodCallAndFactoryService()
5650
{

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services20.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,9 @@ public function __construct()
3232
}
3333

3434
/**
35-
* Gets the 'depends_on_request' service.
35+
* Gets the public 'depends_on_request' shared service.
3636
*
37-
* This service is shared.
38-
* This method always returns the same instance of the service.
39-
*
40-
* @return \stdClass A stdClass instance
37+
* @return \stdClass
4138
*/
4239
protected function getDependsOnRequestService()
4340
{
@@ -49,12 +46,9 @@ protected function getDependsOnRequestService()
4946
}
5047

5148
/**
52-
* Gets the 'request' service.
53-
*
54-
* This service is shared.
55-
* This method always returns the same instance of the service.
49+
* Gets the public 'request' shared service.
5650
*
57-
* @return \Request A Request instance
51+
* @return \Request
5852
*/
5953
protected function getRequestService()
6054
{

0 commit comments

Comments
 (0)