Re: [RFC] Deprecate boolean to string coercion
| From: | Kamil Tekiela | Date: | Sat, 26 Jun 2021 17:48:20 +0000 |
| Subject: | Re: [RFC] Deprecate boolean to string coercion | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-115162@lists.php.net to get a copy of this message | ||
Hi George,
As someone who has fallen victim to this silent bug in the past, I think I
would be on board with this change.
Why only implicit casting? If we compare this to the array-to-string
casting then the warning happens for both. It would be more consistent to
deprecate both implicit and explicit. I'd imagine it would also be easier
to implement. I'd say that printf() family of functions should also throw
the deprecation notice, even if we only deprecate implicit conversion.
I am under impression that most of the time when this kind of conversion
happens the expected outcome is either 0 or 1. For example, when storing a
boolean flag to sqlite database. Could we not change the false value to 0
instead of deprecating?
Regards,
Kamil