From 4fa1d32082fff792c86c2c83b0c17a3a1feb03df Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 22 Aug 2023 14:15:46 +0200 Subject: [PATCH] [Validator] Un-deprecate passing an annotation reader to AnnotationLoader --- UPGRADE-6.4.md | 1 - src/Symfony/Component/Validator/CHANGELOG.md | 1 - .../Mapping/Loader/AnnotationLoader.php | 4 --- .../Validator/Tests/Constraints/WhenTest.php | 2 -- ...otationLoaderWithHybridAnnotationsTest.php | 26 +------------------ ...otationLoaderWithLegacyAnnotationsTest.php | 14 +--------- ...LoaderTest.php => AttributeLoaderTest.php} | 5 ++-- 7 files changed, 5 insertions(+), 48 deletions(-) rename src/Symfony/Component/Validator/Tests/Mapping/Loader/{AnnotationLoaderTest.php => AttributeLoaderTest.php} (98%) diff --git a/UPGRADE-6.4.md b/UPGRADE-6.4.md index ceeca2c9814db..b82a36276129c 100644 --- a/UPGRADE-6.4.md +++ b/UPGRADE-6.4.md @@ -157,7 +157,6 @@ Validator --------- * Deprecate Doctrine annotations support in favor of native attributes - * Deprecate passing an annotation reader to the constructor signature of `AnnotationLoader` * Deprecate `ValidatorBuilder::setDoctrineAnnotationReader()` * Deprecate `ValidatorBuilder::addDefaultDoctrineAnnotationReader()` * Deprecate `ValidatorBuilder::enableAnnotationMapping()`, use `ValidatorBuilder::enableAttributeMapping()` instead diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index 3f1883b481194..183267cf26287 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -7,7 +7,6 @@ CHANGELOG * Allow single integer for the `versions` option of the `Uuid` constraint * Allow single constraint to be passed to the `constraints` option of the `When` constraint * Deprecate Doctrine annotations support in favor of native attributes - * Deprecate passing an annotation reader to the constructor signature of `AnnotationLoader` * Deprecate `ValidatorBuilder::setDoctrineAnnotationReader()` * Deprecate `ValidatorBuilder::addDefaultDoctrineAnnotationReader()` * Add `number`, `finite-number` and `finite-float` types to `Type` constraint diff --git a/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php index 4c801103f97a3..910ff6ab39443 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php @@ -38,10 +38,6 @@ class AnnotationLoader implements LoaderInterface public function __construct(Reader $reader = null) { - if ($reader) { - 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__); - } - $this->reader = $reader; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/WhenTest.php b/src/Symfony/Component/Validator/Tests/Constraints/WhenTest.php index 8bf2a64cded0b..7e11f0f683746 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/WhenTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/WhenTest.php @@ -51,8 +51,6 @@ public function testNonConstraintsAreRejected() */ public function testAnnotations() { - $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.'); - $loader = new AnnotationLoader(new AnnotationReader()); $metadata = new ClassMetadata(WhenTestWithAnnotations::class); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderWithHybridAnnotationsTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderWithHybridAnnotationsTest.php index 2e34d7d6ea6de..7010adeecb44f 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderWithHybridAnnotationsTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderWithHybridAnnotationsTest.php @@ -18,58 +18,34 @@ /** * @group legacy */ -class AnnotationLoaderWithHybridAnnotationsTest extends AnnotationLoaderTest +class AnnotationLoaderWithHybridAnnotationsTest extends AttributeLoaderTest { use ExpectDeprecationTrait; public function testLoadClassMetadataReturnsTrueIfSuccessful() { - $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.'); $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.'); $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.'); parent::testLoadClassMetadataReturnsTrueIfSuccessful(); } - public function testLoadClassMetadataReturnsFalseIfNotSuccessful() - { - $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.'); - - parent::testLoadClassMetadataReturnsFalseIfNotSuccessful(); - } - public function testLoadClassMetadata() { - $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.'); $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.'); $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.'); parent::testLoadClassMetadata(); } - public function testLoadParentClassMetadata() - { - $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.'); - - parent::testLoadParentClassMetadata(); - } - public function testLoadClassMetadataAndMerge() { - $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.'); $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.'); $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.'); parent::testLoadClassMetadataAndMerge(); } - public function testLoadGroupSequenceProviderAnnotation() - { - $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.'); - - parent::testLoadGroupSequenceProviderAnnotation(); - } - protected function createAnnotationLoader(): AnnotationLoader { return new AnnotationLoader(new AnnotationReader()); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderWithLegacyAnnotationsTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderWithLegacyAnnotationsTest.php index 821fce12b414c..86d6d8b21dc95 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderWithLegacyAnnotationsTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderWithLegacyAnnotationsTest.php @@ -18,13 +18,12 @@ /** * @group legacy */ -class AnnotationLoaderWithLegacyAnnotationsTest extends AnnotationLoaderTest +class AnnotationLoaderWithLegacyAnnotationsTest extends AttributeLoaderTest { use ExpectDeprecationTrait; public function testLoadClassMetadataReturnsTrueIfSuccessful() { - $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.'); $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.'); $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.'); $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() parent::testLoadClassMetadataReturnsTrueIfSuccessful(); } - public function testLoadClassMetadataReturnsFalseIfNotSuccessful() - { - $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.'); - - parent::testLoadClassMetadataReturnsFalseIfNotSuccessful(); - } - public function testLoadClassMetadata() { - $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.'); $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.'); $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.'); $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.'); @@ -63,7 +54,6 @@ public function testLoadClassMetadata() public function testLoadParentClassMetadata() { - $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.'); $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.'); parent::testLoadParentClassMetadata(); @@ -71,7 +61,6 @@ public function testLoadParentClassMetadata() public function testLoadClassMetadataAndMerge() { - $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.'); $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.'); $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.'); $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() public function testLoadGroupSequenceProviderAnnotation() { - $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.'); $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.'); parent::testLoadGroupSequenceProviderAnnotation(); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AttributeLoaderTest.php similarity index 98% rename from src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php rename to src/Symfony/Component/Validator/Tests/Mapping/Loader/AttributeLoaderTest.php index 474064274bb37..c8975dbd29383 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AttributeLoaderTest.php @@ -30,9 +30,10 @@ use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; +use Symfony\Component\Validator\Mapping\Loader\AttributeLoader; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; -class AnnotationLoaderTest extends TestCase +class AttributeLoaderTest extends TestCase { public function testLoadClassMetadataReturnsTrueIfSuccessful() { @@ -212,7 +213,7 @@ public function testLoadGroupSequenceProviderAnnotation() protected function createAnnotationLoader(): AnnotationLoader { - return new AnnotationLoader(); + return new AttributeLoader(); } protected function getFixtureNamespace(): string pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy