From 374b77fb62f2953da1cac105c6f9fd63b21cf89a Mon Sep 17 00:00:00 2001 From: Frederik Bosch Date: Fri, 20 Nov 2026 15:50:16 +0100 Subject: [PATCH 1/7] support php 8.6 --- .github/workflows/ci.yml | 7 +++---- composer.json | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1611a3c..74bf02ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' extensions: bcmath, gmp, intl, dom, mbstring - name: Setup Problem Matchers for PHPUnit @@ -40,7 +40,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.6' + php-version: '8.7' extensions: bcmath, gmp, intl, dom, mbstring - name: Setup Problem Matchers for PHPUnit @@ -66,11 +66,10 @@ jobs: fail-fast: false matrix: php: - - '8.1' - - '8.2' - '8.3' - '8.4' - '8.5' + - '8.6' steps: - name: Set up PHP diff --git a/composer.json b/composer.json index ac4bc744..16a4c166 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ ], "homepage": "http://moneyphp.org", "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0", "ext-bcmath": "*", "ext-filter": "*" }, From 65bf690a2830b75c1c33080d4dad22f0157f7d34 Mon Sep 17 00:00:00 2001 From: Frederik Bosch Date: Fri, 20 Nov 2026 15:52:54 +0100 Subject: [PATCH 2/7] benchmark to php 8.6 --- .github/workflows/bench.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index cd4a33ba..da156121 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -12,10 +12,10 @@ jobs: fail-fast: false matrix: php: - - '8.1' - - '8.2' - '8.3' - '8.4' + - '8.5' + - '8.6' steps: - name: Set up PHP From f3ff67caf16c471e00ceca513ddbe6657ed61c52 Mon Sep 17 00:00:00 2001 From: Frederik Bosch Date: Fri, 20 Nov 2026 15:53:13 +0100 Subject: [PATCH 3/7] phpstan on php 8.5 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74bf02ca..42fced4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' extensions: bcmath, gmp, intl, dom, mbstring - uses: "ramsey/composer-install@v3" From eb83470b4e28272bcc5cfd586bf8c261ec542822 Mon Sep 17 00:00:00 2001 From: Frederik Bosch Date: Fri, 20 Nov 2026 15:53:34 +0100 Subject: [PATCH 4/7] phpcs on php 8.5 --- .github/workflows/static.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 55ede354..61712a38 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -16,7 +16,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.3' + php-version: '8.5' extensions: bcmath, gmp, intl, dom, mbstring - name: Download dependencies From 560dc6fb01c880cc2dffecb3907c5cf496f672c1 Mon Sep 17 00:00:00 2001 From: Frederik Bosch Date: Fri, 20 Nov 2026 16:00:05 +0100 Subject: [PATCH 5/7] fix phpstan --- src/Calculator/GmpCalculator.php | 1 - src/Parser/IntlMoneyParser.php | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Calculator/GmpCalculator.php b/src/Calculator/GmpCalculator.php index eb750f58..7e30c6e0 100644 --- a/src/Calculator/GmpCalculator.php +++ b/src/Calculator/GmpCalculator.php @@ -108,7 +108,6 @@ public static function multiply(string $amount, string $multiplier): string $finalResult = substr($resultBase, 0, $decimalPlaces * -1) . '.' . $result; if ($negativeZero) { - // @phpstan-ignore possiblyImpure.functionCall (see https://github.com/phpstan/phpstan/issues/11884) $finalResult = str_replace('-.', '-0.', $finalResult); } diff --git a/src/Parser/IntlMoneyParser.php b/src/Parser/IntlMoneyParser.php index 5c07ee52..1478fcd1 100644 --- a/src/Parser/IntlMoneyParser.php +++ b/src/Parser/IntlMoneyParser.php @@ -33,10 +33,9 @@ public function parse(string $money, Currency|null $fallbackCurrency = null): Mo { $currency = ''; // phpcs:ignore - /** @var string|float|bool|null $decimal */ $decimal = $this->formatter->parseCurrency($money, $currency); - if ($decimal === false || $decimal === null) { + if ($decimal === false) { throw new ParserException('Cannot parse ' . $money . ' to Money. ' . $this->formatter->getErrorMessage()); } From b6c5e79bd17fa4877bedeff573c5a18d5f0bc7c5 Mon Sep 17 00:00:00 2001 From: Frederik Bosch Date: Fri, 20 Nov 2026 16:10:37 +0100 Subject: [PATCH 6/7] upgrade doctrine coding standards --- composer.json | 20 ++++++++++---------- src/Calculator/BcMathCalculator.php | 2 +- src/Calculator/GmpCalculator.php | 2 +- src/Currencies/BitcoinCurrencies.php | 4 ++-- src/Money.php | 16 ++++++++-------- src/Number.php | 2 +- src/Parser/DecimalMoneyParser.php | 2 +- src/Parser/IntlMoneyParser.php | 3 +-- tests/Currencies/CurrencyListTest.php | 2 +- tests/MoneyTest.php | 8 ++++---- 10 files changed, 30 insertions(+), 31 deletions(-) diff --git a/composer.json b/composer.json index 16a4c166..a170a02e 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ ], "homepage": "http://moneyphp.org", "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0", + "php": "~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0", "ext-bcmath": "*", "ext-filter": "*" }, @@ -32,7 +32,7 @@ "ext-gmp": "*", "ext-intl": "*", "cache/taggable-cache": "^1.1.0", - "doctrine/coding-standard": "^12.0", + "doctrine/coding-standard": "^14.0", "doctrine/instantiator": "^1.5.0 || ^2.0", "florianv/exchanger": "^2.8.1", "florianv/swap": "^4.3.0", @@ -86,23 +86,23 @@ }, "scripts": { "benchmark": [ - "vendor/bin/phpbench run --retry-threshold=3 --iterations=15 --revs=1000 --warmup=2" + "@php vendor/bin/phpbench run --retry-threshold=3 --iterations=15 --revs=1000 --warmup=2" ], "clean": "rm -rf build/ vendor/", "test": [ - "vendor/bin/phpbench run", - "vendor/bin/phpunit", - "vendor/bin/phpstan", - "vendor/bin/phpcs" + "@php vendor/bin/phpbench run", + "@php vendor/bin/phpunit", + "@php vendor/bin/phpstan", + "@php vendor/bin/phpcs" ], "test-coverage": [ - "vendor/bin/phpunit --coverage-text --coverage-clover=build/unit_coverage.xml" + "@php vendor/bin/phpunit --coverage-text --coverage-clover=build/unit_coverage.xml" ], "update-currencies": [ "cp vendor/moneyphp/iso-currencies/resources/current.php resources/currency.php", "cp vendor/moneyphp/crypto-currencies/resources/binance.php resources/binance.php", - "php resources/generate-money-factory.php", - "php resources/generate-teller-factory.php" + "@php resources/generate-money-factory.php", + "@php resources/generate-teller-factory.php" ] } } diff --git a/src/Calculator/BcMathCalculator.php b/src/Calculator/BcMathCalculator.php index 5465e14b..8daeab2e 100644 --- a/src/Calculator/BcMathCalculator.php +++ b/src/Calculator/BcMathCalculator.php @@ -21,7 +21,7 @@ final class BcMathCalculator implements Calculator { - private const SCALE = 14; + private const int SCALE = 14; /** @phpstan-pure */ public static function compare(string $a, string $b): int diff --git a/src/Calculator/GmpCalculator.php b/src/Calculator/GmpCalculator.php index 7e30c6e0..2fb71e30 100644 --- a/src/Calculator/GmpCalculator.php +++ b/src/Calculator/GmpCalculator.php @@ -38,7 +38,7 @@ */ final class GmpCalculator implements Calculator { - private const SCALE = 14; + private const int SCALE = 14; /** @phpstan-pure */ public static function compare(string $a, string $b): int diff --git a/src/Currencies/BitcoinCurrencies.php b/src/Currencies/BitcoinCurrencies.php index 87d73f94..0a91739e 100644 --- a/src/Currencies/BitcoinCurrencies.php +++ b/src/Currencies/BitcoinCurrencies.php @@ -12,9 +12,9 @@ final class BitcoinCurrencies implements Currencies { - public const CODE = 'XBT'; + public const string CODE = 'XBT'; - public const SYMBOL = "\xC9\x83"; + public const string SYMBOL = "\xC9\x83"; public function contains(Currency $currency): bool { diff --git a/src/Money.php b/src/Money.php index a9b0defd..b1ef2996 100644 --- a/src/Money.php +++ b/src/Money.php @@ -34,21 +34,21 @@ final class Money implements JsonSerializable { use MoneyFactory; - public const ROUND_HALF_UP = PHP_ROUND_HALF_UP; + public const int ROUND_HALF_UP = PHP_ROUND_HALF_UP; - public const ROUND_HALF_DOWN = PHP_ROUND_HALF_DOWN; + public const int ROUND_HALF_DOWN = PHP_ROUND_HALF_DOWN; - public const ROUND_HALF_EVEN = PHP_ROUND_HALF_EVEN; + public const int ROUND_HALF_EVEN = PHP_ROUND_HALF_EVEN; - public const ROUND_HALF_ODD = PHP_ROUND_HALF_ODD; + public const int ROUND_HALF_ODD = PHP_ROUND_HALF_ODD; - public const ROUND_UP = 5; + public const int ROUND_UP = 5; - public const ROUND_DOWN = 6; + public const int ROUND_DOWN = 6; - public const ROUND_HALF_POSITIVE_INFINITY = 7; + public const int ROUND_HALF_POSITIVE_INFINITY = 7; - public const ROUND_HALF_NEGATIVE_INFINITY = 8; + public const int ROUND_HALF_NEGATIVE_INFINITY = 8; /** * Internal value. diff --git a/src/Number.php b/src/Number.php index 0034335e..cdde4245 100644 --- a/src/Number.php +++ b/src/Number.php @@ -33,7 +33,7 @@ final class Number /** @phpstan-var numeric-string|'' */ private string $fractionalPart; - private const NUMBERS = [0 => 1, 1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1, 7 => 1, 8 => 1, 9 => 1]; + private const array NUMBERS = [0 => 1, 1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1, 7 => 1, 8 => 1, 9 => 1]; /** * @phpstan-pure diff --git a/src/Parser/DecimalMoneyParser.php b/src/Parser/DecimalMoneyParser.php index 6e5b63aa..a204a8b1 100644 --- a/src/Parser/DecimalMoneyParser.php +++ b/src/Parser/DecimalMoneyParser.php @@ -24,7 +24,7 @@ */ final class DecimalMoneyParser implements MoneyParser { - public const DECIMAL_PATTERN = '/^(?P-)?(?P\d+)?\.?(?P\d+)?$/'; + public const string DECIMAL_PATTERN = '/^(?P-)?(?P\d+)?\.?(?P\d+)?$/'; public function __construct(private readonly Currencies $currencies) { diff --git a/src/Parser/IntlMoneyParser.php b/src/Parser/IntlMoneyParser.php index 1478fcd1..bb8d88f8 100644 --- a/src/Parser/IntlMoneyParser.php +++ b/src/Parser/IntlMoneyParser.php @@ -32,8 +32,7 @@ public function __construct(private readonly NumberFormatter $formatter, private public function parse(string $money, Currency|null $fallbackCurrency = null): Money { $currency = ''; - // phpcs:ignore - $decimal = $this->formatter->parseCurrency($money, $currency); + $decimal = $this->formatter->parseCurrency($money, $currency); if ($decimal === false) { throw new ParserException('Cannot parse ' . $money . ' to Money. ' . $this->formatter->getErrorMessage()); diff --git a/tests/Currencies/CurrencyListTest.php b/tests/Currencies/CurrencyListTest.php index bab37690..b23507b5 100644 --- a/tests/Currencies/CurrencyListTest.php +++ b/tests/Currencies/CurrencyListTest.php @@ -15,7 +15,7 @@ /** @covers \Money\Currencies\CurrencyList */ final class CurrencyListTest extends TestCase { - private const CORRECT_CURRENCIES = [ + private const array CORRECT_CURRENCIES = [ 'MY1' => 2, 'MY2' => 0, 'MY3' => 1, diff --git a/tests/MoneyTest.php b/tests/MoneyTest.php index 0f0fb2de..3201ab96 100644 --- a/tests/MoneyTest.php +++ b/tests/MoneyTest.php @@ -22,13 +22,13 @@ final class MoneyTest extends TestCase use RoundExamples; use Locale; - public const AMOUNT = 10; + public const int AMOUNT = 10; - public const OTHER_AMOUNT = 5; + public const int OTHER_AMOUNT = 5; - public const CURRENCY = 'EUR'; + public const string CURRENCY = 'EUR'; - public const OTHER_CURRENCY = 'USD'; + public const string OTHER_CURRENCY = 'USD'; /** * @phpstan-param int|numeric-string $amount From 0375f125f576c6ddf85d0f615e739fe4422a804f Mon Sep 17 00:00:00 2001 From: Frederik Bosch Date: Fri, 20 Nov 2026 16:14:28 +0100 Subject: [PATCH 7/7] lowest should also use latest phpstan --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a170a02e..1d826600 100644 --- a/composer.json +++ b/composer.json @@ -41,9 +41,9 @@ "php-http/message": "^1.16.0", "php-http/mock-client": "^1.6.0", "phpbench/phpbench": "^1.2.5", - "phpstan/extension-installer": "^1.4", - "phpstan/phpstan": "^2.2.5", - "phpstan/phpstan-phpunit": "^2.0", + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^2.3.7", + "phpstan/phpstan-phpunit": "^2.1.2", "phpunit/phpunit": "^10.5.9", "psr/cache": "^1.0.1 || ^2.0 || ^3.0", "ticketswap/phpstan-error-formatter": "^1.1"