-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Description
Description
The following code:
<?php
class MyString {
function __toString() {
return "2";
}
}
$a = new BCMath\Number("1");
$b = new MyString();
var_dump($a + $b, $b);Resulted in this output:
object(BcMath\Number)#2 (2) {
["value"]=>
string(1) "3"
["scale"]=>
int(0)
}
string(1) "2"
But I expected this output instead:
object(BcMath\Number)#2 (2) {
["value"]=>
string(1) "3"
["scale"]=>
int(0)
}
object(MyString)#2 (0) {
}
Note that this even happens in strict typing mode, where it may not even be expected that the addition succeeds.
Anyhow, the problem is that zend_parse_arg_str_or_long_slow() converts the passed arg.
Also note that GMP also uses ZPP functionality, but catches any such type conversion, even in coercive typing mode.
PHP Version
PHP 8.4
Operating System
any
iluuu1994