Le dimanche 16 octobre 2022, 23:11:05 CET Bob Weinand a écrit : > Hey, > > I've written a small RFC about adding coalesce ability to list() > destructuring. > > This should enhance the ability to easily, concisely and readably destructure > arrays with default values. > > https://wiki.php.net/rfc/destructuring_coalesce > <https://wiki.php.net/rfc/destructuring_coalesce> > > Bob
Hello, I voted no as the syntax is too confusing. It reads as if coalescing would happen on the var while it happens on the array value. It means $a ?? 'value' would mean something different when in a list context. It also looks wrong with keys: list("name" => $name ?? "unknown") = json_decode($json) ?: []; I would expect: list("name" ?? "unknown" => $name) = json_decode($json) ?: []; But event then it looks fishy since "name" is a key and "unknown" is a value. I understand the need but I just can’t see a good syntax for it, and the one chosen in the RFC sure feels not good enough for integration. Côme -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php