diff --git a/DependencyInjection/AttributeMetadataPass.php b/DependencyInjection/AttributeMetadataPass.php index c05c89e86dc..545ce8cffee 100644 --- a/DependencyInjection/AttributeMetadataPass.php +++ b/DependencyInjection/AttributeMetadataPass.php @@ -13,7 +13,6 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Exception\MappingException; /** @@ -33,9 +32,6 @@ public function process(ContainerBuilder $container): void if (!$definition->hasTag('serializer.attribute_metadata')) { continue; } - if (!$definition->hasTag('container.excluded')) { - throw new InvalidArgumentException(\sprintf('The resource "%s" tagged "serializer.attribute_metadata" is missing the "container.excluded" tag.', $id)); - } $class = $resolve($definition->getClass()); foreach ($definition->getTag('serializer.attribute_metadata') as $attributes) { if ($class !== $for = $attributes['for'] ?? $class) { diff --git a/Tests/DependencyInjection/AttributeMetadataPassTest.php b/Tests/DependencyInjection/AttributeMetadataPassTest.php index edffe3f2c81..3291713bab8 100644 --- a/Tests/DependencyInjection/AttributeMetadataPassTest.php +++ b/Tests/DependencyInjection/AttributeMetadataPassTest.php @@ -13,7 +13,6 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\Serializer\DependencyInjection\AttributeMetadataPass; use Symfony\Component\Serializer\Exception\MappingException; use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader; @@ -52,18 +51,14 @@ public function testProcessWithTaggedServices() ->setArguments([false, []]); $container->register('service1', '%user_entity.class%') - ->addTag('serializer.attribute_metadata') - ->addTag('container.excluded'); + ->addTag('serializer.attribute_metadata'); $container->register('service2', 'App\Entity\Product') - ->addTag('serializer.attribute_metadata') - ->addTag('container.excluded'); + ->addTag('serializer.attribute_metadata'); $container->register('service3', 'App\Entity\Order') - ->addTag('serializer.attribute_metadata') - ->addTag('container.excluded'); + ->addTag('serializer.attribute_metadata'); // Classes should be deduplicated $container->register('service4', 'App\Entity\Order') - ->addTag('serializer.attribute_metadata') - ->addTag('container.excluded'); + ->addTag('serializer.attribute_metadata'); (new AttributeMetadataPass())->process($container); @@ -78,18 +73,6 @@ public function testProcessWithTaggedServices() $this->assertSame([false, $expectedClasses], $arguments); } - public function testThrowsWhenMissingExcludedTag() - { - $container = new ContainerBuilder(); - $container->register('serializer.mapping.attribute_loader'); - - $container->register('service_without_excluded', 'App\\Entity\\User') - ->addTag('serializer.attribute_metadata'); - - $this->expectException(InvalidArgumentException::class); - (new AttributeMetadataPass())->process($container); - } - public function testProcessWithForOptionAndMatchingMembers() { $sourceClass = _AttrMeta_Source::class; @@ -100,8 +83,7 @@ public function testProcessWithForOptionAndMatchingMembers() ->setArguments([false, []]); $container->register('service.source', $sourceClass) - ->addTag('serializer.attribute_metadata', ['for' => $targetClass]) - ->addTag('container.excluded'); + ->addTag('serializer.attribute_metadata', ['for' => $targetClass]); (new AttributeMetadataPass())->process($container); @@ -119,8 +101,7 @@ public function testProcessWithForOptionAndMissingMemberThrows() ->setArguments([false, []]); $container->register('service.source', $sourceClass) - ->addTag('serializer.attribute_metadata', ['for' => $targetClass]) - ->addTag('container.excluded'); + ->addTag('serializer.attribute_metadata', ['for' => $targetClass]); $this->expectException(MappingException::class); (new AttributeMetadataPass())->process($container);