From 5ee56541714e5825d350370a4acf0cae760b9c09 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 1 Apr 2020 08:28:48 +0200 Subject: [PATCH] [DependencyInjection] Fix alias deprecations with package and version --- .../Compiler/ResolveReferencesToAliasesPass.php | 2 +- .../Component/DependencyInjection/Dumper/XmlDumper.php | 2 +- .../Tests/Compiler/ResolveReferencesToAliasesPassTest.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php index 6d320e77f4..b6c00da5fa 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php @@ -63,7 +63,7 @@ class ResolveReferencesToAliasesPass extends AbstractRecursivePass if ($alias->isDeprecated()) { $deprecation = $alias->getDeprecation($id); - trigger_deprecation($deprecation['package'], $deprecation['version'], rtrim($deprecation['message'], '. ').'. It is being referenced by the "%s" '.($container->hasDefinition($this->currentId) ? 'service.' : 'alias.'), rtrim($deprecation['message'], '. '), $this->currentId); + trigger_deprecation($deprecation['package'], $deprecation['version'], rtrim($deprecation['message'], '. ').'. It is being referenced by the "%s" '.($container->hasDefinition($this->currentId) ? 'service.' : 'alias.'), $this->currentId); } $seen = []; diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index 26521421bc..805fa95850 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -230,7 +230,7 @@ class XmlDumper extends Dumper if ($id->isDeprecated()) { $deprecation = $id->getDeprecation('%alias_id%'); $deprecated = $this->document->createElement('deprecated'); - $deprecated->setAttribute('message', $deprecation['message']); + $deprecated->appendChild($this->document->createTextNode($deprecation['message'])); $deprecated->setAttribute('package', $deprecation['package']); $deprecated->setAttribute('version', $deprecation['version']); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php index ecef24fd4f..9357e848d0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php @@ -89,13 +89,13 @@ class ResolveReferencesToAliasesPassTest extends TestCase */ public function testDeprecationNoticeWhenReferencedByAlias() { - $this->expectDeprecation('The "deprecated_foo_alias" service alias is deprecated. You should stop using it, as it will be removed in the future. It is being referenced by the "alias" alias.'); + $this->expectDeprecation('Since foobar 1.2.3.4: The "deprecated_foo_alias" service alias is deprecated. You should stop using it, as it will be removed in the future. It is being referenced by the "alias" alias.'); $container = new ContainerBuilder(); $container->register('foo', 'stdClass'); $aliasDeprecated = new Alias('foo'); - $aliasDeprecated->setDeprecated(true); + $aliasDeprecated->setDeprecated('foobar', '1.2.3.4', ''); $container->setAlias('deprecated_foo_alias', $aliasDeprecated); $alias = new Alias('deprecated_foo_alias'); @@ -109,13 +109,13 @@ class ResolveReferencesToAliasesPassTest extends TestCase */ public function testDeprecationNoticeWhenReferencedByDefinition() { - $this->expectDeprecation('The "foo_aliased" service alias is deprecated. You should stop using it, as it will be removed in the future. It is being referenced by the "definition" service.'); + $this->expectDeprecation('Since foobar 1.2.3.4: The "foo_aliased" service alias is deprecated. You should stop using it, as it will be removed in the future. It is being referenced by the "definition" service.'); $container = new ContainerBuilder(); $container->register('foo', 'stdClass'); $aliasDeprecated = new Alias('foo'); - $aliasDeprecated->setDeprecated(true); + $aliasDeprecated->setDeprecated('foobar', '1.2.3.4', ''); $container->setAlias('foo_aliased', $aliasDeprecated); $container