diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6fd545f..e4da880 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,15 +16,10 @@ jobs: fail-fast: false matrix: operating-system: [ ubuntu-latest, windows-latest ] - php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] - symfony: [ '4.4.*', '5.4.*', '6.4.*', '7.1.*' ] + php: [ '8.1', '8.2', '8.3', '8.4' ] + symfony: [ '5.4.*', '6.4.*', '7.2.*' ] exclude: - - { php: '7.4', symfony: '6.4.*' } - - { php: '8.0', symfony: '6.4.*' } - - { php: '7.4', symfony: '7.1.*' } - - { php: '8.0', symfony: '7.1.*' } - - { php: '8.1', symfony: '7.1.*' } - + - { php: '8.1', symfony: '7.2.*' } steps: - name: Checkout uses: actions/checkout@v4 @@ -49,6 +44,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: latest - uses: ramsey/composer-install@v3 - run: vendor/bin/ecs @@ -57,5 +55,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: latest - uses: ramsey/composer-install@v3 - run: vendor/bin/phpstan diff --git a/composer.json b/composer.json index 0329d97..9dfb946 100644 --- a/composer.json +++ b/composer.json @@ -9,18 +9,18 @@ "issues": "https://github.com/headsnet/money-bundle/issues" }, "require": { - "php": ">=7.4", - "moneyphp/money": "^3.3 || ^4.0", - "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0" + "php": ">=8.1", + "moneyphp/money": "^4.6", + "symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0" }, "require-dev": { - "doctrine/doctrine-bundle": "^1.0 || ^2.0", + "doctrine/doctrine-bundle": "^2.7", "phpstan/phpstan": "^1.8", "phpunit/phpunit": "^8.0 || ^9.0", - "symfony/form": "^4.4 || ^5.0 || ^6.0 || ^7.0", - "symfony/serializer": "^4.4 || ^5.0 || ^6.0 || ^7.0", - "symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0", - "symfony/validator": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/form": "^5.4 || ^6.4 || ^7.0", + "symfony/serializer": "^5.4 || ^6.4 || ^7.0", + "symfony/twig-bundle": "^5.4 || ^6.4 || ^7.0", + "symfony/validator": "^5.4 || ^6.4 || ^7.0", "symplify/easy-coding-standard": "^11" }, "suggest": { @@ -41,6 +41,7 @@ }, "scripts": { "cs": "vendor/bin/ecs check --ansi --config=ecs.php", - "cs-fix": "vendor/bin/ecs check --ansi --config=ecs.php --fix" + "cs-fix": "vendor/bin/ecs check --ansi --config=ecs.php --fix", + "static": "vendor/bin/phpstan analyze --ansi" } } diff --git a/src/Serializer/Normalizer/MoneyAsDecimalNormalizer.php b/src/Serializer/Normalizer/MoneyAsDecimalNormalizer.php index 512c239..75ab681 100644 --- a/src/Serializer/Normalizer/MoneyAsDecimalNormalizer.php +++ b/src/Serializer/Normalizer/MoneyAsDecimalNormalizer.php @@ -28,18 +28,18 @@ public function __construct() } /** - * @param Money $object + * @param Money $data * @param array $context */ - public function normalize($object, string $format = null, array $context = []): string + public function normalize($data, string|null $format = null, array $context = []): string { - return $this->moneyFormatter->format($object); + return $this->moneyFormatter->format($data); } /** * @param array $context */ - public function supportsNormalization($data, string $format = null, array $context = []): bool + public function supportsNormalization($data, string|null $format = null, array $context = []): bool { return $data instanceof Money; } @@ -47,7 +47,7 @@ public function supportsNormalization($data, string $format = null, array $conte /** * @return array */ - public function getSupportedTypes(?string $format): array + public function getSupportedTypes(string|null $format): array { return [ Money::class => true, diff --git a/src/Serializer/Normalizer/MoneyNormalizer.php b/src/Serializer/Normalizer/MoneyNormalizer.php index fd79396..b9b1087 100644 --- a/src/Serializer/Normalizer/MoneyNormalizer.php +++ b/src/Serializer/Normalizer/MoneyNormalizer.php @@ -18,23 +18,23 @@ class MoneyNormalizer implements NormalizerInterface, DenormalizerInterface { /** - * @param Money $object + * @param Money $data * @param array $context * * @return array{amount: string, currency: Currency} */ - public function normalize($object, string $format = null, array $context = []): array + public function normalize($data, string|null $format = null, array $context = []): array { return [ - 'amount' => $object->getAmount(), - 'currency' => $object->getCurrency(), + 'amount' => $data->getAmount(), + 'currency' => $data->getCurrency(), ]; } /** * @param array $context */ - public function supportsNormalization($data, string $format = null, array $context = []): bool + public function supportsNormalization($data, string|null $format = null, array $context = []): bool { return $data instanceof Money; } @@ -43,7 +43,7 @@ public function supportsNormalization($data, string $format = null, array $conte * @param array{amount: numeric-string, currency: non-empty-string} $data * @param array $context */ - public function denormalize($data, string $type, string $format = null, array $context = []): Money + public function denormalize($data, string $type, string|null $format = null, array $context = []): Money { return new Money($data['amount'], new Currency($data['currency'])); } @@ -51,7 +51,7 @@ public function denormalize($data, string $type, string $format = null, array $c /** * @param array $context */ - public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool + public function supportsDenormalization($data, string $type, string|null $format = null, array $context = []): bool { if ($type !== Money::class) { return false; @@ -63,7 +63,7 @@ public function supportsDenormalization($data, string $type, string $format = nu /** * @return array */ - public function getSupportedTypes(?string $format): array + public function getSupportedTypes(string|null $format): array { return [ Money::class => true, diff --git a/src/Twig/Extension/FormatMoneyExtension.php b/src/Twig/Extension/FormatMoneyExtension.php index f7b35b9..b70d6ef 100644 --- a/src/Twig/Extension/FormatMoneyExtension.php +++ b/src/Twig/Extension/FormatMoneyExtension.php @@ -34,7 +34,7 @@ public function getFilters(): array return [new TwigFilter('money', [$this, 'moneyFilter'])]; } - public function moneyFilter(Money $money, string $locale = null): string + public function moneyFilter(Money $money, string|null $locale = null): string { $defaultLocale = $this->translator->getLocale();