8000 Merge branch '4.3' into 4.4 · chapa/symfony@6f11058 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f11058

Browse files
Merge branch '4.3' into 4.4
* 4.3: [DependencyInjection] Fix dumping multiple deprecated aliases
2 parents 1b2651c + 996d8a7 commit 6f11058

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
@@ -1298,7 +1298,7 @@ private function addDeprecatedAliases(): string
12981298
$methodNameAlias = $this->generateMethodName($alias);
12991299
$idExported = $this->export($id);
13001300
$messageExported = $this->export($definition->getDeprecationMessage($alias));
1301-
$code = <<<EOF
1301+
$code .= <<<EOF
13021302
13031303
/*{$this->docStar}
13041304
* 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
@@ -1339,6 +1339,30 @@ public function testWither()
13391339
$wither = $container->get('wither');
13401340
$this->assertInstanceOf(Foo::class, $wither->foo);
13411341
}
1342+
1343+
/**
1344+
* @group legacy
1345+
* @expectedDeprecation The "deprecated1" service alias is deprecated. You should stop using it, as it will be removed in the future.
1346+
* @expectedDeprecation The "deprecated2" service alias is deprecated. You should stop using it, as it will be removed in the future.
1347+
*/
1348+
public function testMultipleDeprecatedAliasesWorking()
1349+
{
1350+
$container = new ContainerBuilder();
1351+
$container->setDefinition('bar', new Definition('stdClass'))->setPublic(true);
1352+
$container->setAlias('deprecated1', 'bar')->setPublic(true)->setDeprecated('%alias_id% is deprecated');
1353+
$container->setAlias('deprecated2', 'bar')->setPublic(true)->setDeprecated('%alias_id% is deprecated');
1354+
$container->compile();
1355+
1356+
$dumper = new PhpDumper($container);
1357+
$dump = $dumper->dump(['class' => $class = __FUNCTION__]);
1358+
1359+
eval('?>'.$dump);
1360+
$container = new $class();
1361+
1362+
$this->assertInstanceOf(\stdClass::class, $container->get('bar'));
1363+
$this->assertInstanceOf(\stdClass::class, $container->get('deprecated1'));
1364+
$this->assertInstanceOf(\stdClass::class, $container->get('deprecated2'));
1365+
}
13421366
}
13431367

13441368
class Rot13EnvVarProcessor implements EnvVarProcessorInterface

0 commit comments

Comments
 (0)
0