bug #34451 [DependencyInjection] Fix dumping multiple deprecated aliases (shyim)
This PR was merged into the 4.3 branch.
Discussion
----------
[DependencyInjection] Fix dumping multiple deprecated aliases
| Q | A
| ------------- | ---
| Branch? | 4.3
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
Only the last deprecated alias wins, cause the content will not appended
Commits
-------
60b0dae174
[DependencyInjection] Fix dumping multiple deprecated aliases
This commit is contained in:
commit
996d8a708f
@ -1226,7 +1226,7 @@ EOF;
|
|||||||
$methodNameAlias = $this->generateMethodName($alias);
|
$methodNameAlias = $this->generateMethodName($alias);
|
||||||
$idExported = $this->export($id);
|
$idExported = $this->export($id);
|
||||||
$messageExported = $this->export($definition->getDeprecationMessage($alias));
|
$messageExported = $this->export($definition->getDeprecationMessage($alias));
|
||||||
$code = <<<EOF
|
$code .= <<<EOF
|
||||||
|
|
||||||
/*{$this->docStar}
|
/*{$this->docStar}
|
||||||
* Gets the $public '$alias' alias.
|
* Gets the $public '$alias' alias.
|
||||||
|
@ -1283,6 +1283,30 @@ class PhpDumperTest extends TestCase
|
|||||||
$wither = $container->get('wither');
|
$wither = $container->get('wither');
|
||||||
$this->assertInstanceOf(Foo::class, $wither->foo);
|
$this->assertInstanceOf(Foo::class, $wither->foo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation The "deprecated1" service alias is deprecated. You should stop using it, as it will be removed in the future.
|
||||||
|
* @expectedDeprecation The "deprecated2" service alias is deprecated. You should stop using it, as it will be removed in the future.
|
||||||
|
*/
|
||||||
|
public function testMultipleDeprecatedAliasesWorking()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->setDefinition('bar', new Definition('stdClass'))->setPublic(true);
|
||||||
|
$container->setAlias('deprecated1', 'bar')->setPublic(true)->setDeprecated('%alias_id% is deprecated');
|
||||||
|
$container->setAlias('deprecated2', 'bar')->setPublic(true)->setDeprecated('%alias_id% is deprecated');
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$dumper = new PhpDumper($container);
|
||||||
|
$dump = $dumper->dump(['class' => $class = __FUNCTION__]);
|
||||||
|
|
||||||
|
eval('?>'.$dump);
|
||||||
|
$container = new $class();
|
||||||
|
|
||||||
|
$this->assertInstanceOf(\stdClass::class, $container->get('bar'));
|
||||||
|
$this->assertInstanceOf(\stdClass::class, $container->get('deprecated1'));
|
||||||
|
$this->assertInstanceOf(\stdClass::class, $container->get('deprecated2'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Rot13EnvVarProcessor implements EnvVarProcessorInterface
|
class Rot13EnvVarProcessor implements EnvVarProcessorInterface
|
||||||
|
Reference in New Issue
Block a user