Hi
Am 2025-05-21 16:27, schrieb Nicolas Grekas:
Thanks for sharing your insights. This looks a bit far reaching for the
RFC.
Making `array()` a function / allowing named parameter syntax with
`array()` would be a separate RFC.
On my side, my opinion is: don't make clone a function call. I've never
missed not being able to call clone as a callback. It's trivial to
write a
short function using the operator when in need.
It's an intentional design goal of this RFC to borrow the function call
syntax to avoid inventing something that does not yet exist in PHP and
to avoid blocking additional keywords (“with”). Making `clone()` an
actual function greatly simplifies the implementation, since all the
heavy lifting around parameter parsing is already provided by the engine
[1] and it also ensures that the behavior is consistent with the
behavior implied by the used syntax. If the second parameter would be a
regular array rather than using the named parameter syntax, making
clone() a function would not be necessary (but wouldn't make things
harder either).
Best regards
Tim Düsterhus
[1] As an example, with the currently proposed named parameter syntax,
unpacking arbitrary Traversables with `clone($obj, ...$traversable)`
would need to be reimplemented specifically for `clone()`.