From cfb9986203acad99aa17f4a516ed50bc9f34b2d6 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 12 Oct 2020 12:31:32 +0200 Subject: [PATCH] [Serializer] Enabled mapping configuration via attributes. --- .github/patch-types.php | 1 + .../Annotation/DiscriminatorMap.php | 20 ++++-- .../Serializer/Annotation/Groups.php | 13 ++-- .../Serializer/Annotation/Ignore.php | 1 + .../Serializer/Annotation/MaxDepth.php | 17 +++-- .../Serializer/Annotation/SerializedName.php | 17 +++-- src/Symfony/Component/Serializer/CHANGELOG.md | 1 + .../Mapping/Loader/AnnotationLoader.php | 45 ++++++++++-- .../{ => Annotations}/AbstractDummy.php | 8 +-- .../Annotations/AbstractDummyFirstChild.php | 39 ++++++++++ .../Annotations/AbstractDummySecondChild.php | 39 ++++++++++ .../Annotations/AbstractDummyThirdChild.php | 16 +++++ .../Fixtures/{ => Annotations}/GroupDummy.php | 3 +- .../Fixtures/Annotations/GroupDummyChild.php | 33 +++++++++ .../{ => Annotations}/GroupDummyParent.php | 2 +- .../{ => Annotations}/IgnoreDummy.php | 2 +- .../{ => Annotations}/MaxDepthDummy.php | 2 +- .../{ => Annotations}/SerializedNameDummy.php | 2 +- .../Fixtures/Attributes/AbstractDummy.php | 29 ++++++++ .../AbstractDummyFirstChild.php | 4 +- .../AbstractDummySecondChild.php | 4 +- .../AbstractDummyThirdChild.php | 2 +- .../Tests/Fixtures/Attributes/GroupDummy.php | 71 +++++++++++++++++++ .../{ => Attributes}/GroupDummyChild.php | 2 +- .../Fixtures/Attributes/GroupDummyParent.php | 45 ++++++++++++ .../Tests/Fixtures/Attributes/IgnoreDummy.php | 31 ++++++++ .../Fixtures/Attributes/MaxDepthDummy.php | 46 ++++++++++++ .../Attributes/SerializedNameDummy.php | 43 +++++++++++ .../Tests/Fixtures/invalid-ignore.yml | 2 +- .../Tests/Fixtures/serialization.xml | 14 ++-- .../Tests/Fixtures/serialization.yml | 14 ++-- .../Mapping/ClassDiscriminatorMappingTest.php | 6 +- .../ClassMetadataFactoryCompilerTest.php | 4 +- .../Factory/ClassMetadataFactoryTest.php | 8 +-- .../CompiledClassMetadataFactoryTest.php | 2 +- .../Mapping/Loader/AnnotationLoaderTest.php | 41 +++++------ .../AnnotationLoaderWithAttributesTest.php | 30 ++++++++ ...ationLoaderWithDoctrineAnnotationsTest.php | 28 ++++++++ .../Mapping/Loader/XmlFileLoaderTest.php | 14 ++-- .../Mapping/Loader/YamlFileLoaderTest.php | 14 ++-- .../Mapping/TestClassMetadataFactory.php | 8 +-- .../MetadataAwareNameConverterTest.php | 2 +- .../Normalizer/AbstractNormalizerTest.php | 2 +- .../AbstractObjectNormalizerTest.php | 6 +- .../Normalizer/Features/GroupsTestTrait.php | 2 +- .../Normalizer/Features/MaxDepthTestTrait.php | 2 +- .../Normalizer/GetSetMethodNormalizerTest.php | 4 +- .../Tests/Normalizer/ObjectNormalizerTest.php | 4 +- .../Normalizer/PropertyNormalizerTest.php | 6 +- .../Serializer/Tests/SerializerTest.php | 6 +- 50 files changed, 638 insertions(+), 119 deletions(-) rename src/Symfony/Component/Serializer/Tests/Fixtures/{ => Annotations}/AbstractDummy.php (58%) create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyFirstChild.php create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummySecondChild.php create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyThirdChild.php rename src/Symfony/Component/Serializer/Tests/Fixtures/{ => Annotations}/GroupDummy.php (90%) create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyChild.php rename src/Symfony/Component/Serializer/Tests/Fixtures/{ => Annotations}/GroupDummyParent.php (92%) rename src/Symfony/Component/Serializer/Tests/Fixtures/{ => Annotations}/IgnoreDummy.php (89%) rename src/Symfony/Component/Serializer/Tests/Fixtures/{ => Annotations}/MaxDepthDummy.php (91%) rename src/Symfony/Component/Serializer/Tests/Fixtures/{ => Annotations}/SerializedNameDummy.php (91%) create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummy.php rename src/Symfony/Component/Serializer/Tests/Fixtures/{ => Attributes}/AbstractDummyFirstChild.php (83%) rename src/Symfony/Component/Serializer/Tests/Fixtures/{ => Attributes}/AbstractDummySecondChild.php (83%) rename src/Symfony/Component/Serializer/Tests/Fixtures/{ => Attributes}/AbstractDummyThirdChild.php (82%) create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/GroupDummy.php rename src/Symfony/Component/Serializer/Tests/Fixtures/{ => Attributes}/GroupDummyChild.php (88%) create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/GroupDummyParent.php create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/IgnoreDummy.php create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/MaxDepthDummy.php create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/SerializedNameDummy.php create mode 100644 src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php create mode 100644 src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php diff --git a/.github/patch-types.php b/.github/patch-types.php index 3c91c7f580b17..ec4f35655a11b 100644 --- a/.github/patch-types.php +++ b/.github/patch-types.php @@ -35,6 +35,7 @@ case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php80Dummy.php'): case false !== strpos($file, '/src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures'): case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'): + case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/'): case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/LotsOfAttributes.php'): case false !== strpos($file, '/src/Symfony/Component/Validator/Tests/Fixtures/Attribute/'): case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/MyAttribute.php'): diff --git a/src/Symfony/Component/Serializer/Annotation/DiscriminatorMap.php b/src/Symfony/Component/Serializer/Annotation/DiscriminatorMap.php index c1184a53a5f6a..18df1c38d6cb0 100644 --- a/src/Symfony/Component/Serializer/Annotation/DiscriminatorMap.php +++ b/src/Symfony/Component/Serializer/Annotation/DiscriminatorMap.php @@ -21,6 +21,7 @@ * * @author Samuel Roze */ +#[\Attribute(\Attribute::TARGET_CLASS)] class DiscriminatorMap { /** @@ -34,20 +35,29 @@ class DiscriminatorMap private $mapping; /** + * @param string|array $typeProperty + * * @throws InvalidArgumentException */ - public function __construct(array $data) + public function __construct($typeProperty, array $mapping = null) { - if (empty($data['typeProperty'])) { + if (\is_array($typeProperty)) { + $mapping = $typeProperty['mapping'] ?? null; + $typeProperty = $typeProperty['typeProperty'] ?? null; + } elseif (!\is_string($typeProperty)) { + throw new \TypeError(sprintf('"%s": Argument $typeProperty was expected to be a string or array, got "%s".', __METHOD__, get_debug_type($typeProperty))); + } + + if (empty($typeProperty)) { throw new InvalidArgumentException(sprintf('Parameter "typeProperty" of annotation "%s" cannot be empty.', static::class)); } - if (empty($data['mapping'])) { + if (empty($mapping)) { throw new InvalidArgumentException(sprintf('Parameter "mapping" of annotation "%s" cannot be empty.', static::class)); } - $this->typeProperty = $data['typeProperty']; - $this->mapping = $data['mapping']; + $this->typeProperty = $typeProperty; + $this->mapping = $mapping; } public function getTypeProperty(): string diff --git a/src/Symfony/Component/Serializer/Annotation/Groups.php b/src/Symfony/Component/Serializer/Annotation/Groups.php index 4358a3e26dcb9..8f1e1d94f98e9 100644 --- a/src/Symfony/Component/Serializer/Annotation/Groups.php +++ b/src/Symfony/Component/Serializer/Annotation/Groups.php @@ -21,6 +21,7 @@ * * @author Kévin Dunglas */ +#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)] class Groups { /** @@ -31,20 +32,22 @@ class Groups /** * @throws InvalidArgumentException */ - public function __construct(array $data) + public function __construct(array $groups) { - if (!isset($data['value']) || !$data['value']) { + if (isset($groups['value'])) { + $groups = (array) $groups['value']; + } + if (empty($groups)) { throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', static::class)); } - $value = (array) $data['value']; - foreach ($value as $group) { + foreach ($groups as $group) { if (!\is_string($group)) { throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string or an array of strings.', static::class)); } } - $this->groups = $value; + $this->groups = $groups; } /** diff --git a/src/Symfony/Component/Serializer/Annotation/Ignore.php b/src/Symfony/Component/Serializer/Annotation/Ignore.php index 313c7f794753e..b09e7007a4a4d 100644 --- a/src/Symfony/Component/Serializer/Annotation/Ignore.php +++ b/src/Symfony/Component/Serializer/Annotation/Ignore.php @@ -19,6 +19,7 @@ * * @author Kévin Dunglas */ +#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)] final class Ignore { } diff --git a/src/Symfony/Component/Serializer/Annotation/MaxDepth.php b/src/Symfony/Component/Serializer/Annotation/MaxDepth.php index 9939fdab1cd18..97d29869a0f7a 100644 --- a/src/Symfony/Component/Serializer/Annotation/MaxDepth.php +++ b/src/Symfony/Component/Serializer/Annotation/MaxDepth.php @@ -21,6 +21,7 @@ * * @author Kévin Dunglas */ +#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)] class MaxDepth { /** @@ -28,17 +29,23 @@ class MaxDepth */ private $maxDepth; - public function __construct(array $data) + /** + * @param int|array $maxDepth + */ + public function __construct($maxDepth) { - if (!isset($data['value'])) { - throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.', static::class)); + if (\is_array($maxDepth)) { + if (!isset($maxDepth['value'])) { + throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.', static::class)); + } + $maxDepth = $maxDepth['value']; } - if (!\is_int($data['value']) || $data['value'] <= 0) { + if (!\is_int($maxDepth) || $maxDepth <= 0) { throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a positive integer.', static::class)); } - $this->maxDepth = $data['value']; + $this->maxDepth = $maxDepth; } public function getMaxDepth() diff --git a/src/Symfony/Component/Serializer/Annotation/SerializedName.php b/src/Symfony/Component/Serializer/Annotation/SerializedName.php index 747c8c55f108b..d621d9903db1b 100644 --- a/src/Symfony/Component/Serializer/Annotation/SerializedName.php +++ b/src/Symfony/Component/Serializer/Annotation/SerializedName.php @@ -21,6 +21,7 @@ * * @author Fabien Bourigault */ +#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)] final class SerializedName { /** @@ -28,17 +29,23 @@ final class SerializedName */ private $serializedName; - public function __construct(array $data) + /** + * @param string|array $serializedName + */ + public function __construct($serializedName) { - if (!isset($data['value'])) { - throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.', static::class)); + if (\is_array($serializedName)) { + if (!isset($serializedName['value'])) { + throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.', static::class)); + } + $serializedName = $serializedName['value']; } - if (!\is_string($data['value']) || empty($data['value'])) { + if (!\is_string($serializedName) || empty($serializedName)) { throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a non-empty string.', static::class)); } - $this->serializedName = $data['value']; + $this->serializedName = $serializedName; } public function getSerializedName(): string diff --git a/src/Symfony/Component/Serializer/CHANGELOG.md b/src/Symfony/Component/Serializer/CHANGELOG.md index 0fc8fd2c6898c..97ae3fd62fdab 100644 --- a/src/Symfony/Component/Serializer/CHANGELOG.md +++ b/src/Symfony/Component/Serializer/CHANGELOG.md @@ -8,6 +8,7 @@ CHANGELOG * added `UidNormalizer` * added `FormErrorNormalizer` * added `MimeMessageNormalizer` + * serializer mapping can be configured using php attributes 5.1.0 ----- diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php b/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php index 978fe659bbbce..9409bca360eb4 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php @@ -26,12 +26,21 @@ * Annotation loader. * * @author Kévin Dunglas + * @author Alexander M. Turek */ class AnnotationLoader implements LoaderInterface { + private const KNOWN_ANNOTATIONS = [ + DiscriminatorMap::class => true, + Groups::class => true, + Ignore:: class => true, + MaxDepth::class => true, + SerializedName::class => true, + ]; + private $reader; - public function __construct(Reader $reader) + public function __construct(Reader $reader = null) { $this->reader = $reader; } @@ -47,7 +56,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata) $attributesMetadata = $classMetadata->getAttributesMetadata(); - foreach ($this->reader->getClassAnnotations($reflectionClass) as $annotation) { + foreach ($this->loadAnnotations($reflectionClass) as $annotation) { if ($annotation instanceof DiscriminatorMap) { $classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping( $annotation->getTypeProperty(), @@ -63,7 +72,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata) } if ($property->getDeclaringClass()->name === $className) { - foreach ($this->reader->getPropertyAnnotations($property) as $annotation) { + foreach ($this->loadAnnotations($property) as $annotation) { if ($annotation instanceof Groups) { foreach ($annotation->getGroups() as $group) { $attributesMetadata[$property->name]->addGroup($group); @@ -98,7 +107,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata) } } - foreach ($this->reader->getMethodAnnotations($method) as $annotation) { + foreach ($this->loadAnnotations($method) as $annotation) { if ($annotation instanceof Groups) { if (!$accessorOrMutator) { throw new MappingException(sprintf('Groups on "%s::%s" cannot be added. Groups can only be added on methods beginning with "get", "is", "has" or "set".', $className, $method->name)); @@ -129,4 +138,32 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata) return $loaded; } + + /** + * @param \ReflectionClass|\ReflectionMethod|\ReflectionProperty $reflector + */ + public function loadAnnotations(object $reflector): iterable + { + if (\PHP_VERSION_ID >= 80000) { + foreach ($reflector->getAttributes() as $attribute) { + if (self::KNOWN_ANNOTATIONS[$attribute->getName()] ?? false) { + yield $attribute->newInstance(); + } + } + } + + if (null === $this->reader) { + return; + } + + if ($reflector instanceof \ReflectionClass) { + yield from $this->reader->getClassAnnotations($reflector); + } + if ($reflector instanceof \ReflectionMethod) { + yield from $this->reader->getMethodAnnotations($reflector); + } + if ($reflector instanceof \ReflectionProperty) { + yield from $this->reader->getPropertyAnnotations($reflector); + } + } } diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummy.php similarity index 58% rename from src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummy.php rename to src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummy.php index 4ae9812e7c76d..fad842b0d4693 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummy.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Serializer\Tests\Fixtures; +namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; /** * @DiscriminatorMap(typeProperty="type", mapping={ - * "first"="Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild", - * "second"="Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild", - * "third"="Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyThirdChild", + * "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 diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyFirstChild.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyFirstChild.php new file mode 100644 index 0000000000000..81f15aaf0d391 --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyFirstChild.php @@ -0,0 +1,39 @@ + + * + * 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 new file mode 100644 index 0000000000000..4d113066bbe32 --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummySecondChild.php @@ -0,0 +1,39 @@ + + * + * 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 new file mode 100644 index 0000000000000..2df26c3320f4c --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/AbstractDummyThirdChild.php @@ -0,0 +1,16 @@ + + * + * 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/GroupDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummy.php similarity index 90% rename from src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummy.php rename to src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummy.php index 37bfa7eb3f075..cf26b6e0da15d 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummy.php @@ -9,9 +9,10 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Serializer\Tests\Fixtures; +namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Tests\Fixtures\GroupDummyInterface; /** * @author Kévin Dunglas diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyChild.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyChild.php new file mode 100644 index 0000000000000..c8845736ac0d9 --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyChild.php @@ -0,0 +1,33 @@ + + * + * 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; + +class GroupDummyChild extends GroupDummy +{ + private $baz; + + /** + * @return mixed + */ + public function getBaz() + { + return $this->baz; + } + + /** + * @param mixed $baz + */ + public function setBaz($baz) + { + $this->baz = $baz; + } +} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummyParent.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyParent.php similarity index 92% rename from src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummyParent.php rename to src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyParent.php index dd24233993b9b..77d539b9400c8 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummyParent.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/GroupDummyParent.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Serializer\Tests\Fixtures; +namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; use Symfony\Component\Serializer\Annotation\Groups; diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/IgnoreDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummy.php similarity index 89% rename from src/Symfony/Component/Serializer/Tests/Fixtures/IgnoreDummy.php rename to src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummy.php index a272b4c6feb67..900447c581499 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/IgnoreDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/IgnoreDummy.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Serializer\Tests\Fixtures; +namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; use Symfony\Component\Serializer\Annotation\Ignore; diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/MaxDepthDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/MaxDepthDummy.php similarity index 91% rename from src/Symfony/Component/Serializer/Tests/Fixtures/MaxDepthDummy.php rename to src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/MaxDepthDummy.php index 92a4045f1eaf2..12be2db03b97f 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/MaxDepthDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/MaxDepthDummy.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Serializer\Tests\Fixtures; +namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; use Symfony\Component\Serializer\Annotation\MaxDepth; diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/SerializedNameDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedNameDummy.php similarity index 91% rename from src/Symfony/Component/Serializer/Tests/Fixtures/SerializedNameDummy.php rename to src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedNameDummy.php index 6fed9d201a26e..1eaa579b466fa 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/SerializedNameDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Annotations/SerializedNameDummy.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Serializer\Tests\Fixtures; +namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; use Symfony\Component\Serializer\Annotation\SerializedName; diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummy.php new file mode 100644 index 0000000000000..2e66f465b3cba --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummy.php @@ -0,0 +1,29 @@ + + * + * 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\Attributes; + +use Symfony\Component\Serializer\Annotation\DiscriminatorMap; + +#[DiscriminatorMap(typeProperty: 'type', mapping: [ + 'first' => AbstractDummyFirstChild::class, + 'second' => AbstractDummySecondChild::class, + 'third' => AbstractDummyThirdChild::class, +])] +abstract class AbstractDummy +{ + public $foo; + + public function __construct($foo = null) + { + $this->foo = $foo; + } +} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummyFirstChild.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummyFirstChild.php similarity index 83% rename from src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummyFirstChild.php rename to src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummyFirstChild.php index 20672c39b5fe7..b5cd2faba24ee 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummyFirstChild.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummyFirstChild.php @@ -9,7 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Serializer\Tests\Fixtures; +namespace Symfony\Component\Serializer\Tests\Fixtures\Attributes; + +use Symfony\Component\Serializer\Tests\Fixtures\DummyFirstChildQuux; class AbstractDummyFirstChild extends AbstractDummy { diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummySecondChild.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummySecondChild.php similarity index 83% rename from src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummySecondChild.php rename to src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummySecondChild.php index 67a72977e2c09..e245033cc2d4b 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummySecondChild.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummySecondChild.php @@ -9,7 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Serializer\Tests\Fixtures; +namespace Symfony\Component\Serializer\Tests\Fixtures\Attributes; + +use Symfony\Component\Serializer\Tests\Fixtures\DummySecondChildQuux; class AbstractDummySecondChild extends AbstractDummy { diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummyThirdChild.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummyThirdChild.php similarity index 82% rename from src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummyThirdChild.php rename to src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummyThirdChild.php index 3701e8c3f3bed..d5ef40c64468b 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummyThirdChild.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/AbstractDummyThirdChild.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Serializer\Tests\Fixtures; +namespace Symfony\Component\Serializer\Tests\Fixtures\Attributes; final class AbstractDummyThirdChild extends AbstractDummyFirstChild { diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/GroupDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/GroupDummy.php new file mode 100644 index 0000000000000..eef1c55be9e1e --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/GroupDummy.php @@ -0,0 +1,71 @@ + + * + * 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\Attributes; + +use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Tests\Fixtures\GroupDummyInterface; + +/** + * @author Kévin Dunglas + */ +class GroupDummy extends GroupDummyParent implements GroupDummyInterface +{ + #[Groups(["a"])] + private $foo; + #[Groups(["b", "c", "name_converter"])] + protected $bar; + 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; + } +} diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummyChild.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/GroupDummyChild.php similarity index 88% rename from src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummyChild.php rename to src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/GroupDummyChild.php index fa72160ec657f..5a7423914cd1d 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummyChild.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/GroupDummyChild.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Serializer\Tests\Fixtures; +namespace Symfony\Component\Serializer\Tests\Fixtures\Attributes; class GroupDummyChild extends GroupDummy { diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/GroupDummyParent.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/GroupDummyParent.php new file mode 100644 index 0000000000000..51a89acc47335 --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/GroupDummyParent.php @@ -0,0 +1,45 @@ + + * + * 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\Attributes; + +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/Attributes/IgnoreDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/IgnoreDummy.php new file mode 100644 index 0000000000000..85d7a9ca412b6 --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/IgnoreDummy.php @@ -0,0 +1,31 @@ + + * + * 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\Attributes; + +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/Attributes/MaxDepthDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/MaxDepthDummy.php new file mode 100644 index 0000000000000..7a1dc42c2faec --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/MaxDepthDummy.php @@ -0,0 +1,46 @@ + + * + * 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\Attributes; + +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/Attributes/SerializedNameDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/SerializedNameDummy.php new file mode 100644 index 0000000000000..39ded47731bc5 --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/SerializedNameDummy.php @@ -0,0 +1,43 @@ + + * + * 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\Attributes; + +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/invalid-ignore.yml b/src/Symfony/Component/Serializer/Tests/Fixtures/invalid-ignore.yml index d245021d8c7d3..00aa0fa962aae 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/invalid-ignore.yml +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/invalid-ignore.yml @@ -1,4 +1,4 @@ -'Symfony\Component\Serializer\Tests\Fixtures\IgnoreDummy': +'Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy': attributes: ignored1: ignore: foo diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/serialization.xml b/src/Symfony/Component/Serializer/Tests/Fixtures/serialization.xml index 257d838b4965e..635253dd8e805 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/serialization.xml +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/serialization.xml @@ -4,7 +4,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping https://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd"> - + group1 group2 @@ -15,26 +15,26 @@ - + - + - + - - + + - + diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/serialization.yml b/src/Symfony/Component/Serializer/Tests/Fixtures/serialization.yml index 4d98c73b04c16..5b212c8914aea 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/serialization.yml +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/serialization.yml @@ -1,30 +1,30 @@ -'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy': +'Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy': attributes: foo: groups: ['group1', 'group2'] bar: groups: ['group2'] -'Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy': +'Symfony\Component\Serializer\Tests\Fixtures\Annotations\MaxDepthDummy': attributes: foo: max_depth: 2 bar: max_depth: 3 -'Symfony\Component\Serializer\Tests\Fixtures\SerializedNameDummy': +'Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy': attributes: foo: serialized_name: 'baz' bar: serialized_name: 'qux' -'Symfony\Component\Serializer\Tests\Fixtures\AbstractDummy': +'Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummy': discriminator_map: type_property: type mapping: - first: 'Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild' - second: 'Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild' + first: 'Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummyFirstChild' + second: 'Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummySecondChild' attributes: foo: ~ -'Symfony\Component\Serializer\Tests\Fixtures\IgnoreDummy': +'Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy': attributes: ignored1: ignore: true diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/ClassDiscriminatorMappingTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/ClassDiscriminatorMappingTest.php index aed2d221d4a10..9c94a0463dcd1 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/ClassDiscriminatorMappingTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/ClassDiscriminatorMappingTest.php @@ -13,9 +13,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyThirdChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummyFirstChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummySecondChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummyThirdChild; /** * @author Samuel Roze diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryCompilerTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryCompilerTest.php index 87feb8f99ccae..2ce24718df31e 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryCompilerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryCompilerTest.php @@ -8,8 +8,8 @@ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryCompiler; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; use Symfony\Component\Serializer\Tests\Fixtures\Dummy; -use Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy; -use Symfony\Component\Serializer\Tests\Fixtures\SerializedNameDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\MaxDepthDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy; final class ClassMetadataFactoryCompilerTest extends TestCase { diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php index db0e887fb5770..3034eb4c4a31a 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php @@ -32,16 +32,16 @@ public function testInterface() public function testGetMetadataFor() { $factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); - $classMetadata = $factory->getMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy'); + $classMetadata = $factory->getMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy'); - $this->assertEquals(TestClassMetadataFactory::createClassMetadata(true, true), $classMetadata); + $this->assertEquals(TestClassMetadataFactory::createClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\Annotations', true, true), $classMetadata); } public function testHasMetadataFor() { $factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); - $this->assertTrue($factory->hasMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy')); - $this->assertTrue($factory->hasMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummyParent')); + $this->assertTrue($factory->hasMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy')); + $this->assertTrue($factory->hasMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummyParent')); $this->assertTrue($factory->hasMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummyInterface')); $this->assertFalse($factory->hasMetadataFor('Dunglas\Entity')); } diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CompiledClassMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CompiledClassMetadataFactoryTest.php index 21beddd3f641b..034e8aa0880b1 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CompiledClassMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CompiledClassMetadataFactoryTest.php @@ -8,7 +8,7 @@ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; use Symfony\Component\Serializer\Mapping\Factory\CompiledClassMetadataFactory; use Symfony\Component\Serializer\Tests\Fixtures\Dummy; -use Symfony\Component\Serializer\Tests\Fixtures\SerializedNameDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy; /** * @author Fabien Bourigault diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php index 9c5a9943e31ef..690f1c4b81df9 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php @@ -11,23 +11,17 @@ namespace Symfony\Component\Serializer\Tests\Mapping\Loader; -use Doctrine\Common\Annotations\AnnotationReader; use PHPUnit\Framework\TestCase; use Symfony\Component\Serializer\Mapping\AttributeMetadata; use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping; use Symfony\Component\Serializer\Mapping\ClassMetadata; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummy; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild; -use Symfony\Component\Serializer\Tests\Fixtures\IgnoreDummy; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyThirdChild; use Symfony\Component\Serializer\Tests\Mapping\TestClassMetadataFactory; /** * @author Kévin Dunglas */ -class AnnotationLoaderTest extends TestCase +abstract class AnnotationLoaderTest extends TestCase { /** * @var AnnotationLoader @@ -36,7 +30,7 @@ class AnnotationLoaderTest extends TestCase protected function setUp(): void { - $this->loader = new AnnotationLoader(new AnnotationReader()); + $this->loader = $this->createLoader(); } public function testInterface() @@ -46,28 +40,28 @@ public function testInterface() public function testLoadClassMetadataReturnsTrueIfSuccessful() { - $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy'); + $classMetadata = new ClassMetadata($this->getNamespace().'\GroupDummy'); $this->assertTrue($this->loader->loadClassMetadata($classMetadata)); } public function testLoadGroups() { - $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy'); + $classMetadata = new ClassMetadata($this->getNamespace().'\GroupDummy'); $this->loader->loadClassMetadata($classMetadata); - $this->assertEquals(TestClassMetadataFactory::createClassMetadata(), $classMetadata); + $this->assertEquals(TestClassMetadataFactory::createClassMetadata($this->getNamespace()), $classMetadata); } public function testLoadDiscriminatorMap() { - $classMetadata = new ClassMetadata(AbstractDummy::class); + $classMetadata = new ClassMetadata($this->getNamespace().'\AbstractDummy'); $this->loader->loadClassMetadata($classMetadata); - $expected = new ClassMetadata(AbstractDummy::class, new ClassDiscriminatorMapping('type', [ - 'first' => AbstractDummyFirstChild::class, - 'second' => AbstractDummySecondChild::class, - 'third' => AbstractDummyThirdChild::class, + $expected = new ClassMetadata($this->getNamespace().'\AbstractDummy', new ClassDiscriminatorMapping('type', [ + 'first' => $this->getNamespace().'\AbstractDummyFirstChild', + 'second' => $this->getNamespace().'\AbstractDummySecondChild', + 'third' => $this->getNamespace().'\AbstractDummyThirdChild', ])); $expected->addAttributeMetadata(new AttributeMetadata('foo')); @@ -78,7 +72,7 @@ public function testLoadDiscriminatorMap() public function testLoadMaxDepth() { - $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy'); + $classMetadata = new ClassMetadata($this->getNamespace().'\MaxDepthDummy'); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); @@ -88,7 +82,7 @@ public function testLoadMaxDepth() public function testLoadSerializedName() { - $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\SerializedNameDummy'); + $classMetadata = new ClassMetadata($this->getNamespace().'\SerializedNameDummy'); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); @@ -98,24 +92,27 @@ public function testLoadSerializedName() public function testLoadClassMetadataAndMerge() { - $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy'); - $parentClassMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummyParent'); + $classMetadata = new ClassMetadata($this->getNamespace().'\GroupDummy'); + $parentClassMetadata = new ClassMetadata($this->getNamespace().'\GroupDummyParent'); $this->loader->loadClassMetadata($parentClassMetadata); $classMetadata->merge($parentClassMetadata); $this->loader->loadClassMetadata($classMetadata); - $this->assertEquals(TestClassMetadataFactory::createClassMetadata(true), $classMetadata); + $this->assertEquals(TestClassMetadataFactory::createClassMetadata($this->getNamespace(), true), $classMetadata); } public function testLoadIgnore() { - $classMetadata = new ClassMetadata(IgnoreDummy::class); + $classMetadata = new ClassMetadata($this->getNamespace().'\IgnoreDummy'); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); $this->assertTrue($attributesMetadata['ignored1']->isIgnored()); $this->assertTrue($attributesMetadata['ignored2']->isIgnored()); } + + abstract protected function createLoader(): AnnotationLoader; + abstract protected function getNamespace(): string; } diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php new file mode 100644 index 0000000000000..c5836f26f9a24 --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php @@ -0,0 +1,30 @@ + + * + * 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\Mapping\Loader\AnnotationLoader; + +/** + * @requires PHP 8 + */ +class AnnotationLoaderWithAttributesTest extends AnnotationLoaderTest +{ + protected function createLoader(): AnnotationLoader + { + return new AnnotationLoader(); + } + + protected function getNamespace(): string + { + return 'Symfony\Component\Serializer\Tests\Fixtures\Attributes'; + } +} diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php new file mode 100644 index 0000000000000..37675a49d94ac --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php @@ -0,0 +1,28 @@ + + * + * 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\Component\Serializer\Mapping\Loader\AnnotationLoader; + +class AnnotationLoaderWithDoctrineAnnotationsTest extends AnnotationLoaderTest +{ + 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/Tests/Mapping/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php index 4d30c8e2cbfe9..8a5e0e13f74fe 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php @@ -16,10 +16,10 @@ use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping; use Symfony\Component\Serializer\Mapping\ClassMetadata; use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummy; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild; -use Symfony\Component\Serializer\Tests\Fixtures\IgnoreDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummyFirstChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummySecondChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy; use Symfony\Component\Serializer\Tests\Mapping\TestClassMetadataFactory; /** @@ -39,7 +39,7 @@ class XmlFileLoaderTest extends TestCase protected function setUp(): void { $this->loader = new XmlFileLoader(__DIR__.'/../../Fixtures/serialization.xml'); - $this->metadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy'); + $this->metadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy'); } public function testInterface() @@ -61,7 +61,7 @@ public function testLoadClassMetadata() public function testMaxDepth() { - $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy'); + $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\Annotations\MaxDepthDummy'); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); @@ -71,7 +71,7 @@ public function testMaxDepth() public function testSerializedName() { - $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\SerializedNameDummy'); + $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy'); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php index 6d2ff5c0bdb8e..2e708665f5ae1 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php @@ -17,10 +17,10 @@ use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping; use Symfony\Component\Serializer\Mapping\ClassMetadata; use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummy; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild; -use Symfony\Component\Serializer\Tests\Fixtures\IgnoreDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummyFirstChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummySecondChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy; use Symfony\Component\Serializer\Tests\Mapping\TestClassMetadataFactory; /** @@ -40,7 +40,7 @@ class YamlFileLoaderTest extends TestCase protected function setUp(): void { $this->loader = new YamlFileLoader(__DIR__.'/../../Fixtures/serialization.yml'); - $this->metadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy'); + $this->metadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy'); } public function testInterface() @@ -75,7 +75,7 @@ public function testLoadClassMetadata() public function testMaxDepth() { - $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy'); + $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\Annotations\MaxDepthDummy'); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); @@ -85,7 +85,7 @@ public function testMaxDepth() public function testSerializedName() { - $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\SerializedNameDummy'); + $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy'); $this->loader->loadClassMetadata($classMetadata); $attributesMetadata = $classMetadata->getAttributesMetadata(); diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/TestClassMetadataFactory.php b/src/Symfony/Component/Serializer/Tests/Mapping/TestClassMetadataFactory.php index 71fa42be8a067..4fcb8e5436fe8 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/TestClassMetadataFactory.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/TestClassMetadataFactory.php @@ -19,9 +19,9 @@ */ class TestClassMetadataFactory { - public static function createClassMetadata(bool $withParent = false, bool $withInterface = false) + public static function createClassMetadata(string $namespace, bool $withParent = false, bool $withInterface = false): ClassMetadata { - $expected = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy'); + $expected = new ClassMetadata($namespace.'\GroupDummy'); $foo = new AttributeMetadata('foo'); $foo->addGroup('a'); @@ -64,9 +64,9 @@ public static function createClassMetadata(bool $withParent = false, bool $withI return $expected; } - public static function createXmlCLassMetadata() + public static function createXmlCLassMetadata(): ClassMetadata { - $expected = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy'); + $expected = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy'); $foo = new AttributeMetadata('foo'); $foo->addGroup('group1'); diff --git a/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php b/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php index 9b0ad4d79c55b..ba20bc7b0df2d 100644 --- a/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php +++ b/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php @@ -19,7 +19,7 @@ use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter; use Symfony\Component\Serializer\NameConverter\NameConverterInterface; use Symfony\Component\Serializer\Tests\Fixtures\OtherSerializedNameDummy; -use Symfony\Component\Serializer\Tests\Fixtures\SerializedNameDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy; /** * @author Fabien Bourigault diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php index 082b427ab7caa..3aa4d1c63d73b 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Tests\Fixtures\AbstractNormalizerDummy; use Symfony\Component\Serializer\Tests\Fixtures\Dummy; -use Symfony\Component\Serializer\Tests\Fixtures\IgnoreDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy; use Symfony\Component\Serializer\Tests\Fixtures\NullableConstructorArgumentDummy; use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorDummy; use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorNormalizer; diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php index 71d999a466934..55fced0ab3338 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php @@ -31,9 +31,9 @@ use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\SerializerAwareInterface; use Symfony\Component\Serializer\SerializerInterface; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummy; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummyFirstChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummySecondChild; use Symfony\Component\Serializer\Tests\Fixtures\DummySecondChildQuux; class AbstractObjectNormalizerTest extends TestCase diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/GroupsTestTrait.php b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/GroupsTestTrait.php index 1d9777d7a099e..619cb4e88525d 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/GroupsTestTrait.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/GroupsTestTrait.php @@ -4,7 +4,7 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -use Symfony\Component\Serializer\Tests\Fixtures\GroupDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy; /** * Test AbstractNormalizer::GROUPS. diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/MaxDepthTestTrait.php b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/MaxDepthTestTrait.php index 229a1f822a99c..0b7f115ace1e5 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/MaxDepthTestTrait.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/MaxDepthTestTrait.php @@ -3,7 +3,7 @@ namespace Symfony\Component\Serializer\Tests\Normalizer\Features; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -use Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\MaxDepthDummy; /** * Covers AbstractObjectNormalizer::ENABLE_MAX_DEPTH and AbstractObjectNormalizer::MAX_DEPTH_HANDLER. diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index d6beb7c19ec32..b2efafc34844a 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -28,7 +28,7 @@ use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy; -use Symfony\Component\Serializer\Tests\Fixtures\GroupDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy; use Symfony\Component\Serializer\Tests\Fixtures\SiblingHolder; use Symfony\Component\Serializer\Tests\Normalizer\Features\CallbacksTestTrait; use Symfony\Component\Serializer\Tests\Normalizer\Features\CircularReferenceTestTrait; @@ -306,7 +306,7 @@ public function testGroupsDenormalizeWithNameConverter() 'foo_bar' => '@dunglas', 'symfony' => '@coopTilleuls', 'coop_tilleuls' => 'les-tilleuls.coop', - ], 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, [GetSetMethodNormalizer::GROUPS => ['name_converter']]) + ], 'Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy', null, [GetSetMethodNormalizer::GROUPS => ['name_converter']]) ); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 6b2474c145118..66d578f1ebf85 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -29,7 +29,7 @@ use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy; -use Symfony\Component\Serializer\Tests\Fixtures\GroupDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy; use Symfony\Component\Serializer\Tests\Fixtures\OtherSerializedNameDummy; use Symfony\Component\Serializer\Tests\Fixtures\Php74Dummy; use Symfony\Component\Serializer\Tests\Fixtures\SiblingHolder; @@ -435,7 +435,7 @@ public function testGroupsDenormalizeWithNameConverter() 'foo_bar' => '@dunglas', 'symfony' => '@coopTilleuls', 'coop_tilleuls' => 'les-tilleuls.coop', - ], 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, [ObjectNormalizer::GROUPS => ['name_converter']]) + ], 'Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy', null, [ObjectNormalizer::GROUPS => ['name_converter']]) ); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php index 78d75471da252..67989d200e75d 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php @@ -26,8 +26,8 @@ use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\Tests\Fixtures\Dummy; -use Symfony\Component\Serializer\Tests\Fixtures\GroupDummy; -use Symfony\Component\Serializer\Tests\Fixtures\GroupDummyChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummyChild; use Symfony\Component\Serializer\Tests\Fixtures\Php74Dummy; use Symfony\Component\Serializer\Tests\Fixtures\PropertyCircularReferenceDummy; use Symfony\Component\Serializer\Tests\Fixtures\PropertySiblingHolder; @@ -253,7 +253,7 @@ public function testGroupsDenormalizeWithNameConverter() 'foo_bar' => '@dunglas', 'symfony' => '@coopTilleuls', 'coop_tilleuls' => 'les-tilleuls.coop', - ], 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, [PropertyNormalizer::GROUPS => ['name_converter']]) + ], 'Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy', null, [PropertyNormalizer::GROUPS => ['name_converter']]) ); } diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php index 80c430a7d4323..36cd098af8720 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -39,9 +39,9 @@ use Symfony\Component\Serializer\Normalizer\PropertyNormalizer; use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer; use Symfony\Component\Serializer\Serializer; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummy; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild; -use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummy; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummyFirstChild; +use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummySecondChild; use Symfony\Component\Serializer\Tests\Fixtures\DummyFirstChildQuux; use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface; use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageNumberOne; 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