Consistent type errors for internal functions and BC breaks
| From: | Christian Schneider | Date: | Sat, 16 Jan 2021 17:07:27 +0000 |
| Subject: | Consistent type errors for internal functions and BC breaks | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-112909@lists.php.net to get a copy of this message | ||
While testing the migration of our site to PHP 8 we noticed the BC break in internal functions like
round() for parameter type errors:
round("foo") used to (silently, without warning) cast to float and return 0 where as now
it throws a TypeError: round():
https://3v4l.org/pU0LD
The RFC at https://wiki.php.net/rfc/consistent_type_errors#backward_incompatible_changes
<https://wiki.php.net/rfc/consistent_type_errors>
states
> Backward Incompatible Changes
>
> A TypeError will be thrown instead of a warning if incorrectly typed parameters are passed to a
> function, which is a backwards incompatible change.
But that is not the whole truth because it suggests that there was a warning in 7.4 which is not the
case for functions like round() and possibly many more.
This makes the BC break much more impactful as there is no easy way to know if old code will
suddenly abort with an exception whereas it used to run without any warning.
Is there any way of knowing what functions are affected by this?
This might be a blocker for people to migrate to PHP 8, should there be a way to have a
warning-instead-of-exception stage added to PHP 8 even though there first versions were already
released to help people migrate?
Or did I miss something?
- Chris