Skip to content

[Messenger] #[AsMessageHandler] with union type doesn't compile #47206

Closed
@alex-dev

Description

@alex-dev

Symfony version(s) affected

6.0

Description

Having a #[AsMessageHandler] on a method (except __invoke) taking a union will prevent compilation.

How to reproduce

#[AsMessageHandler]
public function method(A|B $message): void {}

Possible Solution

In the MessengerPass::guessHandledClasses() method, every path except the one dealing with union types return if method is known array<class-string, method> else array<int, class-string>. Code path dealing with unions does not.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions