Movatterモバイル変換


[0]ホーム

URL:


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

[FrameworkBundle] Add support for union types on#[AsEventListener]#61252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@Fan2Shrek
Copy link
Contributor

QA
Branch?7.4
Bug fix?no
New feature?yes
Deprecations?no
IssuesFix#61218
LicenseMIT

This is an alternative implementation to support union types, related to issue#61218 and PR#61222.
It duplicateskernel.event_listener tags.

I'm not sure how to add tests for this — could you advise?

@carsonbotcarsonbot added this to the7.4 milestoneJul 27, 2025
@Fan2ShrekFan2Shrekforce-pushed thefix/as-event-listener-multiple-events branch from4f33247 toa69f5ddCompareJuly 27, 2025 20:55
@OskarStarkOskarStark changed the titleAdd support for union types on AsEventListenerAdd support for union types on#[AsEventListener]Jul 28, 2025
@carsonbotcarsonbot changed the titleAdd support for union types on#[AsEventListener][FrameworkBundle] Add support for union types on#[AsEventListener]Jul 28, 2025
@derrabus
Copy link
Member

I'm not sure how to add tests for this — could you advise?

There should be tests for theAsEventListener feature already. Have a look at them.

Copy link
Member

@derrabusderrabus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please add tests. 🙃

Fan2Shrek reacted with thumbs up emoji
@Fan2Shrek
Copy link
ContributorAuthor

Hi@derrabus, thanks for the reply!

The only tests I found are in RegisterListenerPassTest. Is that the right place to add mine?

@Fan2ShrekFan2Shrekforce-pushed thefix/as-event-listener-multiple-events branch froma69f5dd tob872df4CompareSeptember 24, 2025 12:58
@Fan2ShrekFan2Shrekforce-pushed thefix/as-event-listener-multiple-events branch 3 times, most recently from277aa0d to05c0d78CompareOctober 1, 2025 14:50
@fabpotfabpotforce-pushed thefix/as-event-listener-multiple-events branch from05c0d78 to5d7b14fCompareOctober 5, 2025 07:10
@fabpot
Copy link
Member

Thank you@Fan2Shrek.

Fan2Shrek reacted with thumbs up emoji

@fabpotfabpot merged commit40d3c4b intosymfony:7.4Oct 5, 2025
5 of 12 checks passed
This was referencedOct 27, 2025
nicolas-grekas added a commit that referenced this pull requestOct 29, 2025
…#[AsEventListener]` (HypeMC)This PR was merged into the 7.4 branch.Discussion----------[EventDispatcher][FrameworkBundle] Rework union types on `#[AsEventListener]`| Q             | A| ------------- | ---| Branch?       | 7.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Issues        | -| License       | MITThis is a reimplementation of#61252.The previous PR introduced a backward compatibility break.Consider the following listener:```phpfinal class TestListener{    #[AsEventListener(event: RequestEvent::class)]    public function onRequestEvent(): void    {        // ...    }}```In earlier versions, this worked fine, but now it throws:> AsEventListener attribute requires the first argument of "App\EventListener\TestListener::onRequestEvent()" to be an event object.Interestingly, there *was* a test for this scenario, but since each test method re-defines the `registerAttributeForAutoconfiguration()` closure (which wasn't updated everywhere), the tests still passed.Additionally, the implementation was added to the `FrameworkExtension`, even though similar logic already existed in `RegisterListenersPass::getEventFromTypeDeclaration()`, resulting in a decentralized implementation.This PR reverts the changes in `FrameworkExtension` and re-implements the feature in `RegisterListenersPass`.The tests now reuse the closure from `FrameworkExtension` to make them more robust and consistent with the actual implementation.Commits-------8ea7196 [EventDispatcher][FrameworkBundle] Rework union types on `#[AsEventListener]`
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@derrabusderrabusderrabus requested changes

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

7.4

Development

Successfully merging this pull request may close these issues.

#[AsEventListener] does not handle union types

5 participants

@Fan2Shrek@derrabus@fabpot@OskarStark@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp