Improved the deprecation messages for service aliases

This commit is contained in:
Javier Eguiluz 2016-10-07 13:16:58 +02:00 committed by Fabien Potencier
parent a4a68bc56c
commit b1b21bf43d
3 changed files with 6 additions and 6 deletions

View File

@ -505,13 +505,13 @@ EOF
{
foreach ($alias->attributes as $name => $node) {
if (!in_array($name, array('alias', 'id', 'public'))) {
@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);
@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);
}
}
foreach ($alias->childNodes as $child) {
if ($child instanceof \DOMElement && $child->namespaceURI === self::NS) {
@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);
@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);
}
}
}

View File

@ -180,7 +180,7 @@ class YamlFileLoader extends FileLoader
foreach ($service as $key => $value) {
if (!in_array($key, array('alias', 'public'))) {
@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);
@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);
}
}

View File

@ -563,9 +563,9 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
public function testAliasDefinitionContainsUnsupportedElements()
{
$deprecations = array(
'Using the attribute "class" is deprecated for alias definition "bar"',
'Using the element "tag" is deprecated for alias definition "bar"',
'Using the element "factory" is deprecated for alias definition "bar"',
'Using the attribute "class" is deprecated for the service "bar" which is defined as an alias',
'Using the element "tag" is deprecated for the service "bar" which is defined as an alias',
'Using the element "factory" is deprecated for the service "bar" which is defined as an alias',
);
ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () {