Skip to content

Commit 47239a9

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [Server] Fix typo in Symfony Local Web Server page [Validator] Deprecate annotations
2 parents a9c913a + 2261395 commit 47239a9

File tree

3 files changed

+72
-4
lines changed

3 files changed

+72
-4
lines changed

components/validator/resources.rst

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ configure the locations of these files::
8686
The AnnotationLoader
8787
--------------------
8888

89-
At last, the component provides an
89+
.. deprecated:: 6.4
90+
91+
The :class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AnnotationLoader`
92+
is deprecated since Symfony 6.4, use the
93+
:class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AttributeLoader`
94+
instead.
95+
96+
The component provides an
9097
:class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AnnotationLoader` to get
9198
the metadata from the attributes of the class::
9299

@@ -111,8 +118,44 @@ To enable the annotation loader, call the
111118
To disable the annotation loader after it was enabled, call
112119
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAnnotationMapping`.
113120

121+
.. deprecated:: 6.4
122+
123+
The :method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAnnotationMapping`
124+
and :method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAnnotationMapping`
125+
methods are deprecated since Symfony 6.4, use the
126+
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAttributeMapping`
127+
and :method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAttributeMapping`
128+
methods instead.
129+
114130
.. include:: /_includes/_annotation_loader_tip.rst.inc
115131

132+
The AttributeLoader
133+
-------------------
134+
135+
.. versionadded:: 6.4
136+
137+
The :class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AttributeLoader`
138+
was introduced in Symfony 6.4.
139+
140+
The component provides an
141+
:class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AttributeLoader` to get
142+
the metadata from the attributes of the class. For example::
143+
144+
use Symfony\Component\Validator\Constraints as Assert;
145+
// ...
146+
147+
class User
148+
{
149+
#[Assert\NotBlank]
150+
protected string $name;
151+
}
152+
153+
To enable the attribute loader, call the
154+
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAttributeMapping` method.
155+
156+
To disable the annotation loader after it was enabled, call
157+
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAttributeMapping`.
158+
116159
Using Multiple Loaders
117160
----------------------
118161

@@ -126,7 +169,7 @@ multiple mappings::
126169
use Symfony\Component\Validator\Validation;
127170

128171
$validator = Validation::createValidatorBuilder()
129-
->enableAnnotationMapping(true)
172+
->enableAttributeMapping()
130173
->addMethodMapping('loadValidatorMetadata')
131174
->addXmlMapping('validator/validation.xml')
132175
->getValidator();

form/unit_testing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ allows you to return a list of extensions to register::
216216

217217
// or if you also need to read constraints from annotations
218218
$validator = Validation::createValidatorBuilder()
219-
->enableAnnotationMapping(true)
219+
->enableAttributeMapping()
220220
->getValidator();
221221

222222
return [

reference/configuration/framework.rst

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,19 @@ enable_annotations
26362636

26372637
**type**: ``boolean`` **default**: ``true``
26382638

2639-
If this option is enabled, validation constraints can be defined using annotations or attributes.
2639+
If this option is enabled, validation constraints can be defined using annotations or `PHP attributes`_.
2640+
2641+
.. deprecated:: 6.4
2642+
2643+
This option is deprecated since Symfony 6.4, use the ``enable_attributes``
2644+
option instead.
2645+
2646+
enable_attributes
2647+
.................
2648+
2649+
**type**: ``boolean`` **default**: ``true``
2650+
2651+
If this option is enabled, validation constraints can be defined using `PHP attributes`_.
26402652

26412653
translation_domain
26422654
..................
@@ -2824,6 +2836,18 @@ enable_annotations
28242836

28252837
If this option is enabled, serialization groups can be defined using annotations or attributes.
28262838

2839+
.. deprecated:: 6.4
2840+
2841+
This option is deprecated since Symfony 6.4, use the ``enable_attributes``
2842+
option instead.
2843+
2844+
enable_attributes
2845+
.................
2846+
2847+
**type**: ``boolean`` **default**: ``true``
2848+
2849+
If this option is enabled, serialization groups can be defined using `PHP attributes`_.
2850+
28272851
.. seealso::
28282852

28292853
For more information, see :ref:`serializer-using-serialization-groups-attributes`.
@@ -3788,3 +3812,4 @@ the ``#[WithLogLevel]`` attribute::
37883812
.. _`utf-8 modifier`: https://www.php.net/reference.pcre.pattern.modifiers
37893813
.. _`Link HTTP header`: https://tools.ietf.org/html/rfc5988
37903814
.. _`SMTP session`: https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol#SMTP_transport_example
3815+
.. _`PHP attributes`: https://www.php.net/manual/en/language.attributes.overview.php

0 commit comments

Comments
 (0)