Skip to content

Commit 187f878

Browse files
committed
minor symfony#57484 [Serializer] Use SUPPORTED_TYPES in Normalizers when available (alexandre-daubois)
This PR was merged into the 7.2 branch. Discussion ---------- [Serializer] Use `SUPPORTED_TYPES` in Normalizers when available | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT In both normalizers, a constant exists to define supported types. Let's reuse it in `getSupportedTypes()` to ease addition/removal of type in the future? Commits ------- 13bc189 [Serializer] Use `SUPPORTED_TYPES` in Normalizers when available
2 parents 8f71c8d + 13bc189 commit 187f878

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ public function __construct(?MimeTypeGuesserInterface $mimeTypeGuesser = null)
4444

4545
public function getSupportedTypes(?string $format): array
4646
{
47-
return [
48-
\SplFileInfo::class => true,
49-
\SplFileObject::class => true,
50-
File::class => true,
51-
];
47+
return self::SUPPORTED_TYPES;
5248
}
5349

5450
public function normalize(mixed $object, ?string $format = null, array $context = []): string

src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ public function setDefaultContext(array $defaultContext): void
5050

5151
public function getSupportedTypes(?string $format): array
5252
{
53-
return [
54-
\DateTimeInterface::class => true,
55-
\DateTimeImmutable::class => true,
56-
\DateTime::class => true,
57-
];
53+
return self::SUPPORTED_TYPES;
5854
}
5955

6056
/**

0 commit comments

Comments
 (0)