All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
3.0.0 - 2026-02-08
- BREAKING:
Mathis now immutable by default — every operation returns a new instance, leaving the original unchanged MathImmutablereplaced byMathMutable— mutability is now the explicit opt-in for performance-sensitive hot loops__toString()bypasses redundant regex validation for better performance- PHPStan level 9 compliance for
src/ - GitHub Actions workflows updated to latest action versions
MathMutableCast— Laravel Eloquent cast that returnsMathMutableinstances. UseMathMutableCast::class(with optional:nullable) instead ofMathCast::classfor mutable cast attributes. Separate cast classes enable proper static type resolution. Upgrading from v2: sinceMathis now immutable, existing Laravel models that rely on in-place mutation of cast attributes should switch fromMathCast::classtoMathMutableCast::classto restore the previous behavior.MathMutable— mutable variant ofMathwhere operations modify the instance in place. ExtendsMathand is accepted anywhereMathis type-hinted.negate()— flip sign, zero stays zeroclamp($min, $max)— clip value between boundsquotientAndRemainder($divisor)— returns[$quotient, $remainder]in one callisZero()— precision-aware zero checkisNegative()— complement toisPositive()isEven()/isOdd()— integer parity checks, returnfalsefor non-integersgetScale()— number of meaningful decimal places (normalized)getIntegralPart()— part before the decimal point (normalized,-0becomes0)getFractionalPart()— part after the decimal point (normalized, trailing zeros stripped)declare(strict_types=1)in all source filesphpstan-tests.neon— dedicated PHPStan configuration for tests at level 5
toBase()/fromBase()now preserve the sign of negative numbers instead of silently stripping it —Math::number('-42')->toBase(16)returns'-2a'andMath::fromBase('-2a', 16)returns'-42'fromBase()now normalizes input case for bases <= 36 —Math::fromBase('FF', 16)works consistently with and without GMPformat()now works correctly with immutable default (capturesabs()return value)bcDec2Base()properly initializes result as'0'
MathImmutable— no longer needed,Mathitself is now immutable
2.0.0 - 2024-04-24
MathCast— Laravel Eloquent cast forMathinstances with nullable support
- Minimum PHP version raised to 8.1
- PHP < 8.1 support
1.0.1 - 2021-06-16
- PHP 8.0 support
1.0.0 - 2019-07-31
Initial release.