Skip to content

Commit 61a7680

Browse files
committed
minor #15256 Calling enableAnnotationMapping without argument is deprecated (l-vo)
This PR was merged into the 5.2 branch. Discussion ---------- Calling enableAnnotationMapping without argument is deprecated Since 5.2, first argument of `enableAnnotationMapping` must be set to true (https://github.com/symfony/symfony/blob/v5.2.0/src/Symfony/Component/Validator/ValidatorBuilder.php#L227) Closes #14522 (I guess). Commits ------- eb0c8a4 Calling enableAnnotationMapping without argument is deprecated
2 parents 5ab1233 + eb0c8a4 commit 61a7680

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

components/validator/resources.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ prefixed classes included in doc block comments (``/** ... */``). For example::
106106
}
107107

108108
To enable the annotation loader, call the
109-
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAnnotationMapping`
110-
method. It takes an optional annotation reader instance, which defaults to
111-
``Doctrine\Common\Annotations\AnnotationReader``::
109+
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAnnotationMapping` method.
110+
``addDefaultDoctrineAnnotationReader`` must also be called to use ``Doctrine\Common\Annotations\AnnotationReader``::
112111

113112
use Symfony\Component\Validator\Validation;
114113

115114
$validator = Validation::createValidatorBuilder()
116-
->enableAnnotationMapping()
115+
->enableAnnotationMapping(true)
116+
->addDefaultDoctrineAnnotationReader()
117117
->getValidator();
118118

119119
To disable the annotation loader after it was enabled, call
@@ -134,7 +134,8 @@ multiple mappings::
134134
use Symfony\Component\Validator\Validation;
135135

136136
$validator = Validation::createValidatorBuilder()
137-
->enableAnnotationMapping()
137+
->enableAnnotationMapping(true)
138+
->addDefaultDoctrineAnnotationReader()
138139
->addMethodMapping('loadValidatorMetadata')
139140
->addXmlMapping('validator/validation.xml')
140141
->getValidator();

form/unit_testing.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ allows you to return a list of extensions to register::
219219

220220
// or if you also need to read constraints from annotations
221221
$validator = Validation::createValidatorBuilder()
222-
->enableAnnotationMapping()
222+
->enableAnnotationMapping(true)
223+
->addDefaultDoctrineAnnotationReader()
223224
->getValidator();
224225

225226
return [

0 commit comments

Comments
 (0)