Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6e2a792

Browse filesBrowse files
[Serializer] Add ->hasCacheableSupportsMethod() to CacheableSupportsMethodInterface
1 parent 4fb6736 commit 6e2a792
Copy full SHA for 6e2a792

14 files changed

+96
-7
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
+9-1Lines 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 CacheableSupportsMethodInteface, NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php
+9-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/CacheableSupportsMethodInterface.php
+1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php
+8Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php
+8Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php
+8Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php
+8Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php
+8Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
+8Lines 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
*/

‎src/Symfony/Component/Serializer/Normalizer/JsonSerializableNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/JsonSerializableNormalizer.php
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
* @author Fred Cox <mcfedr@gmail.com>
2121
*/
22-
class JsonSerializableNormalizer extends AbstractNormalizer implements CacheableSupportsMethodInterface
22+
class JsonSerializableNormalizer extends AbstractNormalizer
2323
{
2424
/**
2525
* {@inheritdoc}
@@ -64,4 +64,12 @@ public function denormalize($data, $class, $format = null, array $context = arra
6464
{
6565
throw new LogicException(sprintf('Cannot denormalize with "%s".', \JsonSerializable::class));
6666
}
67+
68+
/**
69+
* {@inheritdoc}
70+
*/
71+
public function hasCacheableSupportsMethod(): bool
72+
{
73+
return __CLASS__ === \get_class($this);
74+
}
6775
}

‎src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory
4040
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
4141
}
4242

43+
/**
44+
* {@inheritdoc}
45+
*/
46+
public function hasCacheableSupportsMethod(): bool
47+
{
48+
return __CLASS__ === \get_class($this);
49+
}
50+
4351
/**
4452
* {@inheritdoc}
4553
*/

‎src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public function supportsDenormalization($data, $type, $format = null)
4646
return parent::supportsDenormalization($data, $type, $format) && $this->supports($type);
4747
}
4848

49+
/**
50+
* {@inheritdoc}
51+
*/
52+
public function hasCacheableSupportsMethod(): bool
53+
{
54+
return __CLASS__ === \get_class($this);
55+
}
56+
4957
/**
5058
* Checks if the given class has any non-static property.
5159
*/

‎src/Symfony/Component/Serializer/Serializer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Serializer.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
use Symfony\Component\Serializer\Encoder\DecoderInterface;
2020
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
2121
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
22+
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
2223
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
2324
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
2425
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
2526
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
2627
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
2728
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
2829
use Symfony\Component\Serializer\Exception\LogicException;
29-
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
3030

3131
/**
3232
* Serializer serializes and deserializes data.
@@ -221,7 +221,7 @@ private function getNormalizer($data, ?string $format, array $context)
221221
continue;
222222
}
223223

224-
if (!$normalizer instanceof CacheableSupportsMethodInterface) {
224+
if (!$normalizer instanceof CacheableSupportsMethodInterface || !$normalizer->hasCacheableSupportsMethod()) {
225225
$this->normalizerCache[$format][$type][$k] = false;
226226
} elseif ($normalizer->supportsNormalization($data, $format)) {
227227
$this->normalizerCache[$format][$type][$k] = true;
@@ -263,7 +263,7 @@ private function getDenormalizer($data, string $class, ?string $format, array $c
263263
continue;
264264
}
265265

266-
if (!$normalizer instanceof CacheableSupportsMethodInterface) {
266+
if (!$normalizer instanceof CacheableSupportsMethodInterface || !$normalizer->hasCacheableSupportsMethod()) {
267267
$this->denormalizerCache[$format][$class][$k] = false;
268268
} elseif ($normalizer->supportsDenormalization(null, $class, $format)) {
269269
$this->denormalizerCache[$format][$class][$k] = true;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.