Re: [PHP-DEV] [RFC] Reclassifying engine warnings

  106770
August 28, 2019 19:48 smalyshev@gmail.com (Stanislav Malyshev)
Hi!

> Besides, we have tools available for years now to make this behaviour > more defined: > > $counts[$key] = ($counts[$key] ?? 0) + 1;
Sure, that works. But I don't see any way this clunker is better than $counts[$key]++ -- Stas Malyshev smalyshev@gmail.com
  106772
August 28, 2019 20:28 markyr@gmail.com (Mark Randall)
On 28/08/2019 20:48, Stanislav Malyshev wrote:
> Sure, that works. But I don't see any way this clunker is better than > $counts[$key]++
Because it's explicit, and incrementing null is mathematically unintuitive. After all, null does not exist anywhere in the set of natural numbers, so Roman etymology aside, adding 1 to it shouldn't magic it into a completely different type without some explicit cast. ?? Let's you go "I know this index may not exist, if it doesn't, use 0 instead". No funky type coercions that are in no way apparent from looking at the code. To use the analogy someone posted elsewhere... the training wheels are coming off. Time to be responsible and type those few extra characters to be clear on your intent. -- Mark Randall