[4.x] Upgrade brick/math to support versions ^0.14–^0.17#638
Merged
Conversation
Introduce BrickMathRoundingMode internal class to resolve Brick\Math\RoundingMode constants across versions that use different naming conventions (UPPER_SNAKE_CASE < 0.15, PascalCase >= 0.15). Tighten PHPDoc types on CalculatorInterface to satisfy stricter type annotations in newer brick/math releases. Update test assertions for error messages that changed wording across versions. Widen composer constraint to >=0.8.16 <=0.17.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.x #638 +/- ##
============================================
+ Coverage 95.12% 95.13% +0.01%
- Complexity 575 576 +1
============================================
Files 70 71 +1
Lines 1640 1645 +5
============================================
+ Hits 1560 1565 +5
Misses 80 80
|
ramsey
approved these changes
Apr 27, 2026
This was referenced Apr 29, 2026
|
@ramsey this still needs a new release pushed out before it shows up on Packagist |
|
@ramsey Thanks for merging this PR. Eagerly waiting for a new release :) |
|
@ramsey we are all on the same boat :D Any news for the release? |
|
Just checking in like the rest. Thanks in advance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I noticed there have been a few attempts at adding support for newer brick/math versions, so I wanted to take a stab at it with an approach that keeps full backward compatibility.
The main challenge is that brick/math 0.15 renamed the
RoundingModeconstants fromUPPER_SNAKE_CASEtoPascalCaseand changedMathExceptionfrom a class to an interface. Rather than dropping support for older versions, I introduced a small internalBrickMathRoundingModeclass that resolves the correct constant at runtime usingdefined()with a fallback. It ain't pretty, but it works seamlessly across all versions.I also tightened the PHPDoc types on
CalculatorInterfaceto satisfy the stricter type annotations introduced in newer brick/math releases, and adjusted a couple of test assertions where error message wording changed.The full
composer testsuite (lint, benchmarks, PHPStan, unit tests) passes on both sides of the 0.15 breaking-change boundary, and unit tests pass on every supported version: 0.8.16, 0.9, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, and 0.17.See #636.
Test plan
composer testpasses with brick/math 0.14composer testpasses with brick/math 0.17lockedandhighestdependency strategies