@@ -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(newAnnotationLoader(new AnnotationReader() ));
670+ $classMetadataFactory = new ClassMetadataFactory(newAttributeLoader( ));
649671
650672 $metadataAwareNameConverter = new MetadataAwareNameConverter($classMetadataFactory);
651673
@@ -1533,10 +1555,9 @@ Instead of throwing an exception, a custom callable can be executed when the
15331555maximum depth is reached. This is especially useful when serializing entities
15341556having unique identifiers::
15351557
1536- use Doctrine\Common\Annotations\AnnotationReader;
15371558 use Symfony\Component\Serializer\Annotation\MaxDepth;
15381559 use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
1539- use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader ;
1560+ use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader ;
15401561 use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
15411562 use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
15421563 use Symfony\Component\Serializer\Serializer;
@@ -1560,7 +1581,7 @@ having unique identifiers::
15601581 $level3->id = 3;
15611582 $level2->child = $level3;
15621583
1563- $classMetadataFactory = new ClassMetadataFactory(newAnnotationLoader(new AnnotationReader() ));
1584+ $classMetadataFactory = new ClassMetadataFactory(newAttributeLoader( ));
15641585
15651586 // all callback parameters are optional (you can omit the ones you don't use)
15661587 $maxDepthHandler = function (object $innerObject, object $outerObject, string $attributeName, string $format = null, array $context = []): string {
@@ -1761,7 +1782,7 @@ this is already set up and you only need to provide the configuration. Otherwise
17611782 use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
17621783 use Symfony\Component\Serializer\Serializer;
17631784
1764- $classMetadataFactory = new ClassMetadataFactory(newAnnotationLoader(new AnnotationReader() ));
1785+ $classMetadataFactory = new ClassMetadataFactory(newAttributeLoader( ));
17651786
17661787 $discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
17671788