Fix BcMath\Number unary plus/minus/bitwise-not#4980
Conversation
|
I'm not sure it's the right way to do it see Given the fact we have a So maybe the best way to do it the same way is to
But I'd like the confirmation from someone else |
|
I did not verify it, but I think we have support for GMP which also supports working with objects on operators. please see whether this can be used as inspiration how BcMath\Number could/should work |
|
see e.g. phpstan-src/src/Type/OperatorTypeSpecifyingExtension.php Lines 6 to 10 in e696ed0 |
|
You should be able to rework your PR with UnaryOperatorTypeSpecifyingExtension #5284 |
Fixes phpstan/phpstan#13965
Returning
ObjectType('BcMath\Number')fromtoNumber()fixed+$xand-$xbut caused other tests to fail in these operations (https://github.com/phpstan/phpstan-src/blob/2.1.x/tests/PHPStan/Analyser/nsrt/bcmath-number.php)$a & $b$a | $b$a ^ $b$a << $b$a >> $bThis is fixed by checking for
BcMath\Numberearly and returningErrorTypebefore callingtoNumber()when handling those bitwise operations (getBitwiseAndTypeFromTypes()etc.)I'm not sure if the
*ERROR*->*NEVER*changes in tests fix something or break something?