Skip to content

Commit 0b1e1c4

Browse files
javiereguiluzfabpot
authored andcommitted
Improved the deprecation messages for service aliases
1 parent 80717a8 commit 0b1e1c4

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Loader/XmlFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,13 +505,13 @@ private function validateAlias(\DOMElement $alias, $file)
505505
{
506506
foreach ($alias->attributes as $name => $node) {
507507
if (!in_array($name, array('alias', 'id', 'public'))) {
508-
@trigger_error(sprintf('Using the attribute "%s" is deprecated for alias definition "%s" in "%s". Allowed attributes are "alias", "id" and "public". The XmlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported attributes.', $name, $alias->getAttribute('id'), $file), E_USER_DEPRECATED);
508+
@trigger_error(sprintf('Using the attribute "%s" is deprecated for the service "%s" which is defined as an alias in "%s". Allowed attributes for service aliases are "alias", "id" and "public". The XmlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported attributes.', $name, $alias->getAttribute('id'), $file), E_USER_DEPRECATED);
509509
}
510510
}
511511

512512
foreach ($alias->childNodes as $child) {
513513
if ($child instanceof \DOMElement && $child->namespaceURI === self::NS) {
514-
@trigger_error(sprintf('Using the element "%s" is deprecated for alias definition "%s" in "%s". The XmlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported elements.', $child->localName, $alias->getAttribute('id'), $file), E_USER_DEPRECATED);
514+
@trigger_error(sprintf('Using the element "%s" is deprecated for the service "%s" which is defined as an alias in "%s". The XmlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported elements.', $child->localName, $alias->getAttribute('id'), $file), E_USER_DEPRECATED);
515515
}
516516
}
517517
}

Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private function parseDefinition($id, $service, $file)
180180

181181
foreach ($service as $key => $value) {
182182
if (!in_array($key, array('alias', 'public'))) {
183-
@trigger_error(sprintf('The configuration key "%s" is unsupported for alias definition "%s" in "%s". Allowed configuration keys are "alias" and "public". The YamlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported attributes.', $key, $id, $file), E_USER_DEPRECATED);
183+
@trigger_error(sprintf('The configuration key "%s" is unsupported for the service "%s" which is defined as an alias in "%s". Allowed configuration keys for service aliases are "alias" and "public". The YamlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported attributes.', $key, $id, $file), E_USER_DEPRECATED);
184184
}
185185
}
186186

Tests/Loader/XmlFileLoaderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,9 @@ public function testAutowire()
563563
public function testAliasDefinitionContainsUnsupportedElements()
564564
{
565565
$deprecations = array(
566-
'Using the attribute "class" is deprecated for alias definition "bar"',
567-
'Using the element "tag" is deprecated for alias definition "bar"',
568-
'Using the element "factory" is deprecated for alias definition "bar"',
566+
'Using the attribute "class" is deprecated for the service "bar" which is defined as an alias',
567+
'Using the element "tag" is deprecated for the service "bar" which is defined as an alias',
568+
'Using the element "factory" is deprecated for the service "bar" which is defined as an alias',
569569
);
570570

571571
ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () {

0 commit comments

Comments
 (0)