Skip to content

Commit b115c8b

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [VarExporter] Suppress deprecations for legacy fixtures Bump Symfony version to 5.3.8 Update VERSION for 5.3.7 Update CHANGELOG for 5.3.7 Bump Symfony version to 4.4.31 Update VERSION for 4.4.30 Update CONTRIBUTORS for 4.4.30 Update CHANGELOG for 4.4.30 [Form] minor cs fix [DependencyInjection] Autoconfigurable attributes on methods, properties and parameters
2 parents 1730e24 + 794b5e1 commit b115c8b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,15 @@ public function load(array $configs, ContainerBuilder $container)
557557
$container->registerForAutoconfiguration(LoggerAwareInterface::class)
558558
->addMethodCall('setLogger', [new Reference('logger')]);
559559

560-
$container->registerAttributeForAutoconfiguration(AsEventListener::class, static function (ChildDefinition $definition, AsEventListener $attribute): void {
561-
$definition->addTag('kernel.event_listener', get_object_vars($attribute));
560+
$container->registerAttributeForAutoconfiguration(AsEventListener::class, static function (ChildDefinition $definition, AsEventListener $attribute, \Reflector $reflector) {
561+
$tagAttributes = get_object_vars($attribute);
562+
if ($reflector instanceof \ReflectionMethod) {
563+
if (isset($tagAttributes['method'])) {
564+
throw new LogicException(sprintf('AsEventListener attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));
565+
}
566+
$tagAttributes['method'] = $reflector->getName();
567+
}
568+
$definition->addTag('kernel.event_listener', $tagAttributes);
562569
});
563570
$container->registerAttributeForAutoconfiguration(AsController::class, static function (ChildDefinition $definition, AsController $attribute): void {
564571
$definition->addTag('controller.service_arguments');

0 commit comments

Comments
 (0)