diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index d473a2e6b0..6e9e3fd4ac 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -157,7 +157,7 @@ public function process(ContainerBuilder $container): void continue; } elseif (!$autowire || (!($autowireAttributes ??= $p->getAttributes(Autowire::class, \ReflectionAttribute::IS_INSTANCEOF)) && (!$type || '\\' !== $target[0]))) { continue; - } elseif (is_subclass_of($type, \UnitEnum::class)) { + } elseif (!$autowireAttributes && is_subclass_of($type, \UnitEnum::class)) { // do not attempt to register enum typed arguments if not already present in bindings continue; } elseif (!$p->allowsNull()) { diff --git a/Kernel.php b/Kernel.php index d2e1eda84c..12f65d3a89 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,11 +73,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.5'; - public const VERSION_ID = 70205; + public const VERSION = '7.2.6'; + public const VERSION_ID = 70206; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 5; + public const RELEASE_VERSION = 6; public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2025'; diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index 02b5df6512..af6d49d29c 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -503,13 +503,14 @@ public function testAutowireAttribute() $locator = $container->get($locatorId)->get('foo::fooAction'); - $this->assertCount(9, $locator->getProvidedServices()); + $this->assertCount(10, $locator->getProvidedServices()); $this->assertInstanceOf(\stdClass::class, $locator->get('service1')); $this->assertSame('foo/bar', $locator->get('value')); $this->assertSame('foo', $locator->get('expression')); $this->assertInstanceOf(\stdClass::class, $locator->get('serviceAsValue')); $this->assertInstanceOf(\stdClass::class, $locator->get('expressionAsValue')); $this->assertSame('bar', $locator->get('rawValue')); + $this->stringContains('Symfony_Component_HttpKernel_Tests_Fixtures_Suit_APP_SUIT', $locator->get('suit')); $this->assertSame('@bar', $locator->get('escapedRawValue')); $this->assertSame('foo', $locator->get('customAutowire')); $this->assertInstanceOf(FooInterface::class, $autowireCallable = $locator->get('autowireCallable')); @@ -752,6 +753,8 @@ public function fooAction( \stdClass $expressionAsValue, #[Autowire('bar')] string $rawValue, + #[Autowire(env: 'enum:\Symfony\Component\HttpKernel\Tests\Fixtures\Suit:APP_SUIT')] + Suit $suit, #[Autowire('@@bar')] string $escapedRawValue, #[CustomAutowire('some.parameter')]