[DI] Dump the deprecated status
This commit is contained in:
parent
8f6c21c2b6
commit
2f37cb184f
@ -592,7 +592,15 @@ class PhpDumper extends Dumper
|
||||
$return[] = sprintf("@throws InactiveScopeException when the '%s' service is requested while the '%s' scope is not active", $id, $scope);
|
||||
}
|
||||
|
||||
$return = implode("\n * ", $return);
|
||||
if ($definition->isDeprecated()) {
|
||||
if ($return && 0 === strpos($return[count($return) - 1], '@return')) {
|
||||
$return[] = '';
|
||||
}
|
||||
|
||||
$return[] = '@deprecated';
|
||||
}
|
||||
|
||||
$return = str_replace("\n * \n", "\n *\n", implode("\n * ", $return));
|
||||
|
||||
$doc = '';
|
||||
if ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
|
||||
@ -652,6 +660,10 @@ EOF;
|
||||
if ($definition->isSynthetic()) {
|
||||
$code .= sprintf(" throw new RuntimeException('You have requested a synthetic service (\"%s\"). The DIC does not know how to construct this service.');\n }\n", $id);
|
||||
} else {
|
||||
if ($definition->isDeprecated()) {
|
||||
$code .= sprintf(" @trigger_error('The service %s has been marked as deprecated. You should stop using it.', E_USER_DEPRECATED);\n\n", $id);
|
||||
}
|
||||
|
||||
$code .=
|
||||
$this->addServiceInclude($id, $definition).
|
||||
$this->addServiceLocalTempVariables($id, $definition).
|
||||
|
@ -148,6 +148,9 @@ class XmlDumper extends Dumper
|
||||
if ($definition->isLazy()) {
|
||||
$service->setAttribute('lazy', 'true');
|
||||
}
|
||||
if ($definition->isDeprecated()) {
|
||||
$service->setAttribute('deprecated', 'true');
|
||||
}
|
||||
if (null !== $decorated = $definition->getDecoratedService()) {
|
||||
list($decorated, $renamedId, $priority) = $decorated;
|
||||
$service->setAttribute('decorates', $decorated);
|
||||
|
@ -104,6 +104,10 @@ class YamlDumper extends Dumper
|
||||
$code .= sprintf(" synchronized: true\n");
|
||||
}
|
||||
|
||||
if ($definition->isDeprecated()) {
|
||||
$code .= " deprecated: true\n";
|
||||
}
|
||||
|
||||
if ($definition->getFactoryClass(false)) {
|
||||
$code .= sprintf(" factory_class: %s\n", $definition->getFactoryClass(false));
|
||||
}
|
||||
|
@ -89,6 +89,10 @@ $container
|
||||
->register('decorator_service_with_name', 'stdClass')
|
||||
->setDecoratedService('decorated', 'decorated.pif-pouf')
|
||||
;
|
||||
$container
|
||||
->register('deprecated_service', 'stdClass')
|
||||
->setDeprecated(true)
|
||||
;
|
||||
$container
|
||||
->register('new_factory', 'FactoryClass')
|
||||
->setProperty('foo', 'bar')
|
||||
|
@ -17,6 +17,7 @@ digraph sc {
|
||||
node_decorated [label="decorated\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
|
||||
node_decorator_service [label="decorator_service\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
|
||||
node_decorator_service_with_name [label="decorator_service_with_name\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
|
||||
node_deprecated_service [label="deprecated_service\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
|
||||
node_new_factory [label="new_factory\nFactoryClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
|
||||
node_factory_service [label="factory_service\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"];
|
||||
node_new_factory_service [label="new_factory_service\nFooBarBaz\n", shape=record, fillcolor="#eeeeee", style="filled"];
|
||||
|
@ -33,6 +33,7 @@ class ProjectServiceContainer extends Container
|
||||
'decorated' => 'getDecoratedService',
|
||||
'decorator_service' => 'getDecoratorServiceService',
|
||||
'decorator_service_with_name' => 'getDecoratorServiceWithNameService',
|
||||
'deprecated_service' => 'getDeprecatedServiceService',
|
||||
'factory_service' => 'getFactoryServiceService',
|
||||
'foo' => 'getFooService',
|
||||
'foo.baz' => 'getFoo_BazService',
|
||||
@ -143,6 +144,23 @@ class ProjectServiceContainer extends Container
|
||||
return $this->services['decorator_service_with_name'] = new \stdClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the 'deprecated_service' service.
|
||||
*
|
||||
* This service is shared.
|
||||
* This method always returns the same instance of the service.
|
||||
*
|
||||
* @return \stdClass A stdClass instance.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
protected function getDeprecatedServiceService()
|
||||
{
|
||||
@trigger_error('The service deprecated_service has been marked as deprecated. You should stop using it.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->services['deprecated_service'] = new \stdClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the 'factory_service' service.
|
||||
*
|
||||
|
@ -37,6 +37,7 @@ class ProjectServiceContainer extends Container
|
||||
'configured_service' => 'getConfiguredServiceService',
|
||||
'decorator_service' => 'getDecoratorServiceService',
|
||||
'decorator_service_with_name' => 'getDecoratorServiceWithNameService',
|
||||
'deprecated_service' => 'getDeprecatedServiceService',
|
||||
'factory_service' => 'getFactoryServiceService',
|
||||
'foo' => 'getFooService',
|
||||
'foo.baz' => 'getFoo_BazService',
|
||||
@ -144,6 +145,23 @@ class ProjectServiceContainer extends Container
|
||||
return $this->services['decorator_service_with_name'] = new \stdClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the 'deprecated_service' service.
|
||||
*
|
||||
* This service is shared.
|
||||
* This method always returns the same instance of the service.
|
||||
*
|
||||
* @return \stdClass A stdClass instance.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
protected function getDeprecatedServiceService()
|
||||
{
|
||||
@trigger_error('The service deprecated_service has been marked as deprecated. You should stop using it.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->services['deprecated_service'] = new \stdClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the 'factory_service' service.
|
||||
*
|
||||
|
@ -87,6 +87,7 @@
|
||||
<service id="decorated" class="stdClass"/>
|
||||
<service id="decorator_service" class="stdClass" decorates="decorated"/>
|
||||
<service id="decorator_service_with_name" class="stdClass" decorates="decorated" decoration-inner-name="decorated.pif-pouf"/>
|
||||
<service id="deprecated_service" class="stdClass" deprecated="true"/>
|
||||
<service id="new_factory" class="FactoryClass" public="false">
|
||||
<property name="foo">bar</property>
|
||||
</service>
|
||||
|
@ -76,6 +76,9 @@ services:
|
||||
class: stdClass
|
||||
decorates: decorated
|
||||
decoration_inner_name: decorated.pif-pouf
|
||||
deprecated_service:
|
||||
class: stdClass
|
||||
deprecated: true
|
||||
new_factory:
|
||||
class: FactoryClass
|
||||
public: false
|
||||
|
Reference in New Issue
Block a user