From 3caf795655203d9fd9bf99040c01f9b65935e172 Mon Sep 17 00:00:00 2001 From: Natsuki Ikeguchi Date: Sun, 28 Apr 2024 06:17:30 +0900 Subject: [PATCH] feat: Support brick/math v0.12 (#526) Signed-off-by: Natsuki Ikeguchi --- .github/workflows/continuous-integration.yml | 16 ++++++++++- composer.json | 2 +- composer.lock | 29 ++++++++++++-------- psalm.xml | 3 +- src/Math/BrickMathCalculator.php | 6 ++-- 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 781831fb..f5cd741a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -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" @@ -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" @@ -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)" @@ -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" diff --git a/composer.json b/composer.json index 9ea4e06b..8139b54e 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/composer.lock b/composer.lock index d23eb53b..a1b85fd5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,29 +4,29 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1a0cfb78275fbdcb1744fc79f1d5fb66", + "content-hash": "d096188f435f9df9336415308e9e4938", "packages": [ { "name": "brick/math", - "version": "0.11.0", + "version": "0.12.1", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" + "reference": "f510c0a40911935b77b86859eb5223d58d660df1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", - "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", + "url": "https://api.github.com/repos/brick/math/zipball/f510c0a40911935b77b86859eb5223d58d660df1", + "reference": "f510c0a40911935b77b86859eb5223d58d660df1", "shasum": "" }, "require": { - "php": "^8.0" + "php": "^8.1" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^9.0", - "vimeo/psalm": "5.0.0" + "phpunit/phpunit": "^10.1", + "vimeo/psalm": "5.16.0" }, "type": "library", "autoload": { @@ -46,12 +46,17 @@ "arithmetic", "bigdecimal", "bignum", + "bignumber", "brick", - "math" + "decimal", + "integer", + "math", + "mathematics", + "rational" ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.11.0" + "source": "https://github.com/brick/math/tree/0.12.1" }, "funding": [ { @@ -59,7 +64,7 @@ "type": "github" } ], - "time": "2023-01-15T23:15:59+00:00" + "time": "2023-11-29T23:19:16+00:00" }, { "name": "ramsey/collection", @@ -7363,5 +7368,5 @@ "ext-json": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/psalm.xml b/psalm.xml index 0489226e..04cb32c7 100644 --- a/psalm.xml +++ b/psalm.xml @@ -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"> diff --git a/src/Math/BrickMathCalculator.php b/src/Math/BrickMathCalculator.php index f2d86788..f065acd4 100644 --- a/src/Math/BrickMathCalculator.php +++ b/src/Math/BrickMathCalculator.php @@ -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; } }