You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When doing $obj + 123, $obj shouldn't be treated by PHP as a string when $obj is a numeric representation.
Adding the magic casting method __toscalar is handy for solving this.
Surely what you want here is operator overloading rather than a __toScalar magic method?
__toscalar would be prefered to also support the round($obj) + 1 use case.
I don't mind if the magic casting method is either called __toNumber or __toNumeric.
Description
When doing
$obj + 123
,$obj
shouldn't be treated by PHP as a string when$obj
is a numeric representation.Adding the magic casting method
__toscalar
is handy for solving this.Please release this patch.
See: https://wiki.php.net/rfc/object_cast_to_types
The text was updated successfully, but these errors were encountered: