Skip to content

Commit

Permalink
feat: Support brick/math v0.12 (#526)
Browse files Browse the repository at this point in the history
Signed-off-by: Natsuki Ikeguchi <[email protected]>
  • Loading branch information
siketyan authored Apr 27, 2024
1 parent 3baa7ce commit 3caf795
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
include:
# Keep the locked version by default
- dependency-versions: "locked"
# For PHP 8.0, installing with --prefer-highest to use brick/math v0.11
- php-version: "8.0"
dependency-versions: "highest"

steps:
- name: "Checkout repository"
Expand All @@ -99,6 +105,8 @@ jobs:

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

- name: "Run PHPBench"
run: "composer phpbench -- --ansi"
Expand Down Expand Up @@ -151,6 +159,12 @@ jobs:
operating-system:
- "ubuntu-latest"
- "windows-latest"
include:
# Keep the locked version by default
- dependency-versions: "locked"
# For PHP 8.0, installing with --prefer-highest to use brick/math v0.11
- php-version: "8.0"
dependency-versions: "highest"

steps:
- name: "Configure Git (for Windows)"
Expand Down Expand Up @@ -179,7 +193,7 @@ jobs:
- name: "Install dependencies (Composer)"
uses: "ramsey/composer-install@v3"
with:
composer-options: "${{ matrix.composer-options }}"
dependency-versions: "${{ matrix.dependency-versions }}"

- name: "Run unit tests (PHPUnit)"
run: "./vendor/bin/phpunit --verbose --colors=always --no-coverage"
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"require": {
"php": "^8.0",
"ext-json": "*",
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11",
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12",
"ramsey/collection": "^1.2 || ^2.0"
},
"require-dev": {
Expand Down
29 changes: 17 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorLevel="1"
cacheDirectory="./build/cache/psalm"
errorBaseline="psalm-baseline.xml">
errorBaseline="psalm-baseline.xml"
phpVersion="8.1">

<projectFiles>
<directory name="./src" />
Expand Down
6 changes: 4 additions & 2 deletions src/Math/BrickMathCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ public function toInteger(Hexadecimal $value): IntegerObject

/**
* Maps ramsey/uuid rounding modes to those used by brick/math
*
* @return BrickMathRounding::*
*/
private function getBrickRoundingMode(int $roundingMode): int
private function getBrickRoundingMode(int $roundingMode)
{
return self::ROUNDING_MODE_MAP[$roundingMode] ?? 0;
return self::ROUNDING_MODE_MAP[$roundingMode] ?? BrickMathRounding::UNNECESSARY;
}
}

0 comments on commit 3caf795

Please sign in to comment.