-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Replace ArgumentValueResolverInterface by ValueResolverInterface #47363
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
Conversation
ab4880f
to
d1e236a
Compare
I really like this move 👍🏼 |
d1e236a
to
2f90368
Compare
src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php
Outdated
Show resolved
Hide resolved
2f90368
to
e9663cc
Compare
Thank you @nicolas-grekas. |
@@ -18,6 +18,8 @@ | |||
* Responsible for resolving the value of an argument based on its metadata. | |||
* | |||
* @author Iltar van der Berg <kjarli@gmail.com> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a bit late cr seeing the code is already merged but shouldn't we have some sort off:
trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s" interface is deprecated.', ValueResolverInterface::class);
to inform the user on code execution @nicolas-grekas ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DebugClassLoader will trigger it when you implement it, which is much better than triggering it when it is autoloaded (core classes still need to implement it for BC)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool is this the case for all interfaces that are deprecated when you are running debug mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
…luz) This PR was squashed before being merged into the 4.x branch. Discussion ---------- Add compatibility with ValueResolverInterface This avoids a deprecation when upgrading to Symfony 6.2. See symfony/symfony#47363 Commits ------- 497b39c Add compatibility with ValueResolverInterface
This PR was merged into the 2.2-dev branch. Discussion ---------- Implement ValueResolverInterface Follows symfony/symfony#47363 Commits ------- 0b54b85 Implement ValueResolverInterface
This PR was merged into the 5.x branch. Discussion ---------- Simplified the BatchActionDto value resolver The `ValueResolverInterface` was introduced in Symfony 6.2 (see symfony/symfony#47363), so we don't need to take care of the previous interface. Commits ------- 1d69f8d Simplified the BatchActionDto value resolver
Now that I looked at argument value resolvers more closely, I think that we can improve them a bit.
The issue I spotted is that by having two methods (
supports()
andresolve()
), we 1. require some correlation between both that isn't enforced by any contracts, 2. force some duplicate logic between the two and 3. as a consequence incur a needless perf overhead on the hotpath.I hereby propose to remove the
supports()
method and allowresolve()
to return the empty array instead, to signal that an argument is not supported by a specific value resolver.For perf also, I made all
resolve()
methods return arrays instead of generators, which are overhead in our cases.The changes to
EntityValueResolverTest
are a very good example at where the current design is fragile. Nothing prevents us from having de-correlatedsupports()
andresolve()
methods right now, and we felt into that trap.