Easy Wither Call

By Benoit Viguier

Can be useful to create “with-ers” in an immutable (value) object with a LOT of readonly properties.

‘+’ is the addition of arrays, the first values have priority.

get_defined_vars() gets the local variables, with their name, unlike func_get_args().

Valid in PHP 8.1, with support for variadic and named keys.

../_images/easy_wither.png