A blog on PHP, JavaScript and more Amit Merchant · June 1, 2020 · ⋆ PHP If the given value is of the incorrect type, then an error is generated: in PHP 5, this will be a recoverable fatal error, while PHP 7 will throw a TypeError exception.
So, now, whenever the method sum is called, PHP would expect to get the respective parameters of specified types.
In other words, PHP will try to “fallback” to the supplied type to the target type whenever it can.
PHP will try to coerce “3.5” to its integer value which is happen to be 3 in this case and process it further accordingly.