private static function add(BigNumber $a, BigNumber $b) : BigNumber
    {
        if ($a instanceof BigRational) {
            return $a->plus($b);
        }

        if ($b instanceof BigRational) {
            return $b->plus($a);
        }

        if ($a instanceof BigDecimal) {
            return $a->plus($b);
        }

        if ($b instanceof BigDecimal) {
            return $b->plus($a);
        }

        /** @var BigInteger $a */

        return $a->plus($b);
    }
private static function add(BigNumber $a, BigNumber $b) : BigNumber
    {
        if ($a instanceof BigRational) {
            return $a->plus($b);
        }

        if ($b instanceof BigRational) {
            return $b->plus($a);
        }

        if ($a instanceof BigDecimal) {
            return $a->plus($b);
        }

        if ($b instanceof BigDecimal) {
            return $b->plus($a);
        }

        /** @var BigInteger $a */

        return $a->plus($b);
    }
private static function add ( BigNumber $ a , BigNumber $ b ) : BigNumber { if ( $ a instanceof BigRational ) { return $ a -> plus ( $ b ) ; } if ( $ b instanceof BigRational ) { return $ b -> plus ( $ a ) ; } if ( $ a instanceof BigDecimal ) { return $ a -> plus ( $ b ) ; } if ( $ b instanceof BigDecimal ) { return $ b -> plus ( $ a ) ; } /** @var BigInteger $a */ return $ a -> plus ( $ b ) ; }
Adds two BigNumber instances in the correct order to avoid a RoundingNecessaryException.

@todo This could be better resolved by creating an abstract protected method in BigNumber, and leaving to
concrete classes the responsibility to perform the addition themselves or delegate it to the given number,
depending on their ability to perform the operation. This will also require a version bump because we're
potentially breaking custom BigNumber implementations (if any...)

@param BigNumber $a
@param BigNumber $b

@return BigNumber
Adds two BigNumber instances in the correct order to avoid a RoundingNecessaryException .