-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Do not attempt to register enum arguments in controller service locator #44826
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nicolas-grekas
merged 1 commit into
symfony:4.4
from
ogizanagi:service-value-resolver-enum
Dec 28, 2021
Merged
[HttpKernel] Do not attempt to register enum arguments in controller service locator #44826
nicolas-grekas
merged 1 commit into
symfony:4.4
from
ogizanagi:service-value-resolver-enum
Dec 28, 2021
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php
Outdated
Show resolved
Hide resolved
stloyd
reviewed
Dec 28, 2021
src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php
Outdated
Show resolved
Hide resolved
33e16e2
to
89232ee
Compare
Thank you @ogizanagi. |
nicolas-grekas
added a commit
that referenced
this pull request
Dec 29, 2021
…(ogizanagi) This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection][HttpKernel] Fix enum typed bindings | Q | A | ------------- | --- | Branch? | 4.4 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | N/A <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Relates to #44834 While: ```yml # services.yaml services: _defaults: autowire: true autoconfigure: true bind: $myParam: !php/const App\Status::Deleted ``` is working for me, the following isn't: ```diff # services.yaml services: _defaults: autowire: true autoconfigure: true bind: - $myParam: !php/const App\Status::Deleted + App\Status $myParam: !php/const App\Status::Deleted ``` -> > Invalid value for binding key "App\Status $myParam" for service […]: expected "Symfony\Component\DependencyInjection\Reference", "Symfony\Component\DependencyInjection\Definition", "Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument", "Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument" or null, "App\Status" given. This attempts to fix it by accounting for `\UnitEnum` in the `ResolveBindingPass`, as well as re-allowing enum types already present in bindings after #44826. Commits ------- c32d749 [DependencyInjection][HttpKernel] Fix enum typed bindings
3 tasks
This was referenced Dec 29, 2021
Merged
Merged
Merged
Merged
ogizanagi
added a commit
to Elao/PhpEnums
that referenced
this pull request
Dec 30, 2021
…ed enums (ogizanagi) This PR was squashed before being merged into the 2.x-dev branch. Discussion ---------- [HttpKernel] Add a controller argument resolver for backed enums - [x] Add tests - [x] Docs - [x] Rework to streamline the resolver with Symfony 6.1 core PR (only attributes, aims route params, 404, …) + alternative query/body resolver specific to this library. Fixed (symfony/symfony#44826): An issue with Symfony's `ServiceValueResolver` prevents from letting the `DefaultValueResolver` to use the default enum value if the argument is not nullable. Perhaps add: ```php if (enum_exists($argument->getType())) { return false; } ``` in `\Symfony\Component\HttpKernel\Controller\ArgumentResolver\ServiceValueResolver::supports` as a bug fix? Fix in `RegisterControllerArgumentLocatorsPass` ? Commits ------- 564058a Streamline with future Symfony 6.1 resolver + query/body resolvers 3e04d71 [HttpKernel] Add V2 BackedEnumValueResolver to resolve controllers args
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Given:
and the controller:
you get:
which would be annoying in case you have a resolver registered to resolve this argument, but won't support this specific request, hence expect to let the
DefaultValueResolver
use the default value (or another resolver to try).Currently, the
DefaultValueResolver
wouldn't be reached since theServiceValueResolver
would throw the above exception.