Skip to content

[Serializer] Fix Serializer deprecations merge #52113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADE-7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ Serializer
// ...
}
```
* Remove `AnnotationLoader`, use `AttributeLoader` instead

Templating
----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1858,9 +1858,9 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder

$serializerLoaders = [];
if (isset($config['enable_attributes']) && $config['enable_attributes']) {
$annotationLoader = new Definition(AttributeLoader::class);
$attributeLoader = new Definition(AttributeLoader::class);

$serializerLoaders[] = $annotationLoader;
$serializerLoaders[] = $attributeLoader;
}

$fileRecorder = function ($extension, $path) use (&$serializerLoaders) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Serializer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CHANGELOG
* Require explicit argument when calling `AttributeMetadata::setSerializedName()` and `ClassMetadata::setClassDiscriminatorMapping()`
* Add argument `$context` to `NormalizerInterface::supportsNormalization()` and `DenormalizerInterface::supportsDenormalization()`
* Remove Doctrine annotations support in favor of native attributes
* Remove the annotation reader parameter from the constructor of `AnnotationLoader`
* Remove `AnnotationLoader`, use `AttributeLoader` instead

6.4
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,3 @@ private function getPropertyAnnotations(\ReflectionProperty $reflector): array
return $annotations;
}
}

if (!class_exists(AnnotationLoader::class, false)) {
class_alias(AttributeLoader::class, AnnotationLoader::class);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
use Symfony\Component\Serializer\Mapping\ClassMetadata;
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\AbstractDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\AbstractDummyFirstChild;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\AbstractDummySecondChild;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\AbstractDummyThirdChild;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\BadAttributeDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\BadMethodContextDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\ContextDummyParent;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\ContextDummyPromotedProperties;
Expand All @@ -46,19 +44,16 @@
/**
* @author Kévin Dunglas <dunglas@gmail.com>
*/
<<<<<<<< HEAD:src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php
========
abstract class AttributeLoaderTestCase extends TestCase
>>>>>>>> 6.4:src/Symfony/Component/Serializer/Tests/Mapping/Loader/AttributeLoaderTestCase.php
class AttributeLoaderTest extends TestCase
{
use ContextMappingTestTrait;
use ExpectDeprecationTrait;

private AnnotationLoader $loader;
protected AttributeLoader $loader;

protected function setUp(): void
{
$this->loader = new AnnotationLoader();
$this->loader = new AttributeLoader();
}

public function testInterface()
Expand Down Expand Up @@ -226,9 +221,7 @@ public function testLoadGroupsOnClass()
self::assertSame(['a'], $attributesMetadata['baz']->getGroups());
}

abstract protected function createLoader(): AttributeLoader;

protected function getLoaderForContextMapping(): AnnotationLoader
protected function getLoaderForContextMapping(): AttributeLoader
{
return $this->loader;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Symfony\Component\Serializer\Mapping\ClassMetadata;
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;

class AttributeLoaderWithAttributesTest extends AttributeLoaderTestCase
class AttributeLoaderWithAttributesTest extends AttributeLoaderTest
{
protected function createLoader(): AttributeLoader
{
Expand Down