Skip to content

Commit

Permalink
Fix PHP 8.4 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
benr77 committed Dec 16, 2024
1 parent 97dce45 commit f08f5f3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/Serializer/Normalizer/MoneyAsDecimalNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ public function __construct()
}

/**
* @param Money $object
* @param Money $data
* @param array<string, string> $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<string, string> $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;
}

/**
* @return array<string, bool>
*/
public function getSupportedTypes(?string $format): array
public function getSupportedTypes(string|null $format): array
{
return [
Money::class => true,
Expand Down
16 changes: 8 additions & 8 deletions src/Serializer/Normalizer/MoneyNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
class MoneyNormalizer implements NormalizerInterface, DenormalizerInterface
{
/**
* @param Money $object
* @param Money $data
* @param array<string, string> $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<string, string> $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;
}
Expand All @@ -43,15 +43,15 @@ public function supportsNormalization($data, string $format = null, array $conte
* @param array{amount: numeric-string, currency: non-empty-string} $data
* @param array<string, string> $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']));
}

/**
* @param array<string, string> $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;
Expand All @@ -63,7 +63,7 @@ public function supportsDenormalization($data, string $type, string $format = nu
/**
* @return array<string, bool>
*/
public function getSupportedTypes(?string $format): array
public function getSupportedTypes(string|null $format): array
{
return [
Money::class => true,
Expand Down
2 changes: 1 addition & 1 deletion src/Twig/Extension/FormatMoneyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit f08f5f3

Please sign in to comment.