Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -105,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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
],
"homepage": "http://moneyphp.org",
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
"php": "~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0",
"ext-bcmath": "*",
"ext-filter": "*"
},
"require-dev": {
"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",
Expand All @@ -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"
Expand Down Expand Up @@ -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"
]
}
}
2 changes: 1 addition & 1 deletion src/Calculator/BcMathCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Calculator/GmpCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Currencies/BitcoinCurrencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
16 changes: 8 additions & 8 deletions src/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/DecimalMoneyParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
final class DecimalMoneyParser implements MoneyParser
{
public const DECIMAL_PATTERN = '/^(?P<sign>-)?(?P<digits>\d+)?\.?(?P<fraction>\d+)?$/';
public const string DECIMAL_PATTERN = '/^(?P<sign>-)?(?P<digits>\d+)?\.?(?P<fraction>\d+)?$/';

public function __construct(private readonly Currencies $currencies)
{
Expand Down
6 changes: 2 additions & 4 deletions src/Parser/IntlMoneyParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ public function __construct(private readonly NumberFormatter $formatter, private
public function parse(string $money, Currency|null $fallbackCurrency = null): Money
{
$currency = '';
// phpcs:ignore
/** @var string|float|bool|null $decimal */
$decimal = $this->formatter->parseCurrency($money, $currency);
$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());
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Currencies/CurrencyListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions tests/MoneyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading