Conversation
524abac to
895e6d6
Compare
|
Not too much of a fan of further expanding this kind of argument handling, but just my personal opinion. The name sounds a bit ambiguous due to "named args", makes it sound like only arguments that were passed by name would be returned. Maybe |
|
An additional use case is that we often use this args handling in Symfony to add new args to methods without breaking backward compatibility between minor versions. About the naming: your proposition would also suit me fine. |
4a29d16 to
4219f23
Compare
|
Slightly related to #11517 (patch also included) |
|
I'd love to see this! |
4219f23 to
9d09f73
Compare
|
any news about this? |
|
Still on my list but forgot about it. I'll work on it again soon 🙂 |
|
After reading the issue linked by @ndossche, I think this would deserve an RFC as it seems a bit controversial. Let's add the label so I don't forget and will try to make something up when I have some bandwidth. |
|
After spending some time on this one trying to write the right RFC and justifications, I don't feel I have enough strong arguments to defend this new feature. The more I dive into it, the more it feels like a nice-to-have, which isn't enough to me to spend time arguing about it in the internal list. If anyone feels like it, don't hesitate to take over this topic. 🙂 |
|
Thanks for the effort, @alexandre-daubois ❤️ It would be extremely useful, as it would save me a significant amount of boilerplate code. |
I'm still a bit more fond of the idea I proposed ~2 years ago, along with an (by now outdated) PoC implementation: #11517 (comment) |
|
@Lukasss93 FWIU, the problem is also not really the implementation but going through the RFC process (which anybody is free to do). See https://wiki.php.net/rfc/howto, if you're interested in doing that. I think this implementation is also over-optimized. I don't think we need the specialized opcode. |
I'm not entirely sure this would require a RFC. That's why I'm proposing this PR first, and I'll gladly write an RFC if someone requires it.
Allows to write the following code:
Output:
I think this would be a nice addition. With named arguments being more and more popular and the possibility to leverage arrays spreading operator, adding this function feels natural. There's no easy way to do so currently without using reflection.
They differ a bit on they behavior with spread operator and variadic argument:
Adding this function instead of updating
func_get_args()seems better to me, which avoids any breaking change.