Skip to content

Commit 94030d3

Browse files
committed
minor #21470 [FrameworkBundle] Add support for union types on #[AsEventListener] (alamirault)
This PR was merged into the 7.4 branch. Discussion ---------- [FrameworkBundle] Add support for union types on `#[AsEventListener]` Fix #21467 Commits ------- d02feaa [FrameworkBundle] Add support for union types on #[AsEventListener]
2 parents 2478be4 + d02feaa commit 94030d3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

event_dispatcher.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ can also be applied to methods directly::
210210
// ...
211211
}
212212

213+
#[AsEventListener]
214+
public function onMultipleCustomEvent(CustomEvent|AnotherCustomEvent $event): void
215+
{
216+
// ...
217+
}
218+
213219
#[AsEventListener(event: 'foo', priority: 42)]
214220
public function onFoo(): void
215221
{
@@ -228,6 +234,10 @@ can also be applied to methods directly::
228234
Note that the attribute doesn't require its ``event`` parameter to be set
229235
if the method already type-hints the expected event.
230236

237+
.. versionadded:: 7.4
238+
239+
The support for union types in the method type-hints was introduced in Symfony 7.4.
240+
231241
.. _events-subscriber:
232242

233243
Creating an Event Subscriber

0 commit comments

Comments
 (0)