Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc37d3c

Browse files
feature#41392 [Validator] Remove deprecated code (jschaedl)
This PR was squashed before being merged into the 6.0 branch.Discussion----------[Validator] Remove deprecated code| Q | A| ------------- | ---| Branch? | 6.0| Bug fix? | no| New feature? | no <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets | - <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->| License | MIT| Doc PR | <!-- required for new features -->- [x] remove deprecated code- [x] fix tests- [x] update CHANGELOGCommits-------e44ac6b [Validator] Remove deprecated code
2 parents17800d1 +e44ac6b commitfc37d3c

17 files changed

+37
-249
lines changed

‎UPGRADE-6.0.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ Validator
384384
After:
385385

386386
```php
387-
$builder->enableAnnotationMapping(true)
387+
$builder
388+
->enableAnnotationMapping()
388389
->setDoctrineAnnotationReader($reader);
389390
```
390391

@@ -399,7 +400,8 @@ Validator
399400
After:
400401

401402
```php
402-
$builder->enableAnnotationMapping(true)
403+
$builder
404+
->enableAnnotationMapping()
403405
->addDefaultDoctrineAnnotationReader();
404406
```
405407

‎src/Symfony/Component/Validator/CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
CHANGELOG
22
=========
33

4+
6.0
5+
---
6+
7+
* Remove the`allowEmptyString` option from the`Length` constraint
8+
* Remove the`NumberConstraintTrait` trait
9+
*`ValidatorBuilder::enableAnnotationMapping()` does not accept a Doctrine annotation reader anymore
10+
*`ValidatorBuilder::enableAnnotationMapping()` won't automatically setup a Doctrine annotation reader anymore
11+
412
5.3
513
---
614
* Add the`normalizer` option to the`Unique` constraint

‎src/Symfony/Component/Validator/Constraints/Length.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Length extends Constraint
4242
public$min;
4343
public$charset ='UTF-8';
4444
public$normalizer;
45-
public$allowEmptyString =false;
4645

4746
/**
4847
* {@inheritdoc}
@@ -95,9 +94,5 @@ public function __construct(
9594
if (null !==$this->normalizer && !\is_callable($this->normalizer)) {
9695
thrownewInvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).',get_debug_type($this->normalizer)));
9796
}
98-
99-
if (isset($options['allowEmptyString'])) {
100-
trigger_deprecation('symfony/validator','5.2',sprintf('The "allowEmptyString" option of the "%s" constraint is deprecated.',self::class));
101-
}
10297
}
10398
}

‎src/Symfony/Component/Validator/Constraints/LengthValidator.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function validate($value, Constraint $constraint)
3030
thrownewUnexpectedTypeException($constraint, Length::class);
3131
}
3232

33-
if (null ===$value || ('' ===$value &&$constraint->allowEmptyString)) {
33+
if (null ===$value) {
3434
return;
3535
}
3636

‎src/Symfony/Component/Validator/Constraints/NumberConstraintTrait.php‎

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎src/Symfony/Component/Validator/Constraints/Range.php‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,8 @@ public function __construct(
107107
thrownewLogicException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "minPropertyPath" or "maxPropertyPath" option.',static::class));
108108
}
109109

110-
if (null !==$this->min &&null !==$this->max) {
111-
$this->deprecatedMinMessageSet =isset($options['minMessage']) ||null !==$minMessage;
112-
$this->deprecatedMaxMessageSet =isset($options['maxMessage']) ||null !==$maxMessage;
113-
114-
// BC layer, should throw a ConstraintDefinitionException in 6.0
115-
if ($this->deprecatedMinMessageSet ||$this->deprecatedMaxMessageSet) {
116-
trigger_deprecation('symfony/validator','4.4','"minMessage" and "maxMessage" are deprecated when the "min" and "max" options are both set. Use "notInRangeMessage" instead.');
117-
}
110+
if (null !==$this->min &&null !==$this->max && ($minMessage ||$maxMessage)) {
111+
thrownewConstraintDefinitionException(sprintf('The "%s" constraint can not use "minMessage" and "maxMessage" when the "min" and "max" options are both set. Use "notInRangeMessage" instead.',static::class));
118112
}
119113
}
120114
}

‎src/Symfony/Component/Validator/DependencyInjection/AddAutoMappingConfigurationPass.php‎

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,12 @@
2222
*/
2323
class AddAutoMappingConfigurationPassimplements CompilerPassInterface
2424
{
25-
private$validatorBuilderService;
26-
private$tag;
27-
28-
publicfunction__construct(string$validatorBuilderService ='validator.builder',string$tag ='validator.auto_mapper')
29-
{
30-
if (0 <\func_num_args()) {
31-
trigger_deprecation('symfony/validator','5.3','Configuring "%s" is deprecated.',__CLASS__);
32-
}
33-
34-
$this->validatorBuilderService =$validatorBuilderService;
35-
$this->tag =$tag;
36-
}
37-
3825
/**
3926
* {@inheritdoc}
4027
*/
4128
publicfunctionprocess(ContainerBuilder$container)
4229
{
43-
if (!$container->hasParameter('validator.auto_mapping') || !$container->hasDefinition($this->validatorBuilderService)) {
30+
if (!$container->hasParameter('validator.auto_mapping') || !$container->hasDefinition('validator.builder')) {
4431
return;
4532
}
4633

@@ -60,8 +47,8 @@ public function process(ContainerBuilder $container)
6047
}
6148
}
6249

63-
$validatorBuilder =$container->getDefinition($this->validatorBuilderService);
64-
foreach ($container->findTaggedServiceIds($this->tag)as$id =>$tags) {
50+
$validatorBuilder =$container->getDefinition('validator.builder');
51+
foreach ($container->findTaggedServiceIds('validator.auto_mapper')as$id =>$tags) {
6552
$regexp =$this->getRegexp(array_merge($globalNamespaces,$servicesToNamespaces[$id] ?? []));
6653
$validatorBuilder->addMethodCall('addLoader', [newReference($id)]);
6754
$container->getDefinition($id)->setArgument('$classValidatorRegexp',$regexp);

‎src/Symfony/Component/Validator/DependencyInjection/AddConstraintValidatorsPass.php‎

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,14 @@
2222
*/
2323
class AddConstraintValidatorsPassimplements CompilerPassInterface
2424
{
25-
private$validatorFactoryServiceId;
26-
private$constraintValidatorTag;
27-
28-
publicfunction__construct(string$validatorFactoryServiceId ='validator.validator_factory',string$constraintValidatorTag ='validator.constraint_validator')
29-
{
30-
if (0 <\func_num_args()) {
31-
trigger_deprecation('symfony/validator','5.3','Configuring "%s" is deprecated.',__CLASS__);
32-
}
33-
34-
$this->validatorFactoryServiceId =$validatorFactoryServiceId;
35-
$this->constraintValidatorTag =$constraintValidatorTag;
36-
}
37-
3825
publicfunctionprocess(ContainerBuilder$container)
3926
{
40-
if (!$container->hasDefinition($this->validatorFactoryServiceId)) {
27+
if (!$container->hasDefinition('validator.validator_factory')) {
4128
return;
4229
}
4330

4431
$validators = [];
45-
foreach ($container->findTaggedServiceIds($this->constraintValidatorTag,true)as$id =>$attributes) {
32+
foreach ($container->findTaggedServiceIds('validator.constraint_validator',true)as$id =>$attributes) {
4633
$definition =$container->getDefinition($id);
4734

4835
if (isset($attributes[0]['alias'])) {
@@ -53,7 +40,7 @@ public function process(ContainerBuilder $container)
5340
}
5441

5542
$container
56-
->getDefinition($this->validatorFactoryServiceId)
43+
->getDefinition('validator.validator_factory')
5744
->replaceArgument(0, ServiceLocatorTagPass::register($container,$validators))
5845
;
5946
}

‎src/Symfony/Component/Validator/DependencyInjection/AddValidatorInitializersPass.php‎

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,17 @@
2121
*/
2222
class AddValidatorInitializersPassimplements CompilerPassInterface
2323
{
24-
private$builderService;
25-
private$initializerTag;
26-
27-
publicfunction__construct(string$builderService ='validator.builder',string$initializerTag ='validator.initializer')
28-
{
29-
if (0 <\func_num_args()) {
30-
trigger_deprecation('symfony/validator','5.3','Configuring "%s" is deprecated.',__CLASS__);
31-
}
32-
33-
$this->builderService =$builderService;
34-
$this->initializerTag =$initializerTag;
35-
}
36-
3724
publicfunctionprocess(ContainerBuilder$container)
3825
{
39-
if (!$container->hasDefinition($this->builderService)) {
26+
if (!$container->hasDefinition('validator.builder')) {
4027
return;
4128
}
4229

4330
$initializers = [];
44-
foreach ($container->findTaggedServiceIds($this->initializerTag,true)as$id =>$attributes) {
31+
foreach ($container->findTaggedServiceIds('validator.initializer',true)as$id =>$attributes) {
4532
$initializers[] =newReference($id);
4633
}
4734

48-
$container->getDefinition($this->builderService)->addMethodCall('addObjectInitializers', [$initializers]);
35+
$container->getDefinition('validator.builder')->addMethodCall('addObjectInitializers', [$initializers]);
4936
}
5037
}

‎src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespaceSymfony\Component\Validator\Tests\Constraints;
1313

1414
usePHPUnit\Framework\TestCase;
15-
useSymfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1615
useSymfony\Component\Validator\Constraints\Length;
1716
useSymfony\Component\Validator\Exception\InvalidArgumentException;
1817
useSymfony\Component\Validator\Mapping\ClassMetadata;
@@ -23,8 +22,6 @@
2322
*/
2423
class LengthTestextends TestCase
2524
{
26-
use ExpectDeprecationTrait;
27-
2825
publicfunctiontestNormalizerCanBeSet()
2926
{
3027
$length =newLength(['min' =>0,'max' =>10,'normalizer' =>'trim']);
@@ -46,25 +43,6 @@ public function testInvalidNormalizerObjectThrowsException()
4643
newLength(['min' =>0,'max' =>10,'normalizer' =>new \stdClass()]);
4744
}
4845

49-
/**
50-
* @group legacy
51-
* @dataProvider allowEmptyStringOptionData
52-
*/
53-
publicfunctiontestDeprecatedAllowEmptyStringOption(bool$value)
54-
{
55-
$this->expectDeprecation('Since symfony/validator 5.2: The "allowEmptyString" option of the "Symfony\Component\Validator\Constraints\Length" constraint is deprecated.');
56-
57-
newLength(['allowEmptyString' =>$value,'max' =>5]);
58-
}
59-
60-
publicfunctionallowEmptyStringOptionData()
61-
{
62-
return [
63-
[true],
64-
[false],
65-
];
66-
}
67-
6846
publicfunctiontestConstraintDefaultOption()
6947
{
7048
$constraint =newLength(5);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp