Bug #73108 [Ver->Csd]: Internal class cast handler uses integer instead of float
Edit report at https://bugs.php.net/bug.php?id=73108&edit=1
ID: 73108
Updated by: nikic@php.net
Reported by: hartenfels at uni-koblenz dot de
Summary: Internal class cast handler uses integer instead of
float
-Status: Verified
+Status: Closed
Type: Bug
Package: Class/Object related
Operating System: Linux
PHP Version: 7.0.11
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Fixed by https://github.com/php/php-src/commit/b2b2b437af5495dcb2016be6e45567ed826cb87e
in master.
Previous Comments:
------------------------------------------------------------------------
[2016-09-22 00:47:49] hartenfels at uni-koblenz dot de
How would any extension ever rely on this behavior? If you specify both an integer and a float cast
handler, I don't think you would ever expect the former to take precedence. And in fact,
there's other extensions that break due to this bug, such as SimpleXML, which is probably a
much more common use case.
But even if you really want to keep this behavior, if your object only has a float cast handler, you
get an error about a missing integer cast handler. What should happen instead is that the float
handler is used.
------------------------------------------------------------------------
[2016-09-22 00:33:08] ajf@php.net
As I see it, the root of the problem is we have no way to cast an object to whatever number type is
best, we have to request an integer or a float specifically. That means we end up picking one, and I
guess we chose integers.
We could choose floats, but floats don't work in every situation. What if you need to represent
a >54-bit number?
I'm not sure how this could be fixed without breaking existing extensions, though.
------------------------------------------------------------------------
[2016-09-19 13:30:42] cmb@php.net
Of course, I meant that this issue is related to bug #54973.
------------------------------------------------------------------------
[2016-09-19 13:29:51] cmb@php.net
Indeed, this is related to bug #73108 (might be even seen as
duplicate).
Note that it's possible to work around that issue by employing an
do_operation handler[1] which is available as of PHP 5.6.
[1] <https://github.com/php/php-src/blob/PHP-5.6.26/Zend/zend_object_handlers.h#L148>
------------------------------------------------------------------------
[2016-09-19 13:29:51] cmb@php.net
Related To: Bug #73108
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=73108
--
Edit this bug report at https://bugs.php.net/bug.php?id=73108&edit=1
Thread (6 messages)