Skip to content

Commit 3caf795

Browse files
authored
feat: Support brick/math v0.12 (#526)
Signed-off-by: Natsuki Ikeguchi <[email protected]>
1 parent 3baa7ce commit 3caf795

File tree

5 files changed

+39
-17
lines changed

5 files changed

+39
-17
lines changed

.github/workflows/continuous-integration.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ jobs:
7979
- "8.1"
8080
- "8.2"
8181
- "8.3"
82+
include:
83+
# Keep the locked version by default
84+
- dependency-versions: "locked"
85+
# For PHP 8.0, installing with --prefer-highest to use brick/math v0.11
86+
- php-version: "8.0"
87+
dependency-versions: "highest"
8288

8389
steps:
8490
- name: "Checkout repository"
@@ -99,6 +105,8 @@ jobs:
99105

100106
- name: "Install dependencies (Composer)"
101107
uses: "ramsey/composer-install@v3"
108+
with:
109+
dependency-versions: "${{ matrix.dependency-versions }}"
102110

103111
- name: "Run PHPBench"
104112
run: "composer phpbench -- --ansi"
@@ -151,6 +159,12 @@ jobs:
151159
operating-system:
152160
- "ubuntu-latest"
153161
- "windows-latest"
162+
include:
163+
# Keep the locked version by default
164+
- dependency-versions: "locked"
165+
# For PHP 8.0, installing with --prefer-highest to use brick/math v0.11
166+
- php-version: "8.0"
167+
dependency-versions: "highest"
154168

155169
steps:
156170
- name: "Configure Git (for Windows)"
@@ -179,7 +193,7 @@ jobs:
179193
- name: "Install dependencies (Composer)"
180194
uses: "ramsey/composer-install@v3"
181195
with:
182-
composer-options: "${{ matrix.composer-options }}"
196+
dependency-versions: "${{ matrix.dependency-versions }}"
183197

184198
- name: "Run unit tests (PHPUnit)"
185199
run: "./vendor/bin/phpunit --verbose --colors=always --no-coverage"

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"require": {
1212
"php": "^8.0",
1313
"ext-json": "*",
14-
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11",
14+
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12",
1515
"ramsey/collection": "^1.2 || ^2.0"
1616
},
1717
"require-dev": {

composer.lock

+17-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

psalm.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
55
errorLevel="1"
66
cacheDirectory="./build/cache/psalm"
7-
errorBaseline="psalm-baseline.xml">
7+
errorBaseline="psalm-baseline.xml"
8+
phpVersion="8.1">
89

910
<projectFiles>
1011
<directory name="./src" />

src/Math/BrickMathCalculator.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ public function toInteger(Hexadecimal $value): IntegerObject
136136

137137
/**
138138
* Maps ramsey/uuid rounding modes to those used by brick/math
139+
*
140+
* @return BrickMathRounding::*
139141
*/
140-
private function getBrickRoundingMode(int $roundingMode): int
142+
private function getBrickRoundingMode(int $roundingMode)
141143
{
142-
return self::ROUNDING_MODE_MAP[$roundingMode] ?? 0;
144+
return self::ROUNDING_MODE_MAP[$roundingMode] ?? BrickMathRounding::UNNECESSARY;
143145
}
144146
}

0 commit comments

Comments
 (0)