Skip to content

Commit ff5934d

Browse files
committed
[DependencyInjection] Fix alias deprecations with package and version
1 parent 7cfc98b commit ff5934d

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Compiler/ResolveReferencesToAliasesPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private function getDefinitionId(string $id, ContainerBuilder $container): strin
6363

6464
if ($alias->isDeprecated()) {
6565
$deprecation = $alias->getDeprecation($id);
66-
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);
66+
trigger_deprecation($deprecation['package'], $deprecation['version'], rtrim($deprecation['message'], '. ').'. It is being referenced by the "%s" '.($container->hasDefinition($this->currentId) ? 'service.' : 'alias.'), $this->currentId);
6767
}
6868

6969
$seen = [];

Dumper/XmlDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ private function addServiceAlias(string $alias, Alias $id, \DOMElement $parent)
230230
if ($id->isDeprecated()) {
231231
$deprecation = $id->getDeprecation('%alias_id%');
232232
$deprecated = $this->document->createElement('deprecated');
233-
$deprecated->setAttribute('message', $deprecation['message']);
233+
$deprecated->appendChild($this->document->createTextNode($deprecation['message']));
234234
$deprecated->setAttribute('package', $deprecation['package']);
235235
$deprecated->setAttribute('version', $deprecation['version']);
236236

Tests/Compiler/ResolveReferencesToAliasesPassTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ public function testResolveFactory()
8989
*/
9090
public function testDeprecationNoticeWhenReferencedByAlias()
9191
{
92-
$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.');
92+
$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.');
9393
$container = new ContainerBuilder();
9494

9595
$container->register('foo', 'stdClass');
9696

9797
$aliasDeprecated = new Alias('foo');
98-
$aliasDeprecated->setDeprecated(true);
98+
$aliasDeprecated->setDeprecated('foobar', '1.2.3.4', '');
9999
$container->setAlias('deprecated_foo_alias', $aliasDeprecated);
100100

101101
$alias = new Alias('deprecated_foo_alias');
@@ -109,13 +109,13 @@ public function testDeprecationNoticeWhenReferencedByAlias()
109109
*/
110110
public function testDeprecationNoticeWhenReferencedByDefinition()
111111
{
112-
$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.');
112+
$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.');
113113
$container = new ContainerBuilder();
114114

115115
$container->register('foo', 'stdClass');
116116

117117
$aliasDeprecated = new Alias('foo');
118-
$aliasDeprecated->setDeprecated(true);
118+
$aliasDeprecated->setDeprecated('foobar', '1.2.3.4', '');
119119
$container->setAlias('foo_aliased', $aliasDeprecated);
120120

121121
$container

0 commit comments

Comments
 (0)