Skip to content

Commit 263e6d1

Browse files
committed
bug symfony#21203 [DependencyInjection] moved up ResolveClassPass in the container pass list (fabpot)
This PR was merged into the 3.3-dev branch. Discussion ---------- [DependencyInjection] moved up ResolveClassPass in the container pass list | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | bug from symfony#21133 | License | MIT | Doc PR | n/a Some compiler passes need access to the service class names. But when using an empty class name (the service id being the class name), the resolution happens too late (during the optimization step). This PR fixes this by moving up the ResolveClassPass earlier in the stack. Commits ------- 2e5b69f [DependencyInjection] moved up ResolveClassPass in the container pass list
2 parents 95043b2 + 2e5b69f commit 263e6d1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ public function __construct()
3939
{
4040
$this->mergePass = new MergeExtensionConfigurationPass();
4141

42+
$this->beforeOptimizationPasses = array(
43+
100 => array(
44+
$resolveClassPass = new ResolveClassPass(),
45+
),
46+
);
47+
4248
$this->optimizationPasses = array(array(
4349
new ExtensionCompilerPass(),
44-
$resolveClassPass = new ResolveClassPass(),
4550
new ResolveDefinitionTemplatesPass(),
4651
new DecoratorServicePass(),
4752
new ResolveParameterPlaceHoldersPass(),

src/Symfony/Component/DependencyInjection/Tests/Compiler/PassConfigTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public function testPassOrdering()
2929
$pass2 = $this->getMockBuilder(CompilerPassInterface::class)->getMock();
3030
$config->addPass($pass2, PassConfig::TYPE_BEFORE_OPTIMIZATION, 30);
3131

32-
$this->assertSame(array($pass2, $pass1), $config->getBeforeOptimizationPasses());
32+
$passes = $config->getBeforeOptimizationPasses();
33+
$this->assertSame($pass2, $passes[1]);
34+
$this->assertSame($pass1, $passes[2]);
3335
}
3436
}

0 commit comments

Comments
 (0)