diff --git a/CHANGELOG.md b/CHANGELOG.md index 57a831ad4a..4271bc02cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## v5.0.0-alpha.4 +### Breaking changes + +* `ApiPlatform\State\Provider\DeserializeProvider` no longer accepts a `Symfony\Contracts\Translation\TranslatorInterface` as its fourth constructor argument, as announced by the deprecation added in 4.4. Denormalization violations and their translation are handled by `DenormalizationViolationFactoryInterface`, which moves from the fifth to the fourth position. Anyone constructing the provider by hand, or overriding the `api_platform.state_provider.deserialize` service definition, must drop the translator argument. `api-platform/state` no longer requires `symfony/translation-contracts`. ### Notes * The internal `ApiPlatform\Symfony\Bundle\ArgumentResolver\CompatibleValueResolverInterface` is removed. It aliased either `ValueResolverInterface` or the Symfony 6 `ArgumentValueResolverInterface` depending on which existed; since the Symfony floor is `^7.4`, only the former can be installed, and Symfony 8 dropped the latter altogether. `PayloadArgumentResolver` now implements `ValueResolverInterface` directly. diff --git a/src/Laravel/ApiPlatformProvider.php b/src/Laravel/ApiPlatformProvider.php index 7d43ace6e0..96ba92c53f 100644 --- a/src/Laravel/ApiPlatformProvider.php +++ b/src/Laravel/ApiPlatformProvider.php @@ -473,7 +473,6 @@ public function register(): void $app->make(SwaggerUiProvider::class), $app->make(SerializerInterface::class), $app->make(SerializerContextBuilderInterface::class), - null, $app->make(DenormalizationViolationFactoryInterface::class), ); }); diff --git a/src/State/Provider/DeserializeProvider.php b/src/State/Provider/DeserializeProvider.php index 9ae282691f..d91b26a475 100644 --- a/src/State/Provider/DeserializeProvider.php +++ b/src/State/Provider/DeserializeProvider.php @@ -25,7 +25,6 @@ use Symfony\Component\Serializer\Exception\PartialDenormalizationException; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\SerializerInterface; -use Symfony\Contracts\Translation\TranslatorInterface; final class DeserializeProvider implements ProviderInterface, StopwatchAwareInterface { @@ -35,12 +34,8 @@ public function __construct( private readonly ?ProviderInterface $decorated, private readonly SerializerInterface $serializer, private readonly SerializerContextBuilderInterface $serializerContextBuilder, - ?TranslatorInterface $translator = null, private readonly ?DenormalizationViolationFactoryInterface $violationFactory = null, ) { - if (null !== $translator) { - trigger_deprecation('api-platform/core', '4.4', 'Passing a "%s" to "%s" is deprecated and will be removed in 5.0. Translation is now handled by "%s".', TranslatorInterface::class, self::class, DenormalizationViolationFactoryInterface::class); - } } public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null diff --git a/src/State/Tests/Provider/DeserializeProviderTest.php b/src/State/Tests/Provider/DeserializeProviderTest.php index 6332e30f9e..448144eb6b 100644 --- a/src/State/Tests/Provider/DeserializeProviderTest.php +++ b/src/State/Tests/Provider/DeserializeProviderTest.php @@ -182,7 +182,7 @@ public function testDeserializeDelegatesSingleErrorToHandler(): void $handler->expects($this->once())->method('handle')->with($exception, $operation) ->willThrowException(new \LogicException('handler-threw')); - $provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, null, $handler); + $provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, $handler); $request = new Request(content: '{"status":"invalid"}'); $request->headers->set('CONTENT_TYPE', 'application/json'); $request->attributes->set('input_format', 'json'); @@ -211,7 +211,7 @@ public function testDeserializeDelegatesPartialErrorToHandler(): void $handler->expects($this->once())->method('handle')->with($partialException, $operation) ->willThrowException(new \LogicException('handler-threw-partial')); - $provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, null, $handler); + $provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, $handler); $request = new Request(content: '{"status":"invalid"}'); $request->headers->set('CONTENT_TYPE', 'application/json'); $request->attributes->set('input_format', 'json'); @@ -262,7 +262,7 @@ public function testDeserializeRethrowsPartialErrorWhenHandlerReturnsVoid(): voi $handler = $this->createMock(DenormalizationViolationFactoryInterface::class); $handler->expects($this->once())->method('handle'); - $provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, null, $handler); + $provider = new DeserializeProvider($decorated, $serializer, $serializerContextBuilder, $handler); $request = new Request(content: '{"status":"invalid"}'); $request->headers->set('CONTENT_TYPE', 'application/json'); $request->attributes->set('input_format', 'json'); diff --git a/src/State/composer.json b/src/State/composer.json index 39eb0b40cf..86d6072829 100644 --- a/src/State/composer.json +++ b/src/State/composer.json @@ -32,7 +32,6 @@ "psr/container": "^1.0 || ^2.0", "symfony/http-kernel": "^7.4 || ^8.0", "symfony/serializer": "^7.4 || ^8.0", - "symfony/translation-contracts": "^3.0", "symfony/deprecation-contracts": "^3.1" }, "require-dev": { diff --git a/src/Symfony/Bundle/Resources/config/mcp/events.php b/src/Symfony/Bundle/Resources/config/mcp/events.php index 2c5c848908..c920eb50d8 100644 --- a/src/Symfony/Bundle/Resources/config/mcp/events.php +++ b/src/Symfony/Bundle/Resources/config/mcp/events.php @@ -44,7 +44,6 @@ service('api_platform.mcp.state_provider.deserialize.inner'), service('api_platform.serializer'), service('api_platform.serializer.context_builder'), - service('translator')->nullOnInvalid(), ]); $services->set('api_platform.mcp.state_provider.parameter', ParameterProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/state/provider.php b/src/Symfony/Bundle/Resources/config/state/provider.php index e57c02f59a..50f32a83fb 100644 --- a/src/Symfony/Bundle/Resources/config/state/provider.php +++ b/src/Symfony/Bundle/Resources/config/state/provider.php @@ -56,7 +56,6 @@ service('api_platform.state_provider.deserialize.inner'), service('api_platform.serializer'), service('api_platform.serializer.context_builder'), - null, service('api_platform.state.denormalization_violation_factory')->nullOnInvalid(), ]); diff --git a/src/Symfony/Bundle/Resources/config/symfony/events.php b/src/Symfony/Bundle/Resources/config/symfony/events.php index ae428bb459..c1a0b8e374 100644 --- a/src/Symfony/Bundle/Resources/config/symfony/events.php +++ b/src/Symfony/Bundle/Resources/config/symfony/events.php @@ -85,7 +85,6 @@ null, service('api_platform.serializer'), service('api_platform.serializer.context_builder'), - null, service('api_platform.state.denormalization_violation_factory')->nullOnInvalid(), ]);