3 ms·
Yeah, keyword arguments/named parameters. The most common way that we get to implement (hack) it now is by using an associative array, which then hides parame
by dolinsky 15y ago
Yeah, keyword arguments/named parameters.
The most common way that we get to implement (hack) it now is by using an associative array, which then hides parameters in the implementation of the method as opposed to exposing it in the interface which helps both with reading someone elses code as well as provides for parameter initialization and type hinting (which assoc arrays remove).
I agree with you about argument inconsistencies, and named parameters would help with that, but it even goes beyond that, e.g. how many times have you seen this:
function foo($bar = true, $baz = 5, $qux = "change me"){ ... }
foo(true,5,"this is what i wanted to change");
when all you should have to do is:
foo(qux="this is what i wanted to change");