Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

how to generate function(GuardEvent|TransitionEvent) {... #177

tacman started this conversation in General
Discussion options

I'm trying to generate

public function getRow(GuardEvent|TransitionEvent $event): Row

but I can't figure out how to add more than one type. I see setType, but not addType or setTypes()

 $parameter = $method
 ->addParameter('event');
 $parameter
 ->setType(GuardEvent::class)
 ->setType(TransitionEvent::class);

Is there a way to do this? Thx.

You must be logged in to vote

Replies: 1 comment

Comment options

Found it! Type::union

 $parameter = $method
 ->addParameter('event');
 $parameter
 ->setType(Type::union(TransitionEvent::class, GuardEvent::class));
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #176 on March 01, 2025 20:10.

AltStyle によって変換されたページ (->オリジナル) /