Skip to content

Commit

Permalink
[Serializer] Remove BC layer
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrixx committed Jun 21, 2023
1 parent 2a2c825 commit 28984f1
Show file tree
Hide file tree
Showing 36 changed files with 70 additions and 426 deletions.
24 changes: 12 additions & 12 deletions .github/expected-missing-return-types.diff
Original file line number Diff line number Diff line change
Expand Up @@ -11875,24 +11875,24 @@ index b684fddb2f..ade2242791 100644
{
return $this->data;
diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
index 079b1e7a9e..e3cfe43e67 100644
index efe4a6e0e1..fbf291af7e 100644
--- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
@@ -221,5 +221,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
@@ -211,5 +211,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
* @throws LogicException if the 'allow_extra_attributes' context variable is false and no class metadata factory is provided
*/
- protected function getAllowedAttributes(string|object $classOrObject, array $context, bool $attributesAsString = false)
+ protected function getAllowedAttributes(string|object $classOrObject, array $context, bool $attributesAsString = false): array|bool
{
$allowExtraAttributes = $context[self::ALLOW_EXTRA_ATTRIBUTES] ?? $this->defaultContext[self::ALLOW_EXTRA_ATTRIBUTES];
@@ -271,5 +271,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
@@ -261,5 +261,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
* @return bool
*/
- protected function isAllowedAttribute(object|string $classOrObject, string $attribute, string $format = null, array $context = [])
+ protected function isAllowedAttribute(object|string $classOrObject, string $attribute, string $format = null, array $context = []): bool
{
$ignoredAttributes = $context[self::IGNORED_ATTRIBUTES] ?? $this->defaultContext[self::IGNORED_ATTRIBUTES];
@@ -322,5 +322,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
@@ -312,5 +312,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
* @throws MissingConstructorArgumentsException
*/
- protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null)
Expand Down Expand Up @@ -11980,7 +11980,7 @@ index 48e8c3fb54..a71c3ea476 100644
+ public function setDenormalizer(DenormalizerInterface $denormalizer): void;
}
diff --git a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
index 4edb70096d..8c844785db 100644
index 7faa516980..cb1855c209 100644
--- a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
+++ b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
@@ -47,5 +47,5 @@ interface DenormalizerInterface
Expand All @@ -11998,10 +11998,10 @@ index 4edb70096d..8c844785db 100644

/**
diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
index 063d34ea59..fb10337d35 100644
index 52a2daca91..99e06f844e 100644
--- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
@@ -147,5 +147,5 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer
@@ -137,5 +137,5 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer
* @return void
*/
- protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = [])
Expand Down Expand Up @@ -12030,7 +12030,7 @@ index 40a4fa0e8c..a1e2749aae 100644
{
$this->normalizer = $normalizer;
diff --git a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
index 40779de316..105cf99b06 100644
index b956e260b3..6382cde0c8 100644
--- a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
+++ b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
@@ -39,5 +39,5 @@ interface NormalizerInterface
Expand All @@ -12048,21 +12048,21 @@ index 40779de316..105cf99b06 100644

/**
diff --git a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
index 357c36426e..f4423f47f4 100644
index 2e61947c28..6b604baa04 100644
--- a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
@@ -146,5 +146,5 @@ class ObjectNormalizer extends AbstractObjectNormalizer
@@ -136,5 +136,5 @@ class ObjectNormalizer extends AbstractObjectNormalizer
* @return void
*/
- protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = [])
+ protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = []): void
{
try {
diff --git a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php
index ec12db9bb2..d3b7f036a8 100644
index 39810e10c9..57e2adbdd5 100644
--- a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php
@@ -187,5 +187,5 @@ class PropertyNormalizer extends AbstractObjectNormalizer
@@ -177,5 +177,5 @@ class PropertyNormalizer extends AbstractObjectNormalizer
* @return void
*/
- protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\Messenger\Transport\Serialization\Serializer;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;

Expand All @@ -22,7 +22,7 @@
*
* @author Pascal Luna <skalpa@zetareticuli.org>
*/
final class FlattenExceptionNormalizer implements DenormalizerInterface, ContextAwareNormalizerInterface
final class FlattenExceptionNormalizer implements DenormalizerInterface, NormalizerInterface
{
use NormalizerAwareTrait;

Expand Down
20 changes: 1 addition & 19 deletions src/Symfony/Component/Serializer/Debug/TraceableNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,16 @@
*
* @internal
*/
class TraceableNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, NormalizerAwareInterface, DenormalizerAwareInterface, CacheableSupportsMethodInterface
class TraceableNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, NormalizerAwareInterface, DenormalizerAwareInterface
{
public function __construct(
private NormalizerInterface|DenormalizerInterface $normalizer,
private SerializerDataCollector $dataCollector,
) {
if (!method_exists($normalizer, 'getSupportedTypes')) {
trigger_deprecation('symfony/serializer', '6.3', 'Not implementing the "NormalizerInterface::getSupportedTypes()" in "%s" is deprecated.', get_debug_type($normalizer));
}
}

public function getSupportedTypes(?string $format): array

Check failure on line 38 in src/Symfony/Component/Serializer/Debug/TraceableNormalizer.php

View workflow job for this annotation

GitHub Actions / Psalm

LessSpecificImplementedReturnType

src/Symfony/Component/Serializer/Debug/TraceableNormalizer.php:38:57: LessSpecificImplementedReturnType: The inherited return type 'array<string, bool|null>' for Symfony\Component\Serializer\Normalizer\NormalizerInterface::getSupportedTypes is more specific than the implemented return type for Symfony\Component\Serializer\Debug\TraceableNormalizer::getsupportedtypes 'array<array-key, mixed>' (see https://psalm.dev/166)

Check failure on line 38 in src/Symfony/Component/Serializer/Debug/TraceableNormalizer.php

View workflow job for this annotation

GitHub Actions / Psalm

LessSpecificImplementedReturnType

src/Symfony/Component/Serializer/Debug/TraceableNormalizer.php:38:57: LessSpecificImplementedReturnType: The inherited return type 'array<string, bool|null>' for Symfony\Component\Serializer\Normalizer\DenormalizerInterface::getSupportedTypes is more specific than the implemented return type for Symfony\Component\Serializer\Debug\TraceableNormalizer::getsupportedtypes 'array<array-key, mixed>' (see https://psalm.dev/166)
{
// @deprecated remove condition in 7.0
if (!method_exists($this->normalizer, 'getSupportedTypes')) {
return ['*' => $this->normalizer instanceof CacheableSupportsMethodInterface && $this->normalizer->hasCacheableSupportsMethod()];
}

return $this->normalizer->getSupportedTypes($format);
}

Expand Down Expand Up @@ -127,16 +119,6 @@ public function setDenormalizer(DenormalizerInterface $denormalizer): void
$this->normalizer->setDenormalizer($denormalizer);
}

/**
* @deprecated since Symfony 6.3, use "getSupportedTypes()" instead
*/
public function hasCacheableSupportsMethod(): bool
{
trigger_deprecation('symfony/serializer', '6.3', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__);

return $this->normalizer instanceof CacheableSupportsMethodInterface && $this->normalizer->hasCacheableSupportsMethod();
}

/**
* Proxies all method calls to the original normalizer.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Serializer\DataCollector\SerializerDataCollector;
use Symfony\Component\Serializer\Encoder\DecoderInterface;
use Symfony\Component\Serializer\Encoder\EncoderInterface;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\SerializerInterface;
Expand All @@ -34,9 +33,6 @@ public function __construct(
private SerializerInterface&NormalizerInterface&DenormalizerInterface&EncoderInterface&DecoderInterface $serializer,
private SerializerDataCollector $dataCollector,
) {
if (!method_exists($serializer, 'getSupportedTypes')) {
trigger_deprecation('symfony/serializer', '6.3', 'Not implementing the "NormalizerInterface::getSupportedTypes()" in "%s" is deprecated.', get_debug_type($serializer));
}
}

public function serialize(mixed $data, string $format, array $context = []): string
Expand Down Expand Up @@ -131,11 +127,6 @@ public function decode(string $data, string $format, array $context = []): mixed

public function getSupportedTypes(?string $format): array

Check failure on line 128 in src/Symfony/Component/Serializer/Debug/TraceableSerializer.php

View workflow job for this annotation

GitHub Actions / Psalm

LessSpecificImplementedReturnType

src/Symfony/Component/Serializer/Debug/TraceableSerializer.php:128:57: LessSpecificImplementedReturnType: The inherited return type 'array<string, bool|null>' for Symfony\Component\Serializer\Normalizer\NormalizerInterface::getSupportedTypes is more specific than the implemented return type for Symfony\Component\Serializer\Debug\TraceableSerializer::getsupportedtypes 'array<array-key, mixed>' (see https://psalm.dev/166)

Check failure on line 128 in src/Symfony/Component/Serializer/Debug/TraceableSerializer.php

View workflow job for this annotation

GitHub Actions / Psalm

LessSpecificImplementedReturnType

src/Symfony/Component/Serializer/Debug/TraceableSerializer.php:128:57: LessSpecificImplementedReturnType: The inherited return type 'array<string, bool|null>' for Symfony\Component\Serializer\Normalizer\DenormalizerInterface::getSupportedTypes is more specific than the implemented return type for Symfony\Component\Serializer\Debug\TraceableSerializer::getsupportedtypes 'array<array-key, mixed>' (see https://psalm.dev/166)
{
// @deprecated remove condition in 7.0
if (!method_exists($this->serializer, 'getSupportedTypes')) {
return ['*' => $this->serializer instanceof CacheableSupportsMethodInterface && $this->serializer->hasCacheableSupportsMethod()];
}

return $this->serializer->getSupportedTypes($format);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,8 @@ public function getMaxDepth(): ?int
return $this->maxDepth;
}

public function setSerializedName(string $serializedName = null): void
public function setSerializedName(?string $serializedName): void
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/serializer', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}

$this->serializedName = $serializedName;
}

Expand Down
5 changes: 1 addition & 4 deletions src/Symfony/Component/Serializer/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@ public function getClassDiscriminatorMapping(): ?ClassDiscriminatorMapping
return $this->classDiscriminatorMapping;
}

public function setClassDiscriminatorMapping(ClassDiscriminatorMapping $mapping = null): void
public function setClassDiscriminatorMapping(?ClassDiscriminatorMapping $mapping): void
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/serializer', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
$this->classDiscriminatorMapping = $mapping;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @author Kévin Dunglas <dunglas@gmail.com>
*/
abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface
abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
{
use ObjectToPopulateTrait;
use SerializerAwareTrait;
Expand Down Expand Up @@ -156,16 +156,6 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory
}
}

/**
* @deprecated since Symfony 6.3, use "getSupportedTypes()" instead
*/
public function hasCacheableSupportsMethod(): bool
{
trigger_deprecation('symfony/serializer', '6.3', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__);

return false;
}

/**
* Detects if the configured circular reference limit is reached.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@
*
* @final
*/
class ArrayDenormalizer implements ContextAwareDenormalizerInterface, DenormalizerAwareInterface, CacheableSupportsMethodInterface
class ArrayDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface
{
use DenormalizerAwareTrait;

public function setDenormalizer(DenormalizerInterface $denormalizer): void
{
if (!method_exists($denormalizer, 'getSupportedTypes')) {
trigger_deprecation('symfony/serializer', '6.3', 'Not implementing the "DenormalizerInterface::getSupportedTypes()" in "%s" is deprecated.', get_debug_type($denormalizer));
}

$this->denormalizer = $denormalizer;
}

Expand Down Expand Up @@ -82,14 +78,4 @@ public function supportsDenormalization(mixed $data, string $type, string $forma
return str_ends_with($type, '[]')
&& $this->denormalizer->supportsDenormalization($data, substr($type, 0, -2), $format, $context);
}

/**
* @deprecated since Symfony 6.3, use "getSupportedTypes()" instead
*/
public function hasCacheableSupportsMethod(): bool
{
trigger_deprecation('symfony/serializer', '6.3', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__);

return $this->denormalizer instanceof CacheableSupportsMethodInterface && $this->denormalizer->hasCacheableSupportsMethod();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @author Alexandre Daubois <alex.daubois@gmail.com>
*/
final class BackedEnumNormalizer implements NormalizerInterface, DenormalizerInterface, CacheableSupportsMethodInterface
final class BackedEnumNormalizer implements NormalizerInterface, DenormalizerInterface
{
/**
* If true, will denormalize any invalid value into null.
Expand Down Expand Up @@ -88,14 +88,4 @@ public function supportsDenormalization(mixed $data, string $type, string $forma
{
return is_subclass_of($type, \BackedEnum::class);
}

/**
* @deprecated since Symfony 6.3, use "getSupportedTypes()" instead
*/
public function hasCacheableSupportsMethod(): bool
{
trigger_deprecation('symfony/serializer', '6.3', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__);

return true;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @final since Symfony 6.3
*/
class ConstraintViolationListNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface
class ConstraintViolationListNormalizer implements NormalizerInterface
{
public const INSTANCE = 'instance';
public const STATUS = 'status';
Expand All @@ -41,7 +41,7 @@ public function __construct(
public function getSupportedTypes(?string $format): array
{
return [
ConstraintViolationListInterface::class => __CLASS__ === static::class || $this->hasCacheableSupportsMethod(),
ConstraintViolationListInterface::class => __CLASS__ === static::class,
];
}

Expand Down Expand Up @@ -111,18 +111,8 @@ public function normalize(mixed $object, string $format = null, array $context =
/**
* @param array $context
*/
public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */): bool
public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool
{
return $data instanceof ConstraintViolationListInterface;
}

/**
* @deprecated since Symfony 6.3, use "getSupportedTypes()" instead
*/
public function hasCacheableSupportsMethod(): bool
{
trigger_deprecation('symfony/serializer', '6.3', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__);

return __CLASS__ === static::class;
}
}

This file was deleted.

Loading

0 comments on commit 28984f1

Please sign in to comment.