Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #18960

Re: php 7.4: null["key"]

From Meredith Montgomery <mmontgomery@levado.to>
Newsgroups comp.lang.php
Subject Re: php 7.4: null["key"]
Date 2022-05-29 23:13 -0300
Organization Aioe.org NNTP Server
Message-ID <86ilpnepih.fsf@levado.to> (permalink)
References <86mtfcq6yj.fsf@levado.to>

Show all headers | View raw


Meredith Montgomery <mmontgomery@levado.to> 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.

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

php 7.4: null["key"] Meredith Montgomery <mmontgomery@levado.to> - 2022-05-20 17:34 -0300
  Re: php 7.4: null["key"] Meredith Montgomery <mmontgomery@levado.to> - 2022-05-29 23:13 -0300
    Re: php 7.4: null["key"] "J.O. Aho" <user@example.net> - 2022-05-30 08:06 +0200
      Re: php 7.4: null["key"] Meredith Montgomery <mmontgomery@levado.to> - 2022-05-31 19:27 -0300
        Re: php 7.4: null["key"] De ongekruisigde <ongekruisigde@news.eternal-september.org> - 2022-05-31 22:39 +0000
          Re: php 7.4: null["key"] Meredith Montgomery <mmontgomery@levado.to> - 2022-06-02 17:26 -0300
            Re: php 7.4: null["key"] Meredith Montgomery <mmontgomery@levado.to> - 2022-06-03 17:09 -0300
              Re: php 7.4: null["key"] De ongekruisigde <ongekruisigde@news.eternal-september.org> - 2022-06-04 14:35 +0000

csiph-web