Hello Internals, I opened the vote about Stricter implicit boolean coercions as announced. The vote will run until 2022-06-20. Discussion: https://externals.io/message/117732 RFC: https://wiki.php.net/rfc/stricter_implicit_boolean_coercions Best regards, Andreas Leathley
The vote has been closed, the RFC has been declined with 14 to 3 votes. It would have been interesting to get some more feedback on why people voted No - some took part in the discussion, but most didn't. My assumption is that most didn't find this important enough, especially if strict types is not affected. While I think the RFC would have helped identify obvious bugs (and I find the current behavior of PHP with boolean coercions less than ideal), I can see an argument for voters to not see it as something important enough to change the language, as the problems this RFC would have highlighted can be avoided altogether. If anybody still wants to give some insight on these reasons or a way to improve boolean coercions in another way, I would be happy to hear it. Otherwise thanks to everybody who took part in the discussion, it was an interesting experience.
> It would have been interesting to get some more feedback on why people > voted No - some took part in the discussion, but most didn't.Indeed... Of those who did, I have retained the following arguments (sorry in advance for any omission, approximation or misinterpretation): - no impact analysis (but seems difficult...) - it would increase the discrepancy between e.g. `if ($x)` and `takes_bool($x)` (already existing for non-scalar $x [okay VS TypeError], but now for scalar $x too [okay VS deprecation notice]) - the deprecation should apply to all floats (even 0.0 and 1.0) because floating-point equality is risky - the deprecation should include the string "0" (VS empty "") because it's a recurrent WTF (and maybe even in all implicit boolean evaluations [e.g. `if`, `&&` etc.] too) - we should rather deprecate `takes_bool($string)` and `takes_bool($float)` totally (i.e. all strings and floats), and also `takes_string($bool)` and `takes_float($bool)` (but maybe don't need to change `takes_bool($int)` at all) Note: I think that generally there can be arguments in both ways...> I think the RFC would have helped > identify obvious bugsI agree ;(> thanks to everybody who took part in the discussion, it was an > interesting experience.Thank you ;)> If anybody still wants to give some insight on these reasons or a way to > improve boolean coercions in another way, I would be happy to hear it.Sorry I don't have better ideas... Maybe others will? -- Guilliam Xavier