8000 feature #51454 [Validator] Un-deprecate passing an annotation reader … · symfony/symfony@991d81e · GitHub
[go: up one dir, main page]

Skip to content

Commit 991d81e

Browse files
committed
feature #51454 [Validator] Un-deprecate passing an annotation reader to AnnotationLoader (derrabus)
This PR was merged into the 6.4 branch. Discussion ---------- [Validator] Un-deprecate passing an annotation reader to AnnotationLoader | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Follow-up to #51425 | License | MIT | Doc PR | N/A #51425 deprecated the `AnnotationLoader` class and its replacement already does not accept an annotation reader anymore. Thus, the deprecation of the constructor parameter is redundant, which is why I propose to take it back. cc `@alexandre`-daubois Commits ------- 4fa1d32 [Validator] Un-deprecate passing an annotation reader to AnnotationLoader
2 parents 7188f85 + 4fa1d32 commit 991d81e

File tree

7 files changed

+5
-48
lines changed

7 files changed

+5
-48
lines changed

UPGRADE-6.4.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ Validator
157157
---------
158158

159159
* Deprecate Doctrine annotations support in favor of native attributes
160-
* Deprecate passing an annotation reader to the constructor signature of `AnnotationLoader`
161160
* Deprecate `ValidatorBuilder::setDoctrineAnnotationReader()`
162161
* Deprecate `ValidatorBuilder::addDefaultDoctrineAnnotationReader()`
163162
* Deprecate `ValidatorBuilder::enableAnnotationMapping()`, use `ValidatorBuilder::enableAttributeMapping()` instead

src/Symfony/Component/Validator/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ CHANGELOG
77
* Allow single integer for the `versions` option of the `Uuid` constraint
88
* Allow single constraint to be passed to the `constraints` option of the `When` constraint
99
* Deprecate Doctrine annotations support in favor of native attributes
10-
* Deprecate passing an annotation reader to the constructor signature of `AnnotationLoader`
1110
* Deprecate `ValidatorBuilder::s 8000 etDoctrineAnnotationReader()`
1211
* Deprecate `ValidatorBuilder::addDefaultDoctrineAnnotationReader()`
1312
* Add `number`, `finite-number` and `finite-float` types to `Type` constraint

src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ class AnnotationLoader implements LoaderInterface
3838

3939
public function __construct(Reader $reader = null)
4040
{
41-
if ($reader) {
42-
trigger_deprecation('symfony/validator', '6.4', 'Passing a "%s" instance as argument 1 to "%s()" is deprecated, pass null or omit the parameter instead.', get_debug_type($reader), __METHOD__);
43-
}
44-
4541
$this->reader = $reader;
4642
}
4743

src/Symfony/Component/Validator/Tests/Constraints/WhenTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ public function testNonConstraintsAreRejected()
5151
*/
5252
public function testAnnotations()
5353
{
54-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
55-
5654
$loader = new AnnotationLoader(new AnnotationReader());
5755
$metadata = new ClassMetadata(WhenTestWithAnnotations::class);
5856

src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderWithHybridAnnotationsTest.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,58 +18,34 @@
1818
/**
1919
* @group legacy
2020
*/
21-
class AnnotationLoaderWithHybridAnnotationsTest extends AnnotationLoaderTest
21+
class AnnotationLoaderWithHybridAnnotationsTest extends AttributeLoaderTest
2222
{
2323
use ExpectDeprecationTrait;
2424

2525
public function testLoadClassMetadataReturnsTrueIfSuccessful()
2626
{
27-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
2827
$this->expectDeprecation('Since symfony/validator 6.4: Class "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
2928
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity::$firstName" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
3029

3130
parent::testLoadClassMetadataReturnsTrueIfSuccessful();
3231
}
3332

34-
public function testLoadClassMetadataReturnsFalseIfNotSuccessful()
35-
{
36-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
37-
38-
parent::testLoadClassMetadataReturnsFalseIfNotSuccessful();
39-
}
40-
4133
public function testLoadClassMetadata()
4234
{
43-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
4435
$this->expectDeprecation('Since symfony/validator 6.4: Class "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
4536
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity::$firstName" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
4637

4738
parent::testLoadClassMetadata();
4839
}
4940

50-
public function testLoadParentClassMetadata()
51-
{
52-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
53-
54-
parent::testLoadParentClassMetadata();
55-
}
56-
5741
public function testLoadClassMetadataAndMerge()
5842
{
59-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
6043
$this->expectDeprecation('Since symfony/validator 6.4: Class "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
6144
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity::$firstName" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
6245

6346
parent::testLoadClassMetadataAndMerge();
6447
}
6548

66-
public function testLoadGroupSequenceProviderAnnotation()
67-
{
68-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
69-
70-
parent::testLoadGroupSequenceProviderAnnotation();
71-
}
72-
7349
protected function createAnnotationLoader(): AnnotationLoader
7450
{
7551
return new AnnotationLoader(new AnnotationReader());

src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderWithLegacyAnnotationsTest.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
/**
1919
* @group legacy
2020
*/
21-
class AnnotationLoaderWithLegacyAnnotationsTest extends AnnotationLoaderTest
21+
class AnnotationLoaderWithLegacyAnnotationsTest extends AttributeLoaderTest
2222
{
2323
use ExpectDeprecationTrait;
2424

2525
public function testLoadClassMetadataReturnsTrueIfSuccessful()
2626
{
27-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
2827
$this->expectDeprecation('Since symfony/validator 6.4: Class "Symfony\Component\Validator\Tests\Fixtures\Annotation\Entity" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
2928
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Annotation\Entity::$firstName" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
3029
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Annotation\Entity::$childA" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
@@ -38,16 +37,8 @@ public function testLoadClassMetadataReturnsTrueIfSuccessful()
3837
parent::testLoadClassMetadataReturnsTrueIfSuccessful();
3938
}
4039

41-
public function testLoadClassMetadataReturnsFalseIfNotSuccessful()
42-
{
43-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
44-
45-
parent::testLoadClassMetadataReturnsFalseIfNotSuccessful();
46-
}
47-
4840
public function testLoadClassMetadata()
4941
{
50-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
5142
$this->expectDeprecation('Since symfony/validator 6.4: Class "Symfony\Component\Validator\Tests\Fixtures\Annotation\Entity" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
5243
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Annotation\Entity::$firstName" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
5344
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Annotation\Entity::$childA" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead. 10000 ');
@@ -63,15 +54,13 @@ public function testLoadClassMetadata()
6354

6455
public function testLoadParentClassMetadata()
6556
{
66-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
6757
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Annotation\EntityParent::$other" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
6858

6959
parent::testLoadParentClassMetadata();
7060
}
7161

7262
public function testLoadClassMetadataAndMerge()
7363
{
74-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
7564
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Annotation\EntityParent::$other" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
7665
$this->expectDeprecation('Since symfony/validator 6.4: Class "Symfony\Component\Validator\Tests\Fixtures\Annotation\Entity" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
7766
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Annotation\Entity::$firstName" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
@@ -88,7 +77,6 @@ public function testLoadClassMetadataAndMerge()
8877

8978
public function testLoadGroupSequenceProviderAnnotation()
9079
{
91-
$this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.');
9280
$this->expectDeprecation('Since symfony/validator 6.4: Class "Symfony\Component\Validator\Tests\Fixtures\Annotation\GroupSequenceProviderEntity" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
9381

9482
parent::testLoadGroupSequenceProviderAnnotation();

src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php renamed to src/Symfony/Component/Validator/Tests/Mapping/Loader/AttributeLoaderTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
use Symfony\Component\Validator\Constraints\Valid;
3131
use Symfony\Component\Validator\Mapping\ClassMetadata;
3232
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
33+
use Symfony\Component\Validator\Mapping\Loader\AttributeLoader;
3334
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
3435

35-
class AnnotationLoaderTest extends TestCase
36+
class AttributeLoaderTest extends TestCase
3637
{
3738
public function testLoadClassMetadataReturnsTrueIfSuccessful()
3839
{
@@ -212,7 +213,7 @@ public function testLoadGroupSequenceProviderAnnotation()
212213

213214
protected function createAnnotationLoader(): AnnotationLoader
214215
{
215-
return new AnnotationLoader();
216+
return new AttributeLoader();
216217
}
217218

218219
protected function getFixtureNamespace(): string

0 commit comments

Comments
 (0)
0