User:Legoktm/0

https://github.com/php/php-src/blob/e1baef1835ba50e9183c603324c371acd01ec669/Zend/zend_operators.c#L629

Goal: submit an RFC asking for removal of this special case. '0' instead is truthy, while empty string is still falsey.

Tim says it should be fine to add a deprecation warning there.

Are there any other languages where '0' is falsey?


 * Perl also treats the string "0" as false. The exact string "0 but true" is used as an alternative by some builtin functions for returning true-valued numeric zeros, and is special-cased to not generate runtime warnings about non-numeric strings undergoing numeric conversions.
 * Tcl, as a stringly typed language, also treats the string "0" as false.

Would you want this feature in PHP today (without thinking about backwards-compatibility)?

Why did PHP introduce this behavior in the first place?

Can static linters stop this? E.g. phan, psalm? Why is that insufficient?

Examples of gotchas by experienced PHP programmers:


 * MediaWiki
 * https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Thanks/+/740363
 * https://gerrit.wikimedia.org/r/c/mediawiki/core/+/740362
 * https://gerrit.wikimedia.org/r/c/mediawiki/core/+/740292
 * https://phabricator.wikimedia.org/T296642
 * https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DisplayTitle/+/731129
 * PHP TOML implementation doesn't allow 0 keys?