Skip to content

Commit

Permalink
Fix static analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
benr77 committed May 31, 2024
1 parent 328c6c2 commit fb7b3cc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ parameters:
bootstrapFiles:
- vendor/autoload.php

checkGenericClassInNonGenericObjectType: false
ignoreErrors:
-
identifier: missingType.generics
3 changes: 3 additions & 0 deletions src/HeadsnetMoneyBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function build(ContainerBuilder $container): void
$this->addDoctrineMapping($container);
}

/**
* @throws Exception
*/
public function boot(): void
{
$this->addCurrencyColumnType();
Expand Down
5 changes: 4 additions & 1 deletion src/Serializer/Normalizer/MoneyAsDecimalNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ public function __construct()

/**
* @param Money $object
* @param string[] $context
* @param array<string, string> $context
*/
public function normalize($object, string $format = null, array $context = []): string
{
return $this->moneyFormatter->format($object);
}

/**
* @param array<string, string> $context
*/
public function supportsNormalization($data, string $format = null, array $context = []): bool
{
return $data instanceof Money;
Expand Down
10 changes: 8 additions & 2 deletions src/Serializer/Normalizer/MoneyNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MoneyNormalizer implements NormalizerInterface, DenormalizerInterface
{
/**
* @param Money $object
* @param string[] $context
* @param array<string, string> $context
*
* @return array{amount: string, currency: Currency}
*/
Expand All @@ -31,20 +31,26 @@ public function normalize($object, string $format = null, array $context = []):
];
}

/**
* @param array<string, string> $context
*/
public function supportsNormalization($data, string $format = null, array $context = []): bool
{
return $data instanceof Money;
}

/**
* @param array{amount: numeric-string, currency: non-empty-string} $data
* @param string[] $context
* @param array<string, string> $context
*/
public function denormalize($data, string $type, string $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
{
if ($type !== Money::class) {
Expand Down

0 comments on commit fb7b3cc

Please sign in to comment.