Re: [RFC] Reclassifying engine warnings
| From: | Robert Korulczyk | Date: | Fri, 13 Sep 2019 09:02:57 +0000 |
| Subject: | Re: [RFC] Reclassifying engine warnings | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-107062@lists.php.net to get a copy of this message | ||
> Why? If "assume $key2 exists as a key and is an integer" is so bad that PHP should
> halt my program, why should "assume $key1 exists and is an array"
> be perfectly OK?
Warning is triggered by reading non-existing key, not assigning value to it. In
$foo[$key1][$key2] ??= 0 you never try to read non-existing key.
> Please can you show me a bug that adding this line has avoided? I don't doubt that the
> same warning saves bugs in other scenarios, but in this
> scenario, the logic is unambiguous, and any additions are just to suppress unnecessary errors.
Well, then let's say that it is "lesser evil" - one additional line is better than
ignoring reading uninitialized values. And IMO it is not a
"problem" that would justify introducing special syntax for saving one line in such niche
case.
Regards,
Robert Korulczyk