What will display this #PHP code?
No idea why someone could want to do that… but still interesting 😅
(Answer 🤫 https://3v4l.org/i7lf7#v8.2.11 )
A small #PHP trick, combining named parameters, spread and union arrays operators to « easily » create a modified copy of a DTO: https://3v4l.org/ZWX5G#v8.2.10
⚠️ It’s fun if you have a lot of parameters, but using a string containing the parameter’s name isn’t really satisfactory 😕
In #PHP, remember that « readonly » doesn’t necessarily imply immutability ⚠
Objects and references can be tricky…
#PHP tip: array_column function can also return a list of objects properties. Very useful now that we can create readonly properties in DTO