Skip to content

[DI] Make dumped docblocks less verbose #23673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ private function addService($id, Definition $definition)
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)) {
Expand Down Expand Up @@ -593,32 +593,13 @@ private function addService($id, Definition $definition)

$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
Expand All @@ -627,8 +608,8 @@ private function addService($id, Definition $definition)
$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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ public function isFrozen()
}

/**
* 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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,9 @@ public function isFrozen()
}

/**
* 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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,9 @@ public function isFrozen()
}

/**
* 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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,19 @@ public function __construct()
}

/**
* 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()
{
return $this->services['service_from_anonymous_factory'] = call_user_func(array(new \Bar\FooClass(), 'getInstance'));
}

/**
* Gets the 'service_with_method_call_and_factory' service.
*
* This service is shared.
* This method always returns the same instance of the service.
* Gets the public 'service_with_method_call_and_factory' shared service.
*
* @return \Bar\FooClass A Bar\FooClass instance
* @return \Bar\FooClass
*/
protected function getServiceWithMethodCallAndFactoryService()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ public function __construct()
}

/**
* 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()
{
Expand All @@ -49,12 +46,9 @@ protected function getDependsOnRequestService()
}

/**
* Gets the 'request' service.
*
* This service is shared.
* This method always returns the same instance of the service.
* Gets the public 'request' shared service.
*
* @return \Request A Request instance
* @return \Request
*/
protected function getRequestService()
{
Expand Down
Loading