Combining named-parameter
array()
syntax with clone taking a array as
the second parameter would allow for the following, which might combine
the best of both worlds?
clone($obj, array(foo: 1, bar: "baz", object: "this is not blocked"));
I really like this idea! If it can work without any function call overhead,
it would enable more ergonomic array creation not only for
clone()
but
also in many other common scenarios.
Yes, the implementation in the PR comes without any function call overhead. The logic to support the named parameters is purely implemented in the parser. The actual function implementation is provided to “round off” the implementation and because it was super simple to add.
Best regards
Tim Düsterhus