From 67013e28bca95f4cb40fcab3f622273e959b1fca Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 24 Jul 2023 12:45:07 +0200 Subject: [PATCH] [Serializer] Remove Doctrine annotations support --- UPGRADE-7.0.md | 2 + .../Serializer/Annotation/Context.php | 6 - .../Annotation/DiscriminatorMap.php | 6 - .../Serializer/Annotation/Groups.php | 6 - .../Serializer/Annotation/Ignore.php | 5 - .../Serializer/Annotation/MaxDepth.php | 6 - .../Serializer/Annotation/SerializedName.php | 6 - .../Serializer/Annotation/SerializedPath.php | 6 - src/Symfony/Component/Serializer/CHANGELOG.md | 2 + .../Mapping/Loader/AnnotationLoader.php | 68 ------- .../Fixtures/Annotations/AbstractDummy.php | 31 ---- .../Annotations/AbstractDummyFirstChild.php | 39 ---- .../Annotations/AbstractDummySecondChild.php | 39 ---- .../Annotations/AbstractDummyThirdChild.php | 16 -- .../Annotations/BadMethodContextDummy.php | 28 --- .../Fixtures/Annotations/ContextDummy.php | 50 ------ .../Annotations/ContextDummyParent.php | 30 ---- .../ContextDummyPromotedProperties.php | 53 ------ .../Fixtures/Annotations/Entity45016.php | 26 --- .../Tests/Fixtures/Annotations/GroupDummy.php | 97 ---------- .../Annotations/GroupDummyInterface.php | 25 --- .../Fixtures/Annotations/GroupDummyParent.php | 49 ----- .../Fixtures/Annotations/IgnoreDummy.php | 35 ---- .../IgnoreDummyAdditionalGetter.php | 27 --- ...ditionalGetterWithoutIgnoreAnnotations.php | 22 --- .../Fixtures/Annotations/MaxDepthDummy.php | 50 ------ .../Annotations/SerializedNameDummy.php | 47 ----- .../Annotations/SerializedPathDummy.php | 35 ---- .../SerializedPathInConstructorDummy.php | 25 --- ...rTestCase.php => AnnotationLoaderTest.php} | 91 ++++++---- .../AnnotationLoaderWithAttributesTest.php | 39 ---- ...ationLoaderWithDoctrineAnnotationsTest.php | 170 ------------------ .../Component/Serializer/composer.json | 2 - 33 files changed, 57 insertions(+), 1082 deletions(-) delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummy.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyFirstChild.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummySecondChild.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyThirdChild.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/BadMethodContextDummy.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummy.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummyParent.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummyPromotedProperties.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/Entity45016.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummy.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyInterface.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyParent.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummy.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummyAdditionalGetter.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummyAdditionalGetterWithoutIgnoreAnnotations.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/MaxDepthDummy.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedNameDummy.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedPathDummy.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedPathInConstructorDummy.php rename src/Symfony/Component/Serializer/Tests/Mapping/Loader/{AnnotationLoaderTestCase.php => AnnotationLoaderTest.php} (58%) delete mode 100644 src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php delete mode 100644 src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php diff --git a/UPGRADE-7.0.md b/UPGRADE-7.0.md index 03e377567e012..f1b2c7c687f7b 100644 --- a/UPGRADE-7.0.md +++ b/UPGRADE-7.0.md @@ -290,6 +290,8 @@ Serializer * Require explicit argument when calling `AttributeMetadata::setSerializedName()` and `ClassMetadata::setClassDiscriminatorMapping()` * Add argument `$context` to `NormalizerInterface::supportsNormalization()` and `DenormalizerInterface::supportsDenormalization()` + * Remove Doctrine annotations support in favor of native attributes + * Remove the annotation reader parameter from the constructor of `AnnotationLoader` Translation ----------- diff --git a/src/Symfony/Component/Serializer/Annotation/Context.php b/src/Symfony/Component/Serializer/Annotation/Context.php index e3878c7be5992..6995f24de2b69 100644 --- a/src/Symfony/Component/Serializer/Annotation/Context.php +++ b/src/Symfony/Component/Serializer/Annotation/Context.php @@ -14,12 +14,6 @@ use Symfony\Component\Serializer\Exception\InvalidArgumentException; /** - * Annotation class for @Context(). - * - * @Annotation - * @NamedArgumentConstructor - * @Target({"PROPERTY", "METHOD"}) - * * @author Maxime Steinhausser */ #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] diff --git a/src/Symfony/Component/Serializer/Annotation/DiscriminatorMap.php b/src/Symfony/Component/Serializer/Annotation/DiscriminatorMap.php index 8e9ebb830250a..71aeeeee16b73 100644 --- a/src/Symfony/Component/Serializer/Annotation/DiscriminatorMap.php +++ b/src/Symfony/Component/Serializer/Annotation/DiscriminatorMap.php @@ -14,12 +14,6 @@ use Symfony\Component\Serializer\Exception\InvalidArgumentException; /** - * Annotation class for @DiscriminatorMap(). - * - * @Annotation - * @NamedArgumentConstructor - * @Target({"CLASS"}) - * * @author Samuel Roze */ #[\Attribute(\Attribute::TARGET_CLASS)] diff --git a/src/Symfony/Component/Serializer/Annotation/Groups.php b/src/Symfony/Component/Serializer/Annotation/Groups.php index 5b16f567c3547..b9763d4c2f446 100644 --- a/src/Symfony/Component/Serializer/Annotation/Groups.php +++ b/src/Symfony/Component/Serializer/Annotation/Groups.php @@ -14,12 +14,6 @@ use Symfony\Component\Serializer\Exception\InvalidArgumentException; /** - * Annotation class for @Groups(). - * - * @Annotation - * @NamedArgumentConstructor - * @Target({"PROPERTY", "METHOD"}) - * * @author Kévin Dunglas */ #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)] diff --git a/src/Symfony/Component/Serializer/Annotation/Ignore.php b/src/Symfony/Component/Serializer/Annotation/Ignore.php index b09e7007a4a4d..3e691eb7b3030 100644 --- a/src/Symfony/Component/Serializer/Annotation/Ignore.php +++ b/src/Symfony/Component/Serializer/Annotation/Ignore.php @@ -12,11 +12,6 @@ namespace Symfony\Component\Serializer\Annotation; /** - * Annotation class for @Ignore(). - * - * @Annotation - * @Target({"PROPERTY", "METHOD"}) - * * @author Kévin Dunglas */ #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)] diff --git a/src/Symfony/Component/Serializer/Annotation/MaxDepth.php b/src/Symfony/Component/Serializer/Annotation/MaxDepth.php index 4fe44901020dc..80b1d35429bfa 100644 --- a/src/Symfony/Component/Serializer/Annotation/MaxDepth.php +++ b/src/Symfony/Component/Serializer/Annotation/MaxDepth.php @@ -14,12 +14,6 @@ use Symfony\Component\Serializer\Exception\InvalidArgumentException; /** - * Annotation class for @MaxDepth(). - * - * @Annotation - * @NamedArgumentConstructor - * @Target({"PROPERTY", "METHOD"}) - * * @author Kévin Dunglas */ #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)] diff --git a/src/Symfony/Component/Serializer/Annotation/SerializedName.php b/src/Symfony/Component/Serializer/Annotation/SerializedName.php index 74df79cd27ea7..12d742388e3e7 100644 --- a/src/Symfony/Component/Serializer/Annotation/SerializedName.php +++ b/src/Symfony/Component/Serializer/Annotation/SerializedName.php @@ -14,12 +14,6 @@ use Symfony\Component\Serializer\Exception\InvalidArgumentException; /** - * Annotation class for @SerializedName(). - * - * @Annotation - * @NamedArgumentConstructor - * @Target({"PROPERTY", "METHOD"}) - * * @author Fabien Bourigault */ #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)] diff --git a/src/Symfony/Component/Serializer/Annotation/SerializedPath.php b/src/Symfony/Component/Serializer/Annotation/SerializedPath.php index 88ee8e47d76b1..d7aa8c0d491b7 100644 --- a/src/Symfony/Component/Serializer/Annotation/SerializedPath.php +++ b/src/Symfony/Component/Serializer/Annotation/SerializedPath.php @@ -16,12 +16,6 @@ use Symfony\Component\Serializer\Exception\InvalidArgumentException; /** - * Annotation class for @SerializedPath(). - * - * @Annotation - * @NamedArgumentConstructor - * @Target({"PROPERTY", "METHOD"}) - * * @author Tobias Bönner */ #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)] diff --git a/src/Symfony/Component/Serializer/CHANGELOG.md b/src/Symfony/Component/Serializer/CHANGELOG.md index 7c0c68f4b17f5..917c405426eb5 100644 --- a/src/Symfony/Component/Serializer/CHANGELOG.md +++ b/src/Symfony/Component/Serializer/CHANGELOG.md @@ -12,6 +12,8 @@ CHANGELOG * Remove `CacheableSupportsMethodInterface`, use `NormalizerInterface` and `DenormalizerInterface` instead * Require explicit argument when calling `AttributeMetadata::setSerializedName()` and `ClassMetadata::setClassDiscriminatorMapping()` * Add argument `$context` to `NormalizerInterface::supportsNormalization()` and `DenormalizerInterface::supportsDenormalization()` + * Remove Doctrine annotations support in favor of native attributes + * Remove the annotation reader parameter from the constructor of `AnnotationLoader` 6.4 --- diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php b/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php index 94d0f45dcb1f7..2ef9c553d5689 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Serializer\Mapping\Loader; -use Doctrine\Common\Annotations\Reader; use Symfony\Component\Serializer\Annotation\Context; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\Groups; @@ -43,14 +42,6 @@ class AnnotationLoader implements LoaderInterface Context::class, ]; - public function __construct( - private readonly ?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__); - } - } - public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool { $reflectionClass = $classMetadata->getReflectionClass(); @@ -187,20 +178,6 @@ public function loadAnnotations(\ReflectionMethod|\ReflectionClass|\ReflectionPr } } } - - if (null === $this->reader) { - return; - } - - if ($reflector instanceof \ReflectionClass) { - yield from $this->getClassAnnotations($reflector); - } - if ($reflector instanceof \ReflectionMethod) { - yield from $this->getMethodAnnotations($reflector); - } - if ($reflector instanceof \ReflectionProperty) { - yield from $this->getPropertyAnnotations($reflector); - } } private function setAttributeContextsForGroups(Context $annotation, AttributeMetadataInterface $attributeMetadata): void @@ -229,49 +206,4 @@ private function isKnownAttribute(string $attributeName): bool return false; } - - /** - * @return object[] - */ - private function getClassAnnotations(\ReflectionClass $reflector): array - { - if ($annotations = array_filter( - $this->reader->getClassAnnotations($reflector), - fn (object $annotation): bool => $this->isKnownAttribute($annotation::class), - )) { - trigger_deprecation('symfony/serializer', '6.4', 'Class "%s" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.', $reflector->getName()); - } - - return $annotations; - } - - /** - * @return object[] - */ - private function getMethodAnnotations(\ReflectionMethod $reflector): array - { - if ($annotations = array_filter( - $this->reader->getMethodAnnotations($reflector), - fn (object $annotation): bool => $this->isKnownAttribute($annotation::class), - )) { - trigger_deprecation('symfony/serializer', '6.4', 'Method "%s::%s()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.', $reflector->getDeclaringClass()->getName(), $reflector->getName()); - } - - return $annotations; - } - - /** - * @return object[] - */ - private function getPropertyAnnotations(\ReflectionProperty $reflector): array - { - if ($annotations = array_filter( - $this->reader->getPropertyAnnotations($reflector), - fn (object $annotation): bool => $this->isKnownAttribute($annotation::class), - )) { - trigger_deprecation('symfony/serializer', '6.4', 'Property "%s::$%s" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.', $reflector->getDeclaringClass()->getName(), $reflector->getName()); - } - - return $annotations; - } } diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummy.php deleted file mode 100644 index fad842b0d4693..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummy.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\DiscriminatorMap; - -/** - * @DiscriminatorMap(typeProperty="type", mapping={ - * "first"="Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummyFirstChild", - * "second"="Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummySecondChild", - * "third"="Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummyThirdChild", - * }) - */ -abstract class AbstractDummy -{ - public $foo; - - public function __construct($foo = null) - { - $this->foo = $foo; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyFirstChild.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyFirstChild.php deleted file mode 100644 index 81f15aaf0d391..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyFirstChild.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Tests\Fixtures\DummyFirstChildQuux; - -class AbstractDummyFirstChild extends AbstractDummy -{ - public $bar; - - /** @var DummyFirstChildQuux|null */ - public $quux; - - public function __construct($foo = null, $bar = null) - { - parent::__construct($foo); - - $this->bar = $bar; - } - - public function getQuux(): ?DummyFirstChildQuux - { - return $this->quux; - } - - public function setQuux(DummyFirstChildQuux $quux): void - { - $this->quux = $quux; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummySecondChild.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummySecondChild.php deleted file mode 100644 index 4d113066bbe32..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummySecondChild.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Tests\Fixtures\DummySecondChildQuux; - -class AbstractDummySecondChild extends AbstractDummy -{ - public $baz; - - /** @var DummySecondChildQuux|null */ - public $quux; - - public function __construct($foo = null, $baz = null) - { - parent::__construct($foo); - - $this->baz = $baz; - } - - public function getQuux(): ?DummySecondChildQuux - { - return $this->quux; - } - - public function setQuux(DummySecondChildQuux $quux): void - { - $this->quux = $quux; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyThirdChild.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyThirdChild.php deleted file mode 100644 index 2df26c3320f4c..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyThirdChild.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -final class AbstractDummyThirdChild extends AbstractDummyFirstChild -{ -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/BadMethodContextDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/BadMethodContextDummy.php deleted file mode 100644 index 77b3884de5cb1..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/BadMethodContextDummy.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\Context; - -/** - * @author Maxime Steinhausser - */ -class BadMethodContextDummy extends ContextDummyParent -{ - /** - * @Context({ "foo" = "bar" }) - */ - public function badMethod() - { - return 'bad_method'; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummy.php deleted file mode 100644 index 804df290f0295..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummy.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\Context; - -/** - * @author Maxime Steinhausser - */ -class ContextDummy extends ContextDummyParent -{ - /** - * @Context({ "foo" = "value", "bar" = "value", "nested" = { - * "nested_key" = "nested_value", - * }, "array": { "first", "second" } }) - * @Context({ "bar" = "value_for_group_a" }, groups = "a") - */ - public $foo; - - /** - * @Context( - * normalizationContext = { "format" = "d/m/Y" }, - * denormalizationContext = { "format" = "m-d-Y H:i" }, - * groups = {"a", "b"} - * ) - */ - public $bar; - - /** - * @Context(normalizationContext={ "prop" = "dummy_value" }) - */ - public $overriddenParentProperty; - - /** - * @Context({ "method" = "method_with_context" }) - */ - public function getMethodWithContext() - { - return 'method_with_context'; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummyParent.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummyParent.php deleted file mode 100644 index b7b286c372fa3..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummyParent.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\Context; - -/** - * @author Maxime Steinhausser - */ -class ContextDummyParent -{ - /** - * @Context(normalizationContext={ "prop" = "dummy_parent_value" }) - */ - public $parentProperty; - - /** - * @Context(normalizationContext={ "prop" = "dummy_parent_value" }) - */ - public $overriddenParentProperty; -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummyPromotedProperties.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummyPromotedProperties.php deleted file mode 100644 index 5aa108d1ec8b4..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/ContextDummyPromotedProperties.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\Context; - -/** - * @author Maxime Steinhausser - */ -class ContextDummyPromotedProperties extends ContextDummyParent -{ - public function __construct( - /** - * @Context({ "foo" = "value", "bar" = "value", "nested" = { - * "nested_key" = "nested_value", - * }, "array": { "first", "second" } }) - * @Context({ "bar" = "value_for_group_a" }, groups = "a") - */ - public $foo, - - /** - * @Context( - * normalizationContext = { "format" = "d/m/Y" }, - * denormalizationContext = { "format" = "m-d-Y H:i" }, - * groups = {"a", "b"} - * ) - */ - public $bar, - - /** - * @Context(normalizationContext={ "prop" = "dummy_value" }) - */ - public $overriddenParentProperty, - ) { - } - - /** - * @Context({ "method" = "method_with_context" }) - */ - public function getMethodWithContext() - { - return 'method_with_context'; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/Entity45016.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/Entity45016.php deleted file mode 100644 index a896d9b766c59..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/Entity45016.php +++ /dev/null @@ -1,26 +0,0 @@ -id; - } - - /** - * @Ignore() - */ - public function badIgnore(): bool - { - return true; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummy.php deleted file mode 100644 index 92935f49095ae..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummy.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\Groups; -use Symfony\Component\Serializer\Tests\Fixtures\ChildOfGroupsAnnotationDummy; -use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummyInterface; - -/** - * @author Kévin Dunglas - */ -class GroupDummy extends GroupDummyParent implements GroupDummyInterface -{ - /** - * @Groups({"a"}) - */ - private $foo; - /** - * @Groups({"b", "c", "name_converter"}) - */ - protected $bar; - /** - * @ChildOfGroupsAnnotationDummy - */ - protected $quux; - - private $fooBar; - private $symfony; - - /** - * @Groups({"b"}) - */ - public function setBar($bar) - { - $this->bar = $bar; - } - - /** - * @Groups({"c"}) - */ - public function getBar() - { - return $this->bar; - } - - public function setFoo($foo) - { - $this->foo = $foo; - } - - public function getFoo() - { - return $this->foo; - } - - public function setFooBar($fooBar) - { - $this->fooBar = $fooBar; - } - - /** - * @Groups({"a", "b", "name_converter"}) - */ - public function isFooBar() - { - return $this->fooBar; - } - - public function setSymfony($symfony) - { - $this->symfony = $symfony; - } - - public function getSymfony() - { - return $this->symfony; - } - - public function getQuux() - { - return $this->quux; - } - - public function setQuux($quux): void - { - $this->quux = $quux; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyInterface.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyInterface.php deleted file mode 100644 index c9a736bfa0b2e..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\Groups; - -/** - * @author Kévin Dunglas - */ -interface GroupDummyInterface -{ - /** - * @Groups({"a", "name_converter"}) - */ - public function getSymfony(); -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyParent.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyParent.php deleted file mode 100644 index 77d539b9400c8..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyParent.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\Groups; - -/** - * @author Kévin Dunglas - */ -class GroupDummyParent -{ - /** - * @Groups({"a"}) - */ - private $kevin; - private $coopTilleuls; - - public function setKevin($kevin) - { - $this->kevin = $kevin; - } - - public function getKevin() - { - return $this->kevin; - } - - public function setCoopTilleuls($coopTilleuls) - { - $this->coopTilleuls = $coopTilleuls; - } - - /** - * @Groups({"a", "b"}) - */ - public function getCoopTilleuls() - { - return $this->coopTilleuls; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummy.php deleted file mode 100644 index 900447c581499..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummy.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\Ignore; - -/** - * @author Kévin Dunglas - */ -class IgnoreDummy -{ - public $notIgnored; - /** - * @Ignore() - */ - public $ignored1; - private $ignored2; - - /** - * @Ignore() - */ - public function getIgnored2() - { - return $this->ignored2; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummyAdditionalGetter.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummyAdditionalGetter.php deleted file mode 100644 index 326a9cd07589e..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummyAdditionalGetter.php +++ /dev/null @@ -1,27 +0,0 @@ -myValue; - } - - public function getExtraValue(string $parameter) - { - return $parameter; - } - - public function setExtraValue2(string $parameter) - { - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummyAdditionalGetterWithoutIgnoreAnnotations.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummyAdditionalGetterWithoutIgnoreAnnotations.php deleted file mode 100644 index 2b717c93a9752..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummyAdditionalGetterWithoutIgnoreAnnotations.php +++ /dev/null @@ -1,22 +0,0 @@ -myValue; - } - - public function getExtraValue(string $parameter) - { - return $parameter; - } - - public function setExtraValue2(string $parameter) - { - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/MaxDepthDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/MaxDepthDummy.php deleted file mode 100644 index 12be2db03b97f..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/MaxDepthDummy.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\MaxDepth; - -/** - * @author Kévin Dunglas - */ -class MaxDepthDummy -{ - /** - * @MaxDepth(2) - */ - public $foo; - - public $bar; - - /** - * @var self - */ - public $child; - - /** - * @MaxDepth(3) - */ - public function getBar() - { - return $this->bar; - } - - public function getChild() - { - return $this->child; - } - - public function getFoo() - { - return $this->foo; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedNameDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedNameDummy.php deleted file mode 100644 index 1eaa579b466fa..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedNameDummy.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\SerializedName; - -/** - * @author Fabien Bourigault - */ -class SerializedNameDummy -{ - /** - * @SerializedName("baz") - */ - public $foo; - - public $bar; - - public $quux; - - /** - * @var self - */ - public $child; - - /** - * @SerializedName("qux") - */ - public function getBar() - { - return $this->bar; - } - - public function getChild() - { - return $this->child; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedPathDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedPathDummy.php deleted file mode 100644 index cd50b81c3372e..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedPathDummy.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\SerializedPath; - -/** - * @author Tobias Bönner - */ -class SerializedPathDummy -{ - /** - * @SerializedPath("[one][two]") - */ - public $three; - - public $seven; - - /** - * @SerializedPath("[three][four]") - */ - public function getSeven() - { - return $this->seven; - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedPathInConstructorDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedPathInConstructorDummy.php deleted file mode 100644 index a6d5109086899..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedPathInConstructorDummy.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; - -use Symfony\Component\Serializer\Annotation\SerializedPath; - -class SerializedPathInConstructorDummy -{ - public function __construct( - /** - * @SerializedPath("[one][two]") - */ - public $three, - ) { - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTestCase.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php similarity index 58% rename from src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTestCase.php rename to src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php index 40d5e3cfee5de..ee34e0b904563 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTestCase.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php @@ -19,21 +19,39 @@ use Symfony\Component\Serializer\Mapping\ClassMetadata; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\AbstractDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\AbstractDummyFirstChild; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\AbstractDummySecondChild; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\AbstractDummyThirdChild; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\BadAttributeDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\BadMethodContextDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\ContextDummyParent; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\ContextDummyPromotedProperties; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\Entity45016; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\GroupDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\GroupDummyParent; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\IgnoreDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\IgnoreDummyAdditionalGetter; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\IgnoreDummyAdditionalGetterWithoutIgnoreAnnotations; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\MaxDepthDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\SerializedNameDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\SerializedPathDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Attributes\SerializedPathInConstructorDummy; use Symfony\Component\Serializer\Tests\Mapping\Loader\Features\ContextMappingTestTrait; use Symfony\Component\Serializer\Tests\Mapping\TestClassMetadataFactory; /** * @author Kévin Dunglas */ -abstract class AnnotationLoaderTestCase extends TestCase +class AnnotationLoaderTest extends TestCase { use ContextMappingTestTrait; - protected AnnotationLoader $loader; + private AnnotationLoader $loader; protected function setUp(): void { - $this->loader = $this->createLoader(); + $this->loader = new AnnotationLoader(); } public function testInterface() @@ -43,28 +61,28 @@ public function testInterface() public function testLoadClassMetadataReturnsTrueIfSuccessful() { - $classMetadata = new ClassMetadata($this->getNamespace().'\GroupDummy'); + $classMetadata = new ClassMetadata(GroupDummy::class); $this->assertTrue($this->loader->loadClassMetadata($classMetadata)); } public function testLoadGroups() { - $classMetadata = new ClassMetadata($this->getNamespace().'\GroupDummy'); + $classMetadata = new ClassMetadata(GroupDummy::class); $this->loader->loadClassMetadata($classMetadata); - $this->assertEquals(TestClassMetadataFactory::createClassMetadata($this->getNamespace()), $classMetadata); + $this->assertEquals(TestClassMetadataFactory::createClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\Attributes'), $classMetadata); } public function testLoadDiscriminatorMap() { - $classMetadata = new ClassMetadata($this->getNamespace().'\AbstractDummy'); + $classMetadata = new ClassMetadata(AbstractDummy::class); $this->loader->loadClassMetadata($classMetadata); - $expected = new ClassMetadata($this->getNamespace().'\AbstractDummy', new ClassDiscriminatorMapping('type', [ - 'first' => $this->getNamespace().'\AbstractDummyFirstChild', - 'second' => $this->getNamespace().'\AbstractDummySecondChild', - 'third' => $this->getNamespace().'\AbstractDummyThirdChild', + $expected = new ClassMetadata(AbstractDummy::class, new ClassDiscriminatorMapping('type', [ + 'first' => AbstractDummyFirstChild::class, + 'second' => AbstractDummySecondChild::class, + 'third' => AbstractDummyThirdChild::class, ])); $expected->addAttributeMetadata(new AttributeMetadata('foo')); @@ -75,7 +93,7 @@ public function testLoadDiscriminatorMap() public function testLoadMaxDepth() { - $classMetadata = new ClassMetadata($this->getNamespace().'\MaxDepthDummy'); + $classMetadata = new ClassMetadata(MaxDepthDummy::class); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); @@ -85,7 +103,7 @@ public function testLoadMaxDepth() public function testLoadSerializedName() { - $classMetadata = new ClassMetadata($this->getNamespace().'\SerializedNameDummy'); + $classMetadata = new ClassMetadata(SerializedNameDummy::class); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); @@ -95,7 +113,7 @@ public function testLoadSerializedName() public function testLoadSerializedPath() { - $classMetadata = new ClassMetadata($this->getNamespace().'\SerializedPathDummy'); + $classMetadata = new ClassMetadata(SerializedPathDummy::class); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); @@ -105,7 +123,7 @@ public function testLoadSerializedPath() public function testLoadSerializedPathInConstructor() { - $classMetadata = new ClassMetadata($this->getNamespace().'\SerializedPathInConstructorDummy'); + $classMetadata = new ClassMetadata(SerializedPathInConstructorDummy::class); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); @@ -114,20 +132,20 @@ public function testLoadSerializedPathInConstructor() public function testLoadClassMetadataAndMerge() { - $classMetadata = new ClassMetadata($this->getNamespace().'\GroupDummy'); - $parentClassMetadata = new ClassMetadata($this->getNamespace().'\GroupDummyParent'); + $classMetadata = new ClassMetadata(GroupDummy::class); + $parentClassMetadata = new ClassMetadata(GroupDummyParent::class); $this->loader->loadClassMetadata($parentClassMetadata); $classMetadata->merge($parentClassMetadata); $this->loader->loadClassMetadata($classMetadata); - $this->assertEquals(TestClassMetadataFactory::createClassMetadata($this->getNamespace(), true), $classMetadata); + $this->assertEquals(TestClassMetadataFactory::createClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\Attributes', true), $classMetadata); } public function testLoadIgnore() { - $classMetadata = new ClassMetadata($this->getNamespace().'\IgnoreDummy'); + $classMetadata = new ClassMetadata(IgnoreDummy::class); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); @@ -135,38 +153,29 @@ public function testLoadIgnore() $this->assertTrue($attributesMetadata['ignored2']->isIgnored()); } - public function testLoadContexts() - { - $this->assertLoadedContexts($this->getNamespace().'\ContextDummy', $this->getNamespace().'\ContextDummyParent'); - } - public function testLoadContextsPropertiesPromoted() { - $this->assertLoadedContexts($this->getNamespace().'\ContextDummyPromotedProperties', $this->getNamespace().'\ContextDummyParent'); + $this->assertLoadedContexts(ContextDummyPromotedProperties::class, ContextDummyParent::class); } public function testThrowsOnContextOnInvalidMethod() { - $class = $this->getNamespace().'\BadMethodContextDummy'; - $this->expectException(MappingException::class); - $this->expectExceptionMessage(sprintf('Context on "%s::badMethod()" cannot be added', $class)); + $this->expectExceptionMessage(sprintf('Context on "%s::badMethod()" cannot be added', BadMethodContextDummy::class)); $loader = $this->getLoaderForContextMapping(); - $classMetadata = new ClassMetadata($class); + $classMetadata = new ClassMetadata(BadMethodContextDummy::class); $loader->loadClassMetadata($classMetadata); } public function testCanHandleUnrelatedIgnoredMethods() { - $class = $this->getNamespace().'\Entity45016'; - $this->expectException(MappingException::class); - $this->expectExceptionMessage(sprintf('Ignore on "%s::badIgnore()" cannot be added', $class)); + $this->expectExceptionMessage(sprintf('Ignore on "%s::badIgnore()" cannot be added', Entity45016::class)); - $metadata = new ClassMetadata($class); + $metadata = new ClassMetadata(Entity45016::class); $loader = $this->getLoaderForContextMapping(); $loader->loadClassMetadata($metadata); @@ -174,7 +183,7 @@ public function testCanHandleUnrelatedIgnoredMethods() public function testIgnoreGetterWithRequiredParameterIfIgnoreAnnotationIsUsed() { - $classMetadata = new ClassMetadata($this->getNamespace().'\IgnoreDummyAdditionalGetter'); + $classMetadata = new ClassMetadata(IgnoreDummyAdditionalGetter::class); $this->getLoaderForContextMapping()->loadClassMetadata($classMetadata); $attributes = $classMetadata->getAttributesMetadata(); @@ -184,7 +193,7 @@ public function testIgnoreGetterWithRequiredParameterIfIgnoreAnnotationIsUsed() public function testIgnoreGetterWithRequiredParameterIfIgnoreAnnotationIsNotUsed() { - $classMetadata = new ClassMetadata($this->getNamespace().'\IgnoreDummyAdditionalGetterWithoutIgnoreAnnotations'); + $classMetadata = new ClassMetadata(IgnoreDummyAdditionalGetterWithoutIgnoreAnnotations::class); $this->getLoaderForContextMapping()->loadClassMetadata($classMetadata); $attributes = $classMetadata->getAttributesMetadata(); @@ -192,11 +201,17 @@ public function testIgnoreGetterWithRequiredParameterIfIgnoreAnnotationIsNotUsed self::assertArrayHasKey('extraValue2', $attributes); } - abstract protected function createLoader(): AnnotationLoader; + public function testLoadWithInvalidAttribute() + { + $this->expectException(MappingException::class); + $this->expectExceptionMessage('Could not instantiate attribute "Symfony\Component\Serializer\Annotation\Groups" on "Symfony\Component\Serializer\Tests\Fixtures\Attributes\BadAttributeDummy::myMethod()".'); + + $classMetadata = new ClassMetadata(BadAttributeDummy::class); - abstract protected function getNamespace(): string; + $this->loader->loadClassMetadata($classMetadata); + } - protected function getLoaderForContextMapping(): LoaderInterface + protected function getLoaderForContextMapping(): AnnotationLoader { return $this->loader; } diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php deleted file mode 100644 index 89e94b66302b8..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Mapping\Loader; - -use Symfony\Component\Serializer\Exception\MappingException; -use Symfony\Component\Serializer\Mapping\ClassMetadata; -use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; - -class AnnotationLoaderWithAttributesTest extends AnnotationLoaderTestCase -{ - protected function createLoader(): AnnotationLoader - { - return new AnnotationLoader(); - } - - protected function getNamespace(): string - { - return 'Symfony\Component\Serializer\Tests\Fixtures\Attributes'; - } - - public function testLoadWithInvalidAttribute() - { - $this->expectException(MappingException::class); - $this->expectExceptionMessage('Could not instantiate attribute "Symfony\Component\Serializer\Annotation\Groups" on "Symfony\Component\Serializer\Tests\Fixtures\Attributes\BadAttributeDummy::myMethod()".'); - - $classMetadata = new ClassMetadata($this->getNamespace().'\BadAttributeDummy'); - - $this->loader->loadClassMetadata($classMetadata); - } -} diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php deleted file mode 100644 index 348f8c71c2d6b..0000000000000 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php +++ /dev/null @@ -1,170 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Serializer\Tests\Mapping\Loader; - -use Doctrine\Common\Annotations\AnnotationReader; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; -use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; - -/** - * @group legacy - */ -class AnnotationLoaderWithDoctrineAnnotationsTest extends AnnotationLoaderTestCase -{ - use ExpectDeprecationTrait; - - protected function setUp(): void - { - $this->expectDeprecation('Since symfony/validator 6.4: Passing a "Doctrine\Common\Annotations\AnnotationReader" instance as argument 1 to "Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader::__construct()" is deprecated, pass null or omit the parameter instead.'); - - parent::setUp(); - } - - public function testLoadClassMetadataReturnsTrueIfSuccessful() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::$foo" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::$bar" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::$quux" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::setBar()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::getBar()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::isFooBar()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testLoadClassMetadataReturnsTrueIfSuccessful(); - } - - public function testLoadGroups() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::$foo" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::$bar" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::$quux" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::setBar()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::getBar()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::isFooBar()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testLoadGroups(); - } - - public function testLoadDiscriminatorMap() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Class "Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummy" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testLoadDiscriminatorMap(); - } - - public function testLoadMaxDepth() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\MaxDepthDummy::$foo" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\MaxDepthDummy::getBar()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testLoadMaxDepth(); - } - - public function testLoadSerializedName() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy::$foo" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy::getBar()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testLoadSerializedName(); - } - - public function testLoadSerializedPath() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedPathDummy::$three" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedPathDummy::getSeven()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testLoadSerializedPath(); - } - - public function testLoadSerializedPathInConstructor() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedPathInConstructorDummy::$three" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testLoadSerializedPathInConstructor(); - } - - public function testLoadClassMetadataAndMerge() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummyParent::$kevin" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummyParent::getCoopTilleuls()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::$foo" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::$bar" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::$quux" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::setBar()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::getBar()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy::isFooBar()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testLoadClassMetadataAndMerge(); - } - - public function testLoadIgnore() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy::$ignored1" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy::getIgnored2()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testLoadIgnore(); - } - - public function testLoadContexts() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummyParent::$parentProperty" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummyParent::$overriddenParentProperty" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummy::$foo" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummy::$bar" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummy::$overriddenParentProperty" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummy::getMethodWithContext()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testLoadContexts(); - } - - public function testLoadContextsPropertiesPromoted() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummyParent::$parentProperty" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummyParent::$overriddenParentProperty" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummyPromotedProperties::$foo" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummyPromotedProperties::$bar" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Property "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummyPromotedProperties::$overriddenParentProperty" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummyPromotedProperties::getMethodWithContext()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testLoadContextsPropertiesPromoted(); - } - - public function testThrowsOnContextOnInvalidMethod() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\BadMethodContextDummy::badMethod()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testThrowsOnContextOnInvalidMethod(); - } - - public function testCanHandleUnrelatedIgnoredMethods() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\Entity45016::badIgnore()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testCanHandleUnrelatedIgnoredMethods(); - } - - public function testIgnoreGetterWithRequiredParameterIfIgnoreAnnotationIsUsed() - { - $this->expectDeprecation('Since symfony/serializer 6.4: Method "Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummyAdditionalGetter::getMyValue()" uses Doctrine Annotations to configure serialization, which is deprecated. Use PHP attributes instead.'); - - parent::testIgnoreGetterWithRequiredParameterIfIgnoreAnnotationIsUsed(); - } - - protected function createLoader(): AnnotationLoader - { - return new AnnotationLoader(new AnnotationReader()); - } - - protected function getNamespace(): string - { - return 'Symfony\Component\Serializer\Tests\Fixtures\Annotations'; - } -} diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index d7368258b96ec..3d89edb06731c 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -20,7 +20,6 @@ "symfony/polyfill-ctype": "~1.8" }, "require-dev": { - "doctrine/annotations": "^1.12|^2", "phpdocumentor/reflection-docblock": "^3.2|^4.0|^5.0", "symfony/cache": "^6.4|^7.0", "symfony/config": "^6.4|^7.0", @@ -41,7 +40,6 @@ "symfony/yaml": "^6.4|^7.0" }, "conflict": { - "doctrine/annotations": "<1.12", "phpdocumentor/reflection-docblock": "<3.2.2", "phpdocumentor/type-resolver": "<1.4.0", "symfony/dependency-injection": "<6.4", 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