On 29/11/2026 14:33, Theodore Brown wrote:
Hello Internals,
I've been planning this RFC for quite some time, and during the Thanksgiving
break I finally had time to finish it:
https://wiki.php.net/rfc/deprecate-lossy-bool-conversions
Hi Theodore,
Thanks for a very well-written RFC; I particularly appreciate the survey
of previous proposals and discussion of how this proposal differs.
I think I am broadly in favour, but have two comments:
Firstly, I am not a fan of open-ended deprecations, and read most of the
RFC thinking this was one. There is only one mention of "... and promote
to a TypeError in the next major release (PHP 9.0)".
I think I agree with that timeline, but it should probably be mentioned
elsewhere as well - e.g. in the Proposal section, and in the Voting
description - so that people are clear that they are voting for the
future removal, not just the initial deprecation.
Secondly, I'm not totally sold on the choice of accepted strings. In the
FAQ you say this:
"Are the 0/1 and "0"/"1" values arbitrary?"
No. They are the canonical encoding of booleans used by database
columns, query strings, and many APIs.
This claim feels a bit strong to me. PostgreSQL canonically encodes
booleans as 'f' and 't'; a lot of other databases (e.g. MySQL, SQLite,
SQL Server, Oracle) don't have true booleans, and use integer 0 and 1 by
convention. HTML defaults the value of a selected checkbox to 'on' and
an unselected one is left undefined.
Perhaps more importantly, PHP itself produces '' not '0' when casting or
coercing a boolean false to string. Under the proposal, this code would
be rejected rather than printing bool(false):
function wants_bool(bool $val) {
var_dump($val);
}
function wants_string(string $val) {
wants_bool($val);
}
wants_string(false);
I think accepting the "round-trippable" values should be the minimum, so
0 and '' for false, and 1 and '1' for true. I'd be happy accepting '0'
as well, because it is already special-cased to false rather than
falling into the catch-all "non-empty string" case.
Thanks again for your work on the RFC.
--
Rowan Tommins
[IMSoP]