On 4.6.2025 18:46:58, Larry Garfield wrote:
On Wed, Jun 4, 2025, at 11:16 AM, Theodore Brown wrote:
On Wed, June 4, 2025 at 09:37 Aleksander Machniak wrote:

On 4.06.2025 16:03, G. P. Banyard wrote:
I don't understand what you mean.
The purpose is to deprecate the behaviour in 8.5 so that it can be removed in 
PHP 9.
We try to not break behaviour with no prior warning.
Could you clarify what you mean?
I meant to move the deprecation to PHP 9.0. I feel the impact of
deprecation itself in this case might be significant.
You feel there might be a lot of code passing floats, ints, or strings to
`bool` parameters? I'm doubtful this is the case, since static analysis tools
and IDEs are in much more widespread use nowadays.

In my experience passing non-boolean values to a `bool` parameter almost always
indicates a bug, and it would be valuable to get a deprecation notice sooner
rather than later so these mistakes can be fixed.

Regards,
Theodore
The one place I can see it being used now legitimately is MySQL's TINYINT 
pseudo-bool columns.  If you're mapping your query results into an object 
(please always do this), then you probably want to cast that into to a bool, 
and currently weak mode would let you do that implicitly.

I can't think of a case where a string or float magically casting to a bool is 
reasonable.

--Larry Garfield

Basically every time you use external inputs. Maybe it's a $_GET parameter? I mean, I absolutely do not care whether $_GET["showcomments"] is actually 0, foo or 1.23. My code will only assign showcomments=0 or showcomments=1. But all I want is a bool. I absolutely do not care about the actual contents. If the language warns me about that it's likely that I will just be annoyed when it happens occasionally in production when some user tries to play around with the parameter values. And then I'll explicitly add the cast. But for all purposes, it's a plain annoyance.

If you desire to be annoyed, be my guest and use strict types.

For me the whole point of weak types is so that I can easily and comfortably work with arbitrary inputs. So this RFC gets really in my way here and I'm going to vote no on this.

I could get on board with making true|false decay to bool, whenever they appear in an union type. But that's - for me - not related to bool in type juggling.

Bob

Reply via email to