Re: [RFC] Warning for implicit float to int conversions
| From: | Christian Schneider | Date: | Sat, 06 Feb 2021 14:47:37 +0000 |
| Subject: | Re: [RFC] Warning for implicit float to int conversions | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-113101@lists.php.net to get a copy of this message | ||
Am 06.02.2021 um 01:17 schrieb Benjamin Morel <benjamin.morel@gmail.com>:
> Could we at least fix the odd cases where the cast is definitely a failure?
> Like:
>
> (int) 1e60; // 0
> (int) "foo"; // 0
Are you talking about the constant values 1e60 and "foo"? If not then please don't
add a warning (or worse).
I'm sure there is a lot of code which takes user input and uses (int) casts to ensure they are
dealing with integers.
There is also intval() as an alternative but my guess would be that real world code uses 50% (int)
and 50% intval() to do this.
This would be a big BC break IMHO.
- Chris