Re: [RFC] Warnings for PHP 8.5
| From: | Tim Düsterhus | Date: | Wed, 23 Jul 2025 13:00:49 +0000 |
| Subject: | Re: [RFC] Warnings for PHP 8.5 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128190@lists.php.net to get a copy of this message | ||
Hi
Am 2025-07-23 13:30, schrieb Nicolas Grekas:
It seems appropriate to mention the previous (declined) “Destructuring Coalesce” RFC at this point: https://wiki.php.net/rfc/destructuring_coalesce. Perhaps it might make sense to revisit that one? Best regards Tim DüsterhusAbout destructuring non-array values, null is a very common case that allows writing nice readable code. Here is a dummy example: if ([$a, $b] = $array[$key] ?? null) { /*...*/ } Turning this into a warning will have a significant impact for sure. Even a deprecation would just make the language a bit less pleasant to use without any real benefit, unless I missed any other rationale. If you want to provide default values, then surely: if ([$a, $b] = $array[$key] ?? [null, null]) makes more sense, especially as this allows you to choice different defaults for $a and $b.That's broken, the "if" will always be truthy using this style. There's nothing wrong with the current code. It doesn't need to be deprecated.