mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-16 02:47:45 +00:00
Refactor normalizers: update getSupportedTypes to use match, ensure explicit fallback with '*' => false, and improve type handling.
This commit is contained in:
@@ -85,6 +85,6 @@ class CommentEmbeddableDocGenNormalizer implements NormalizerInterface, Normaliz
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return 'docgen' === $format ? [CommentEmbeddable::class => true] : [];
|
||||
return 'docgen' === $format ? [CommentEmbeddable::class => true, '*' => false] : [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ class DateNormalizer implements NormalizerInterface, DenormalizerInterface
|
||||
\DateTimeInterface::class => true,
|
||||
\DateTime::class => true,
|
||||
\DateTimeImmutable::class => true,
|
||||
'*' => false,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -84,12 +84,10 @@ class PhonenumberNormalizer implements NormalizerInterface, DenormalizerInterfac
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
if ('json' === $format || 'docgen' === $format) {
|
||||
return [
|
||||
PhoneNumber::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
return match ($format) {
|
||||
'json' => [PhoneNumber::class => true],
|
||||
'docgen' => [PhoneNumber::class => true, '*' => false],
|
||||
default => [],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,12 +149,10 @@ class UserNormalizer implements NormalizerInterface, NormalizerAwareInterface
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
if ('json' === $format || 'docgen' === $format) {
|
||||
return [
|
||||
User::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
return match ($format) {
|
||||
'json' => [User::class => true],
|
||||
'docgen' => [User::class => true, '*' => false],
|
||||
default => [],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user