Path: csiph.com!aioe.org!6ZhA1oKqywAd2aTF9ZWs7A.user.46.165.242.91.POSTED!not-for-mail From: Meredith Montgomery Newsgroups: comp.lang.php Subject: Re: php 7.4: null["key"] Date: Sun, 29 May 2022 23:13:42 -0300 Organization: Aioe.org NNTP Server Message-ID: <86ilpnepih.fsf@levado.to> References: <86mtfcq6yj.fsf@levado.to> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: gioia.aioe.org; logging-data="51232"; posting-host="6ZhA1oKqywAd2aTF9ZWs7A.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; X-Notice: Filtered by postfilter v. 0.9.2 Cancel-Lock: sha1:yYRdSbyaa81lbNt413xYn8PpAnI= Xref: csiph.com comp.lang.php:18960 Meredith Montgomery writes: > I'm upgrading code to PHP 7.4, which will now blow a notice for things > such as > > null["key"] > (1.2)["key"] > (123)["key"] > > All of these seem to reduce to null. (The footnote explains why I think > so.) > > I have a lot of code which could be depending on such things. I'd like > to rewrite such code, but I have no idea how to find such code. I > suppose a loop such as > > while ($a["key"]) { ... } > > could be depending on $a sometimes being null or even being undefined > (because ``$a === null'' when $a is undefined). (These are very weird > things about PHP to my way of looking at things.) > > How would you search for something like that? I just have no idea. My > best idea is to just watch a log of errors and notices and try to spot > the code that way. I guess nobody had much to say here. I'm tackling easier problems at first, but I will eventually have to come back to this and make some decision. I suppose upgrading to PHP 7.4 and watching the a noisy log with error_reporting = E_ALL (say) might give me more information. But, of course, I have no way of running every line of code, so there is really no obvious strategy for something like that.