Skip to content

Commit 652e8b5

Browse files
committed
Merge branch '7.4' into 8.0
* 7.4: fix merge [FrameworkBundle] Remove extra argument from ContainerBuilder::willBeAvailable call fix ext-redis 6.2.0 compatibility [CssSelector] Fix incorrect return type for Token::getType() [Workflow] State contamination due to class-based setter cache fix: fixed State contamination in marking stores due to class-based getter cache [Validator] Fix call to undefined getParser() in YamlValidator [ObjectMapper] Update Map attribute PHPDoc to match TransformCallableInterface signature fix tests Fix contentId assignment for inline attachments [HtmlSanitizer] Remove `srcdoc` from allowed attributes [EventDispatcher][FrameworkBundle] Rework union types on `#[AsEventListener]`
2 parents aabe16e + fb9c1e8 commit 652e8b5

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -706,32 +706,13 @@ public function load(array $configs, ContainerBuilder $container): void
706706

707707
$container->registerAttributeForAutoconfiguration(AsEventListener::class, static function (ChildDefinition $definition, AsEventListener $attribute, \ReflectionClass|\ReflectionMethod $reflector) {
708708
$tagAttributes = get_object_vars($attribute);
709-
710-
if (!$reflector instanceof \ReflectionMethod) {
711-
$definition->addTag('kernel.event_listener', $tagAttributes);
712-
713-
return;
714-
}
715-
716-
if (isset($tagAttributes['method'])) {
717-
throw new LogicException(\sprintf('AsEventListener attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));
718-
}
719-
720-
$tagAttributes['method'] = $reflector->getName();
721-
722-
if (!$eventArg = $reflector->getParameters()[0] ?? null) {
723-
throw new LogicException(\sprintf('AsEventListener attribute requires the first argument of "%s::%s()" to be an event object.', $reflector->class, $reflector->name));
724-
}
725-
726-
$types = ($type = $eventArg->getType() instanceof \ReflectionUnionType ? $eventArg->getType()->getTypes() : [$eventArg->getType()]) ?: [];
727-
728-
foreach ($types as $type) {
729-
if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) {
730-
$tagAttributes['event'] = $type->getName();
731-
732-
$definition->addTag('kernel.event_listener', $tagAttributes);
709+
if ($reflector instanceof \ReflectionMethod) {
710+
if (isset($tagAttributes['method'])) {
711+
throw new LogicException(\sprintf('AsEventListener attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));
733712
}
713+
$tagAttributes['method'] = $reflector->getName();
734714
}
715+
$definition->addTag('kernel.event_listener', $tagAttributes);
735716
});
736717
$container->registerAttributeForAutoconfiguration(AsController::class, static function (ChildDefinition $definition, AsController $attribute): void {
737718
$definition->addTag('controller.service_arguments');
@@ -2152,7 +2133,7 @@ private function registerPropertyInfoConfiguration(array $config, ContainerBuild
21522133
$definition->addTag('property_info.constructor_extractor', ['priority' => -1000]);
21532134
}
21542135

2155-
if (ContainerBuilder::willBeAvailable('phpdocumentor/reflection-docblock', DocBlockFactoryInterface::class, ['symfony/framework-bundle', 'symfony/property-info'], true)) {
2136+
if (ContainerBuilder::willBeAvailable('phpdocumentor/reflection-docblock', DocBlockFactoryInterface::class, ['symfony/framework-bundle', 'symfony/property-info'])) {
21562137
$definition = $container->register('property_info.php_doc_extractor', PhpDocExtractor::class);
21572138
$definition->addTag('property_info.description_extractor', ['priority' => -1000]);
21582139
$definition->addTag('property_info.type_extractor', ['priority' => -1001]);

0 commit comments

Comments
 (0)