8000 [DependencyInjection] Fix resolving parameters found in #[Autowire] by nicolas-grekas · Pull Request #46272 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DependencyInjection] Fix resolving parameters found in #[Autowire] #46272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[DependencyInjection] Fix resolving parameters found in #[Autowire]
  • Loading branch information
nicolas-grekas committed May 5, 2022
commit c12b7f0fa0c5f79a627b08e08ce0a964b97e269d
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a

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

if ($value instanceof Reference && $parameter->allowsNull()) {
$value = new Reference($value, ContainerInterface::NULL_ON_INVALID_REFERENCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ public function testAutowireAttribute()
$this->assertCount(8, $definition->getArguments());
$this->assertEquals(new Reference('some.id'), $definition->getArgument(0));
$this->assertEquals(new Expression("parameter('some.parameter')"), $definition->getArgument(1));
$this->assertSame('%some.parameter%/bar', $definition->getArgument(2));
$this->assertSame('foo/bar', $definition->getArgument(2));
$this->assertEquals(new Reference('some.id'), $definition->getArgument(3));
$this->assertEquals(new Expression("parameter('some.parameter')"), $definition->getArgument(4));
$this->assertSame('bar', $definition->getArgument(5));
Expand Down
0