10000 bug #34451 [DependencyInjection] Fix dumping multiple deprecated alia… · chapa/symfony@996d8a7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 996d8a7

Browse files
committed
bug symfony#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 ------- 60b0dae [DependencyInjection] Fix dumping multiple deprecated aliases
2 parents a7c66db + 60b0dae commit 996d8a7

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ private function addDeprecatedAliases(): string
12261226
$methodNameAlias = $this->generateMethodName($alias);
12271227
$idExported = $this->export($id);
12281228
$messageExported = $this->export($definition->getDeprecationMessage($alias));
1229-
$code = <<<EOF
1229+
$code .= <<<EOF
12301230
12311231
/*{$this->docStar}
12321232
* Gets the $public '$alias' alias.

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,30 @@ public function testWither()
12831283
$wither = $container->get('wither');
12841284
$this->assertInstanceOf(Foo::class, $wither->foo);
12851285
}
1286+
1287+
/**
1288+
* @group legacy
1289+
* @expectedDeprecation The "deprecated1" service alias is deprecated. You should stop using it, as it will be removed in the future.
1290+
* @expectedDeprecation The "deprecated2" service alias is deprecated. You should stop using it, as it will be removed in the future.
1291+
*/
1292+
public function testMultipleDeprecatedAliasesWorking()
1293+
{
1294+
$container = new ContainerBuilder();
1295+
$container->setDefinition('bar', new Definition('stdClass'))->setPublic(true);
1296+
$container->setAlias('deprecated1', 'bar')->setPublic(true)->setDeprecated('%alias_id% is deprecated');
1297+
$container->setAlias('deprecated2', 'bar')->setPublic(true)->setDeprecated('%alias_id% is deprecated');
1298+
$container->compile();
1299+
1300+
$dumper = new PhpDumper($container);
1301+
$dump = $dumper->dump(['class' => $class = __FUNCTION__]);
1302+
1303+
eval('?>'.$dump);
1304+
$container = new $class();
1305+
1306+
$this->assertInstanceOf(\stdClass::class, $container->get('bar'));
1307+
$this->assertInstanceOf(\stdClass::class, $container->get('deprecated1'));
1308+
$this->assertInstanceOf(\stdClass::class, $container->get('deprecated2'));
1309+
}
12861310
}
12871311

12881312
class Rot13EnvVarProcessor implements EnvVarProcessorInterface

0 commit comments

Comments
 (0)
0