Re: [RFC] Reclassifying engine warnings

From: Date: Thu, 12 Sep 2019 14:25:35 +0000
Subject: Re: [RFC] Reclassifying engine warnings
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-106960@lists.php.net to get a copy of this message
<http://ocramius.github.com/> On Thu, Sep 12, 2019 at 4:02 PM Arvids Godjuks <arvids.godjuks@gmail.com> wrote: > > > чт, 12 сент. 2019 г. в 15:33, Marco Pivetta <ocramius@gmail.com>: > >> Hey Rowan, >> <http://ocramius.github.com/> >> >> >> On Thu, Sep 12, 2019 at 3:30 PM Rowan Tommins <rowan.collins@gmail.com> >> wrote: >> >> > For instance, for undefined array keys, what if we had an operator for >> > "initialise and retrieve", such as $foo[? 'bar']. Then we could >> > simplify >> > ugly code like this: >> > >> > if ( ! isset($foo[$key1]) { >> > $foo[$key1] = []; >> > } >> > if ( ! isset($foo[$key1][$key2]) { >> > $foo[$key1][$key2] = 0; >> > } >> > $foo[$key1][$key2]++; >> > >> > >> > With something safe but succinct like this: >> > >> > $foo[? $key1][? $key2]++; >> > >> >> $foo[$key1][$key2] = ($foo[$key1][$key2] ?? 0) + 1; >> >> >> > This message contains a healthy dose of sarcasm. > > No sarcasm intended: question is about the verbosity and length of a *proper* (correct = no warnings/notices/errors, matches type expectations) checked solution, and I provided a simple one-liner that is both readable and correct. You can make what you want out of this, but there was most certainly no sarcasm. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/

« previous php.internals (#106960) next »