11

PHP now has named arguments. Welcome to the 20th century.

Comments
  • 1
    Awesome
  • 10
    Funny enough, it's one of the the things I really hate.

    It's an ambiguation for the sake of simplification.

    I'm not really fond of it in Python, too btw.

    What happens can be seen in Python.

    You have functions with too many parameters and as such are variadic...

    And since they're variadic, you'll have a shitton of fun figuring out required vs non required arguments, typing errors (null? 0? empty string?) to set required arguments to a value and so on.

    The trend to syntactic sugar is a thing that will lead to bad code TM...

    And most of it is to save a few keystrokes.

    The constructor syntax eg is imho a nightmare. It looks shit.
  • 5
    Can’t say I’ve ever missed named arguments in PHP. In fact, I stand with @IntrusionCM here that it’s one of those things they maybe should’ve just left out..
  • 1
    Things have been said already and I love that JS doesn’t have it. Just use objects instead if it’s really needed.
  • 1
    Yep, same for me, I also hate it in python, good luck figuring out which args are required..
  • 4
    I don't have an issue with named arguments in itself, but the inevitable consequence is people feel entirely justified in writing functions with 10+ arguments because "hey, they're all named so it's clear, right?!"

    The last thing the average PHP dev needs is an excuse to write crappier code.
  • 2
    If you need independently optional arguments, just use an options object. Named arguments don't work well in python and the only scenario where I can imagine they're good is if you want independently optional arguments in a strictly typed language without defining a struct.
  • 0
    I love the idea. As 'function($required, null, true);' is not really descriptive but I'm afraid that it is going to be abused.

    Any code that has a boolean flag is probably a named parameter in my PHP 8 code.
  • 3
    Named arguments is for amateurs and any need for it shows that the code is badly written.
  • 0
    Named arguments? Doesn’t seem to make any sense
  • 0
    Fuck named arguments. This will be a damn mess.
Add Comment