8000 Merge branch '2.7' into 2.8 · symfony/symfony@57bf748 · GitHub
[go: up one dir, main page]

Skip to content

Commit 57bf748

Browse files
Merge branch '2.7' into 2.8
* 2.7: [DI] Make dumped docblocks less verbose
2 parents 17670e4 + a90250d commit 57bf748

File tree

10 files changed

+87
-247
lines changed

10 files changed

+87
-247
lines changed

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

Lines changed: 6 additions & 32 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)) {
@@ -601,40 +601,14 @@ private function addService($id, Definition $definition)
601601

602602
$return = str_replace("\n * \n", "\n *\n", implode("\n * ", $return));
603603

604-
$doc = '';
605-
if ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
606-
$doc .= <<<'EOF'
607-
608-
*
609-
* This service is shared.
610-
* This method always returns the same instance of the service.
611-
EOF;
612-
}
613-
614-
if (!$definition->isPublic()) {
615-
$doc .= <<<'EOF'
616-
617-
*
618-
* This service is private.
619-
* If you want to be able to request this service from the container directly,
620-
* make it public, otherwise you might end up with broken code.
621-
EOF;
622-
}
623-
624-
if ($definition->isAutowired()) {
625-
$doc .= <<<EOF
626-
627-
*
628-
* This service is autowired.
629-
EOF;
630-
}
604+
$shared = $definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $scope ? ' shared' : '';
605+
$public = $definition->isPublic() ? 'public' : 'private';
606+
$autowired = $definition->isAutowired() ? ' autowired' : '';
631607

632608
if ($definition->isLazy()) {
633609
$lazyInitialization = '$lazyLoad = true';
634-
$lazyInitializationDoc = "\n * @param bool \$lazyLoad whether to try lazy-loading the service with a proxy\n *";
635610
} else {
636611
$lazyInitialization = '';
637-
$lazyInitializationDoc = '';
638612
}
639613

640614
// with proxies, for 5.3.3 compatibility, the getter must be public to be accessible to the initializer
@@ -643,8 +617,8 @@ private function addService($id, Definition $definition)
643617
$code = <<<EOF
644618
645619
/*{$this->docStar}
646-
* Gets the '$id' service.$doc
647-
*$lazyInitializationDoc
620+
* Gets the $public '$id'$shared$autowired service.
621+
*
648622
* $return
649623
*/
650624
{$visibility} function get{$this->camelize($id)}Service($lazyInitialization)

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function testDumpAutowireData()
263263
$container = include self::$fixturesPath.'/containers/container24.php';
264264
$dumper = new PhpDumper($container);
265265

266-
$this->assertEquals(file_get_contents(self::$fixturesPath.'/php/services24.php'), $dumper->dump());
266+
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services24.php', $dumper->dump());
267267
}
268268

269269
public function testInlinedDefinitionReferencingServiceContainer()

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
{

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,9 @@ public function __construct()
3131
}
3232

3333
/**
34-
* Gets the 'foo' service.
34+
* Gets the public 'foo' shared autowired service.
3535
*
36-
* This service is shared.
37-
* This method always returns the same instance of the service.
38-
*
39-
* This service is autowired.
40-
*
41-
* @return \Foo A Foo instance
36+
* @return \Foo
4237
*/
4338
protected function getFooService()
4439
{

0 commit comments

Comments
 (0)
0