[DependencyInjection] Fix alias deprecations with package and version
This commit is contained in:
parent
09dcbfcab0
commit
5ee5654171
@ -63,7 +63,7 @@ class ResolveReferencesToAliasesPass extends AbstractRecursivePass
|
|||||||
|
|
||||||
if ($alias->isDeprecated()) {
|
if ($alias->isDeprecated()) {
|
||||||
$deprecation = $alias->getDeprecation($id);
|
$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 = [];
|
$seen = [];
|
||||||
|
@ -230,7 +230,7 @@ class XmlDumper extends Dumper
|
|||||||
if ($id->isDeprecated()) {
|
if ($id->isDeprecated()) {
|
||||||
$deprecation = $id->getDeprecation('%alias_id%');
|
$deprecation = $id->getDeprecation('%alias_id%');
|
||||||
$deprecated = $this->document->createElement('deprecated');
|
$deprecated = $this->document->createElement('deprecated');
|
||||||
$deprecated->setAttribute('message', $deprecation['message']);
|
$deprecated->appendChild($this->document->createTextNode($deprecation['message']));
|
||||||
$deprecated->setAttribute('package', $deprecation['package']);
|
$deprecated->setAttribute('package', $deprecation['package']);
|
||||||
$deprecated->setAttribute('version', $deprecation['version']);
|
$deprecated->setAttribute('version', $deprecation['version']);
|
||||||
|
|
||||||
|
@ -89,13 +89,13 @@ class ResolveReferencesToAliasesPassTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDeprecationNoticeWhenReferencedByAlias()
|
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 = new ContainerBuilder();
|
||||||
|
|
||||||
$container->register('foo', 'stdClass');
|
$container->register('foo', 'stdClass');
|
||||||
|
|
||||||
$aliasDeprecated = new Alias('foo');
|
$aliasDeprecated = new Alias('foo');
|
||||||
$aliasDeprecated->setDeprecated(true);
|
$aliasDeprecated->setDeprecated('foobar', '1.2.3.4', '');
|
||||||
$container->setAlias('deprecated_foo_alias', $aliasDeprecated);
|
$container->setAlias('deprecated_foo_alias', $aliasDeprecated);
|
||||||
|
|
||||||
$alias = new Alias('deprecated_foo_alias');
|
$alias = new Alias('deprecated_foo_alias');
|
||||||
@ -109,13 +109,13 @@ class ResolveReferencesToAliasesPassTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDeprecationNoticeWhenReferencedByDefinition()
|
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 = new ContainerBuilder();
|
||||||
|
|
||||||
$container->register('foo', 'stdClass');
|
$container->register('foo', 'stdClass');
|
||||||
|
|
||||||
$aliasDeprecated = new Alias('foo');
|
$aliasDeprecated = new Alias('foo');
|
||||||
$aliasDeprecated->setDeprecated(true);
|
$aliasDeprecated->setDeprecated('foobar', '1.2.3.4', '');
|
||||||
$container->setAlias('foo_aliased', $aliasDeprecated);
|
$container->setAlias('foo_aliased', $aliasDeprecated);
|
||||||
|
|
||||||
$container
|
$container
|
||||||
|
Reference in New Issue
Block a user