diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php index ec3f949bbeb69..53d3396bdf765 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php @@ -11,12 +11,14 @@ namespace Symfony\Component\PropertyInfo\Tests\Extractor; +use Doctrine\Common\Annotations\AnnotationReader; use PHPUnit\Framework\TestCase; use Symfony\Component\PropertyInfo\Extractor\SerializerExtractor; use Symfony\Component\PropertyInfo\Tests\Fixtures\AdderRemoverDummy; use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy; use Symfony\Component\PropertyInfo\Tests\Fixtures\IgnorePropertyDummy; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; +use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader; /** @@ -28,7 +30,11 @@ class SerializerExtractorTest extends TestCase protected function setUp(): void { - $classMetadataFactory = new ClassMetadataFactory(new AttributeLoader()); + if (class_exists(AttributeLoader::class)) { + $classMetadataFactory = new ClassMetadataFactory(new AttributeLoader()); + } else { + $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); + } $this->extractor = new SerializerExtractor($classMetadataFactory); } diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php index 6c2ea073f2620..97f4c04d94a82 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php @@ -11,6 +11,7 @@ namespace Symfony\Component\PropertyInfo\Tests\Fixtures; +use Symfony\Component\Serializer\Annotation\Groups as GroupsAnnotation; use Symfony\Component\Serializer\Attribute\Groups; /** @@ -42,6 +43,7 @@ class Dummy extends ParentDummy /** * @var \DateTimeImmutable[] + * @GroupsAnnotation({"a", "b"}) */ #[Groups(['a', 'b'])] public $collection; diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/IgnorePropertyDummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/IgnorePropertyDummy.php index 9216ff801b27d..2ff38cb01e3b3 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/IgnorePropertyDummy.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/IgnorePropertyDummy.php @@ -11,6 +11,8 @@ namespace Symfony\Component\PropertyInfo\Tests\Fixtures; +use Symfony\Component\Serializer\Annotation\Groups as GroupsAnnotation; +use Symfony\Component\Serializer\Annotation\Ignore as IgnoreAnnotation; use Symfony\Component\Serializer\Attribute\Groups; use Symfony\Component\Serializer\Attribute\Ignore; @@ -19,9 +21,16 @@ */ class IgnorePropertyDummy { + /** + * @GroupsAnnotation({"a"}) + */ #[Groups(['a'])] public $visibleProperty; + /** + * @GroupsAnnotation({"a"}) + * @IgnoreAnnotation + */ #[Groups(['a']), Ignore] private $ignoredProperty; } diff --git a/src/Symfony/Component/PropertyInfo/composer.json b/src/Symfony/Component/PropertyInfo/composer.json index 26e754d2b36ae..0b880b78d126d 100644 --- a/src/Symfony/Component/PropertyInfo/composer.json +++ b/src/Symfony/Component/PropertyInfo/composer.json @@ -27,16 +27,19 @@ "symfony/string": "^5.4|^6.0|^7.0" }, "require-dev": { - "symfony/serializer": "^6.4|^7.0", + "doctrine/annotations": "^1.12|^2", + "symfony/serializer": "^5.4|^6.4|^7.0", "symfony/cache": "^5.4|^6.0|^7.0", "symfony/dependency-injection": "^5.4|^6.0|^7.0", "phpdocumentor/reflection-docblock": "^5.2", "phpstan/phpdoc-parser": "^1.0|^2.0" }, "conflict": { + "doctrine/annotations": "<1.12", "phpdocumentor/reflection-docblock": "<5.2", "phpdocumentor/type-resolver": "<1.5.1", - "symfony/dependency-injection": "<5.4" + "symfony/dependency-injection": "<5.4", + "symfony/dependency-injection": "<5.4|>=6.0,<6.4" }, "autoload": { "psr-4": { "Symfony\\Component\\PropertyInfo\\": "" },