Re: [RFC] [VOTE] Saner numeric strings
| From: | Christian Schneider | Date: | Wed, 22 Jul 2020 13:20:38 +0000 |
| Subject: | Re: [RFC] [VOTE] Saner numeric strings | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111114@lists.php.net to get a copy of this message | ||
Am 16.07.2020 um 16:18 schrieb G. P. B. <george.banyard@gmail.com>:
> I've opened voting for the Saner Numeric strings RFC:
> https://wiki.php.net/rfc/saner-numeric-strings
Looking at the BC section I stumbled across
> Code relying on the fact that '' (an empty string) evaluates to 0 for
> arithmetic/bitwise operations.
which is elaborated further down as
> The third reason already emitted an E_WARNING. We considered special-casing this to evaluate to
> 0, but this would be inconsistent with how type declarations deal with an empty string, namely
> throwing a TypeError. Therefore a TypeError will also be emitted in this case. The error can be
> avoided by explicitly checking for an empty string and changing it to 0.
but now I'm a bit confused what is meant by "arithmetic/bitwise operations".
I assume this applies only to things like substr("foo", "") but not to
arithmetic *operators* like 42 + "" because that doesn't currently trigger E_WARNING
AFAIK.
Maybe this should be clarified?
Regards,
- Chris