Skip to content

Commit 7288761

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [Serializer] Deprecate annotations
2 parents a0feed2 + 389a5b6 commit 7288761

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

components/property_info.rst

+16-5
Original file line numberDiff line numberDiff line change
@@ -458,19 +458,30 @@ the :class:`Symfony\\Component\\PropertyInfo\\Extractor\\SerializerExtractor`
458458
provides list information. This extractor is *not* registered automatically
459459
with the ``property_info`` service in the Symfony Framework::
460460

461-
use Doctrine\Common\Annotations\AnnotationReader;
462461
use Symfony\Component\PropertyInfo\Extractor\SerializerExtractor;
463462
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
464-
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
463+
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
465464

466-
$serializerClassMetadataFactory = new ClassMetadataFactory(
467-
new AnnotationLoader(new AnnotationReader)
468-
);
465+
$serializerClassMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
469466
$serializerExtractor = new SerializerExtractor($serializerClassMetadataFactory);
470467

471468
// the `serializer_groups` option must be configured (may be set to null)
472469
$serializerExtractor->getProperties($class, ['serializer_groups' => ['mygroup']]);
473470

471+
.. versionadded:: 6.4
472+
473+
The
474+
:class:`Symfony\\Component\\Serializer\\Mapping\\Loader\\AttributeLoader`
475+
was introduced in Symfony 6.4. Prior to this, the
476+
:class:`Symfony\\Component\\Serializer\\Mapping\\Loader\\AnnotationLoader`
477+
must be used.
478+
479+
.. deprecated:: 6.4
480+
481+
The
482+
:class:`Symfony\\Component\\Serializer\\Mapping\\Loader\\AnnotationLoader`
483+
was deprecated in Symfony 6.4.
484+
474485
If ``serializer_groups`` is set to ``null``, serializer groups metadata won't be
475486
checked but you will get only the properties considered by the Serializer
476487
Component (notably the ``@Ignore`` annotation is taken into account).

components/serializer.rst

+26-5
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ for each format:
279279

280280
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
281281

282+
* Attributes in PHP files::
283+
284+
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
285+
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
286+
287+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
288+
282289
* YAML files::
283290

284291
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
@@ -293,6 +300,21 @@ for each format:
293300

294301
$classMetadataFactory = new ClassMetadataFactory(new XmlFileLoader('/path/to/your/definition.xml'));
295302

303+
.. versionadded:: 6.4
304+
305+
The
306+
:class:`Symfony\\Component\\Serializer\\Mapping\\Loader\\AttributeLoader`
307+
was introduced in Symfony 6.4. Prior to this, the
308+
:class:`Symfony\\Component\\Serializer\\Mapping\\Loader\\AnnotationLoader`
309+
must be used.
310+
311+
.. deprecated:: 6.4
312+
313+
Reading annotations in PHP files is deprecated since Symfony 6.4.
314+
Also, the
315+
:class:`Symfony\\Component\\Serializer\\Mapping\\Loader\\AnnotationLoader`
316+
was deprecated in Symfony 6.4.
317+
296318
.. _component-serializer-attributes-groups-annotations:
297319
.. _component-serializer-attributes-groups-attributes:
298320

@@ -645,7 +667,7 @@ this is already set up and you only need to provide the configuration. Otherwise
645667
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
646668
use Symfony\Component\Serializer\Serializer;
647669

648-
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
670+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
649671

650672
$metadataAwareNameConverter = new MetadataAwareNameConverter($classMetadataFactory);
651673

@@ -1507,10 +1529,9 @@ Instead of throwing an exception, a custom callable can be executed when the
15071529
maximum depth is reached. This is especially useful when serializing entities
15081530
having unique identifiers::
15091531

1510-
use Doctrine\Common\Annotations\AnnotationReader;
15111532
use Symfony\Component\Serializer\Annotation\MaxDepth;
15121533
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
1513-
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
1534+
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
15141535
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
15151536
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
15161537
use Symfony\Component\Serializer\Serializer;
@@ -1534,7 +1555,7 @@ having unique identifiers::
15341555
$level3->id = 3;
15351556
$level2->child = $level3;
15361557

1537-
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
1558+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
15381559

15391560
// all callback parameters are optional (you can omit the ones you don't use)
15401561
$maxDepthHandler = function (object $innerObject, object $outerObject, string $attributeName, string $format = null, array $context = []): string {
@@ -1735,7 +1756,7 @@ this is already set up and you only need to provide the configuration. Otherwise
17351756
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
17361757
use Symfony\Component\Serializer\Serializer;
17371758

1738-
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
1759+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
17391760

17401761
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
17411762

0 commit comments

Comments
 (0)