Path: csiph.com!aioe.org!jX7suk/EoLXVlpi8F2qCUw.user.46.165.242.91.POSTED!not-for-mail From: Meredith Montgomery Newsgroups: comp.lang.php Subject: php 7.4: null["key"] Date: Fri, 20 May 2022 17:34:12 -0300 Organization: Aioe.org NNTP Server Message-ID: <86mtfcq6yj.fsf@levado.to> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: gioia.aioe.org; logging-data="38132"; posting-host="jX7suk/EoLXVlpi8F2qCUw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; Cancel-Lock: sha1:XjgUB55oJSS0vMgz3eglJSTXI2M= X-Notice: Filtered by postfilter v. 0.9.2 Xref: csiph.com comp.lang.php:18942 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. (*) Footnote I say this because of --8<---------------cut here---------------start------------->8--- php > var_dump((123)["key"] === null); PHP Notice: Trying to access array offset on value of type int in php shell code on line 1 Notice: Trying to access array offset on value of type int in php shell code on line 1 bool(true) php > --8<---------------cut here---------------end--------------->8--- (By the way, I don't know why I get two notices.)