Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
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 OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
33e16e2 to89232eeCompareMember
nicolas-grekas commentedDec 28, 2021
Thank you@ogizanagi. |
nicolas-grekas added a commit that referenced this pull requestDec 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#44834While:```yml# services.yamlservices: _defaults: autowire: true autoconfigure: true bind: $myParam: !php/const App\Status::Deleted```is working for me, the following isn't:```diff# services.yamlservices: _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 referencedDec 29, 2021
Merged
Merged
Merged
Merged
ogizanagi added a commit to Elao/PhpEnums that referenced this pull requestDec 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 resolvers3e04d71 [HttpKernel] Add V2 BackedEnumValueResolver to resolve controllers args
Sign up for freeto 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.
Uh oh!
There was an error while loading.Please reload this page.
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
DefaultValueResolveruse the default value (or another resolver to try).Currently, the
DefaultValueResolverwouldn't be reached since theServiceValueResolverwould throw the above exception.