Girgias / php-rfc-bool-string-deprecation

PHP RFC to deprecate boolean to string coercion
1 stars 1 forks source link

Reconsider echo, print and concat/interpolation #5

Open iluuu1994 opened 2 years ago

iluuu1994 commented 2 years ago

In our test suite it seems pretty common to print/concat a falsy value. This makes me think these cases will be very common in userland code too. Doing something like this seems relatively harmless:

$strings = [];
echo reset($strings);

This comes back to the fact that we historically use false as an alternative to null. I think these changes are the worst offenders in the RFC at this point:

I'm pretty sure this would be a major headache for a lot of people. We could theoretically only deprecate implicit coercion of true but that seems inconsistent. TBH my suggestion is inconsistent as well but I don't think going all the way is worth it.

@Girgias WDYT?

Girgias commented 2 years ago

I initially got the idea from https://wiki.php.net/rfc/coercive_sth which only affected scalar type declarations (and it rejects some other situations) but I felt rejecting only for type declarations was a bit weird. But what else other than type declarations would remain if we have an exception for these situations.

It is quite unfortunate that false was use as an alternative to null :-/ but it might indeed be too big of a break. Do you have a ballpark of internal test files affected?