-
Notifications
You must be signed in to change notification settings - Fork 8k
Add func_get_named_args()
#19329
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
base: master
Are you sure you want to change the base?
Add func_get_named_args()
#19329
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. |
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.