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

[HttpKernel] Do not ignore enum in controller arguments when it has an#[Autowire] attribute#60165

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

ruudk
Copy link
Contributor

@ruudkruudk commentedApr 7, 2025
edited
Loading

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
Issues
LicenseMIT

When moving services injected from the constructor to the controller arguments, I noticed a bug.

We were auto wiring an env var to a backed enum like this:

class Foo{publicfunction__construct(        #[Autowire(env:'enum:App\Enum:SOME_ENV_KEY')]private\App\Enum$someEnum,    ) {}publicfunction__invoke() {}}

This works fine with normal Symfony Dependency Injection.

But when we switch to controller arguments like this:

class Foo{publicfunction__invoke(        #[Autowire(env:'enum:App\Enum:SOME_ENV_KEY')]\App\Enum$someEnum,    ) {}}

This stops working.

The issue is that BackedEnum's are excluded. But this should only be excluded when there is no Autowire attribute.

@nicolas-grekas

This comment was marked as outdated.

…entLocatorsPassWhen moving services injected from the constructor to the controller arguments, I noticed a bug.We were auto wiring an env var to a backed enum like this:```phpclass Foo{    public function __construct(        #[Autowire(env: 'enum:App\Enum:SOME_ENV_KEY')]        private \App\Enum $someEnum,    ) {}    public function __invoke() {}}```This works fine with normal Symfony Dependency Injection.But when we switch to controller arguments like this:```phpclass Foo{    public function __invoke(        #[Autowire(env: 'enum:App\Enum:SOME_ENV_KEY')]        \App\Enum $someEnum,    ) {}}```This stops working.The issue is that BackedEnum's are excluded. But this should only be excluded when there is no Autowire attribute.
@ruudkruudkforce-pushed the6.4-fix-autowire-on-unit-enum branch fromfa93de7 to5d6a211CompareApril 7, 2025 09:51
@ruudk

This comment was marked as outdated.

@nicolas-grekasnicolas-grekas changed the title[HttpKernel] Do not ignore enum in controller arguments when it has an#Autowire] attribute[HttpKernel] Do not ignore enum in controller arguments when it has an#[Autowire] attributeApr 7, 2025
@symfonysymfony deleted a comment fromcarsonbotApr 7, 2025
@nicolas-grekas
Copy link
Member

Thank you@ruudk.

@nicolas-grekasnicolas-grekas merged commitea60073 intosymfony:6.4Apr 7, 2025
8 of 11 checks passed
This was referencedMay 2, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@alexandre-dauboisalexandre-dauboisalexandre-daubois approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
6.4
Development

Successfully merging this pull request may close these issues.

4 participants
@ruudk@nicolas-grekas@alexandre-daubois@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp