Upgrading from 2.x

This version removes the mutable class and renames the immutable one.

Summary of changes#

This version is a breaking release. These are the changes that affect your code.

Step by step#

Follow these three steps to move an existing project from 2.x.

1. Update the namespace#

// before
use PHP\Math\BigInteger\ImmutableBigInteger;

// after
use PHPMath\BigInteger\BigInteger;

2. Rename the class#

Replace every ImmutableBigInteger with BigInteger. Type declarations, new calls and instanceof checks all change the same way.

3. Replace mutable code#

Code that used MutableBigInteger relied on methods changing the object in place. Assign the result instead.

// before
$number = new MutableBigInteger('10');
$number->add(new MutableBigInteger('5'));

// after
$number = new BigInteger('10');
$number = $number->add(new BigInteger('5'));