Skip to content

Commit 04b3692

Browse files
[Serializer] Add ->hasCacheableSupportsMethod() to CacheableSupportsMethodInterface
1 parent 4fb6736 commit 04b3692

14 files changed

+98
-11
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @author Kévin Dunglas <dunglas@gmail.com>
2929
*/
30-
abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
30+
abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface
3131
{
3232
use ObjectToPopulateTrait;
3333
use SerializerAwareTrait;
@@ -147,6 +147,14 @@ public function setIgnoredAttributes(array $ignoredAttributes)
147147
return $this;
148148
}
149149

150+
/**
151+
* {@inheritdoc}
152+
*/
153+
public function hasCacheableSupportsMethod(): bool
154+
{
155+
return false;
156+
}
157+
150158
/**
151159
* Detects if the configured circular reference limit is reached.
152160
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*
3131
* @author Kévin Dunglas <dunglas@gmail.com>
3232
*/
33-
abstract class AbstractObjectNormalizer extends AbstractNormalizer implements CacheableSupportsMethodInterface
33+
abstract class AbstractObjectNormalizer extends AbstractNormalizer
3434
{
3535
const ENABLE_MAX_DEPTH = 'enable_max_depth';
3636
const DEPTH_KEY_PATTERN = 'depth_%s::%s';

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @final
2626
*/
27-
class ArrayDenormalizer implements ContextAwareDenormalizerInterface, SerializerAwareInterface
27+
class ArrayDenormalizer implements ContextAwareDenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface
2828
{
2929
/**
3030
* @var SerializerInterface|DenormalizerInterface
@@ -83,4 +83,12 @@ public function setSerializer(SerializerInterface $serializer)
8383

8484
$this->serializer = $serializer;
8585
}
86+
87+
/**
88+
* {@inheritdoc}
89+
*/
90+
public function hasCacheableSupportsMethod(): bool
91+
{
92+
return $this->serializer instanceof CacheableSupportsMethodInterface && $this->serializer->hasCacheableSupportsMethod();
93+
}
8694
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
*/
2323
interface CacheableSupportsMethodInterface
2424
{
25+
public function hasCacheableSupportsMethod(): bool;
2526
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,12 @@ public function supportsNormalization($data, $format = null)
5656
{
5757
return $data instanceof ConstraintViolationListInterface;
5858
}
59+
60+
/**
61+
* {@inheritdoc}
62+
*/
63+
public function hasCacheableSupportsMethod(): bool
64+
{
65+
return __CLASS__ === \get_class($this);
66+
}
5967
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,12 @@ public function supportsDenormalization($data, $type, $format = null)
6767
{
6868
return \is_subclass_of($type, DenormalizableInterface::class);
6969
}
70+
71+
/**
72+
* {@inheritdoc}
73+
*/
74+
public function hasCacheableSupportsMethod(): bool
75+
{
76+
return __CLASS__ === \get_class($this);
77+
}
7078
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ public function supportsDenormalization($data, $type, $format = null)
119119
return isset(self::$supportedTypes[$type]);
120120
}
121121

122+
/**
123+
* {@inheritdoc}
124+
*/
125+
public function hasCacheableSupportsMethod(): bool
126+
{
127+
return __CLASS__ === \get_class($this);
128+
}
129+
122130
/**
123131
* Gets the mime type of the object. Defaults to application/octet-stream.
124132
*

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ public function supportsNormalization($data, $format = null)
5555
return $data instanceof \DateInterval;
5656
}
5757

58+
/**
59+
* {@inheritdoc}
60+
*/
61+
public function hasCacheableSupportsMethod(): bool
62+
{
63+
return __CLASS__ === \get_class($this);
64+
}
65+
5866
/**
5967
* {@inheritdoc}
6068
*

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ public function supportsDenormalization($data, $type, $format = null)
116116
return isset(self::$supportedTypes[$type]);
117117
}
118118

119+
/**
120+
* {@inheritdoc}
121+
*/
122+
public function hasCacheableSupportsMethod(): bool
123+
{
124+
return __CLASS__ === \get_class($this);
125+
}
126+
119127
/**
120128
* Formats datetime errors.
121129
*

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ public function supportsDenormalization($data, $type, $format = null)
5252
return parent::supportsDenormalization($data, $type, $format) && $this->supports($type);
5353
}
5454

55+
/**
56+
* {@inheritdoc}
57+
*/
58+
public function hasCacheableSupportsMethod(): bool
59+
{
60+
return __CLASS__ === \get_class($this);
61+
}
62+
5563
/**
5664
* Checks if the given class has any get{Property} method.
5765
*/

0 commit comments

Comments
 (0)