Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e6fc82

Browse files
bug #46272 [DependencyInjection] Fix resolving parameters found in #[Autowire] (nicolas-grekas)
This PR was merged into the 6.1 branch. Discussion ---------- [DependencyInjection] Fix resolving parameters found in #[Autowire] | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - As reported by Andrew Barlow at https://symfony.com/blog/new-in-symfony-6-1-service-autowiring-attributes#comment-24967 Commits ------- c12b7f0 [DependencyInjection] Fix resolving parameters found in #[Autowire]
2 parents 2097544 + c12b7f0 commit 0e6fc82

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a
263263

264264
if (Autowire::class === $attribute->getName()) {
265265
$value = $attribute->newInstance()->value;
266+
$value = $this->container->getParameterBag()->resolveValue($value);
266267

267268
if ($value instanceof Reference && $parameter->allowsNull()) {
268269
$value = new Reference($value, ContainerInterface::NULL_ON_INVALID_REFERENCE);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ public function testAutowireAttribute()
11451145
$this->assertCount(8, $definition->getArguments());
11461146
$this->assertEquals(new Reference('some.id'), $definition->getArgument(0));
11471147
$this->assertEquals(new Expression("parameter('some.parameter')"), $definition->getArgument(1));
1148-
$this->assertSame('%some.parameter%/bar', $definition->getArgument(2));
1148+
$this->assertSame('foo/bar', $definition->getArgument(2));
11491149
$this->assertEquals(new Reference('some.id'), $definition->getArgument(3));
11501150
$this->assertEquals(new Expression("parameter('some.parameter')"), $definition->getArgument(4));
11511151
$this->assertSame('bar', $definition->getArgument(5));

0 commit comments

Comments
 (0)