Skip to content

Commit e4f0539

Browse files
committed
minor #18523 [Serializer] Add method and return types needed by NormalizerInterface (alexandre-daubois)
This PR was merged into the 7.0 branch. Discussion ---------- [Serializer] Add method and return types needed by `NormalizerInterface` <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Commits ------- db47478 [Serializer] Add needed method and return types
2 parents 24a7391 + db47478 commit e4f0539

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

serializer/custom_normalizer.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ to customize the normalized data. To do that, leverage the ``ObjectNormalizer``:
3030
) {
3131
}
3232

33-
public function normalize($topic, string $format = null, array $context = [])
33+
public function normalize($topic, string $format = null, array $context = []): array
3434
{
3535
$data = $this->normalizer->normalize($topic, $format, $context);
3636

@@ -42,10 +42,17 @@ to customize the normalized data. To do that, leverage the ``ObjectNormalizer``:
4242
return $data;
4343
}
4444

45-
public function supportsNormalization($data, string $format = null, array $context = [])
45+
public function supportsNormalization($data, string $format = null, array $context = []): bool
4646
{
4747
return $data instanceof Topic;
4848
}
49+
50+
public function getSupportedTypes(?string $format): array
51+
{
52+
return [
53+
Topic::class => true,
54+
];
55+
}
4956
}
5057

5158
Registering it in your Application

0 commit comments

Comments
 (0)