Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b38947a

Browse filesBrowse files
committed
Enable auto alias compiler pass by default
1 parent ae00ff4 commit b38947a
Copy full SHA for b38947a

File tree

2 files changed

+34
-0
lines changed
Filter options

2 files changed

+34
-0
lines changed

‎src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function __construct()
4949
];
5050

5151
$this->optimizationPasses = [[
52+
new AutoAliasServicePass(),
5253
new ValidateEnvPlaceholdersPass(),
5354
new ResolveChildDefinitionsPass(),
5455
new RegisterServiceSubscribersPass(),

‎src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,24 @@ public function testWither()
16011601
$wither = $container->get('wither');
16021602
$this->assertInstanceOf(Foo::class, $wither->foo);
16031603
}
1604+
1605+
public function testAutoAliasing()
1606+
{
1607+
$container = new ContainerBuilder();
1608+
$container->register(C::class);
1609+
$container->register(D::class);
1610+
1611+
$container->setParameter('foo', D::class);
1612+
1613+
$definition = new Definition(X::class);
1614+
$definition->setPublic(true);
1615+
$definition->addTag('auto_alias', ['format' => '%foo%']);
1616+
$container->setDefinition(X::class, $definition);
1617+
1618+
$container->compile();
1619+
1620+
$this->assertInstanceOf(D::class, $container->get(X::class));
1621+
}
16041622
}
16051623

16061624
class FooClass
@@ -1617,3 +1635,18 @@ public function __construct(A $a)
16171635
{
16181636
}
16191637
}
1638+
1639+
interface X
1640+
{
1641+
1642+
}
1643+
1644+
class C implements X
1645+
{
1646+
1647+
}
1648+
1649+
class D implements X
1650+
{
1651+
1652+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.