Skip to content

Commit cedfa9c

Browse files
committed
Change visibility of getNormalizer and getDenormalizer
1 parent 934aea0 commit cedfa9c

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ interface DenormalizerInterface
4848
*/
4949
public function denormalize(mixed $data, string $type, string $format = null, array $context = []);
5050

51+
/**
52+
* Returns a matching denormalizer.
53+
*
54+
* @param mixed $data Data to restore
55+
* @param string $class The expected class to instantiate
56+
* @param string|null $format Format name, present to give the option to normalizers to act differently based on formats
57+
* @param array $context Options available to the denormalizer
58+
*/
59+
public function getDenormalizer(mixed $data, string $class, ?string $format, array $context): ?DenormalizerInterface;
60+
5161
/**
5262
* Checks whether the given class is supported for denormalization by this normalizer.
5363
*

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ interface NormalizerInterface
4040
*/
4141
public function normalize(mixed $object, string $format = null, array $context = []);
4242

43+
/**
44+
* Returns a matching normalizer.
45+
*
46+
* @param mixed $data Data to get the serializer for
47+
* @param string|null $format Format name, present to give the option to normalizers to act differently based on formats
48+
* @param array $context Options available to the normalizer
49+
*/
50+
public function getNormalizer(mixed $data, ?string $format, array $context): ?NormalizerInterface;
51+
4352
/**
4453
* Checks whether the given class is supported for normalization by this normalizer.
4554
*

src/Symfony/Component/Serializer/Serializer.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,7 @@ public function supportsDenormalization(mixed $data, string $type, string $forma
249249
return isset(self::SCALAR_TYPES[$type]) || null !== $this->getDenormalizer($data, $type, $format, $context);
250250
}
251251

252-
/**
253-
* Returns a matching normalizer.
254-
*
255-
* @param mixed $data Data to get the serializer for
256-
* @param string|null $format Format name, present to give the option to normalizers to act differently based on formats
257-
* @param array $context Options available to the normalizer
258-
*/
259-
private function getNormalizer(mixed $data, ?string $format, array $context): ?NormalizerInterface
252+
public function getNormalizer(mixed $data, ?string $format, array $context): ?NormalizerInterface
260253
{
261254
if (\is_object($data)) {
262255
$type = $data::class;
@@ -325,15 +318,7 @@ private function getNormalizer(mixed $data, ?string $format, array $context): ?N
325318
return null;
326319
}
327320

328-
/**
329-
* Returns a matching denormalizer.
330-
*
331-
* @param mixed $data Data to restore
332-
* @param string $class The expected class to instantiate
333-
* @param string|null $format Format name, present to give the option to normalizers to act differently based on formats
334-
* @param array $context Options available to the denormalizer
335-
*/
336-
private function getDenormalizer(mixed $data, string $class, ?string $format, array $context): ?DenormalizerInterface
321+
public function getDenormalizer(mixed $data, string $class, ?string $format, array $context): ?DenormalizerInterface
337322
{
338323
if (!isset($this->denormalizerCache[$format][$class])) {
339324
$this->denormalizerCache[$format][$class] = [];

0 commit comments

Comments
 (0)