From 6a209ef289a5dc6ee4c89166a077dd5cfd591f7f Mon Sep 17 00:00:00 2001 From: David Grayston Date: Fri, 11 Oct 2024 09:30:07 +0100 Subject: [PATCH] fix: Compatibility with older Symfony versions --- src/Client.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Client.php b/src/Client.php index 9a1e84f..e24962d 100644 --- a/src/Client.php +++ b/src/Client.php @@ -41,9 +41,9 @@ use Psr\Http\Message\UriInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; -use Symfony\Component\Serializer\Context\Normalizer\ObjectNormalizerContextBuilder; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Symfony\Component\Serializer\Normalizer\BackedEnumNormalizer; use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; @@ -178,9 +178,9 @@ private function requestRaw(string $method, string|UriInterface $uri, array|\Jso new JsonSerializableNormalizer(), new ObjectNormalizer( nameConverter: new CamelCaseToSnakeCaseNameConverter(), - defaultContext: (new ObjectNormalizerContextBuilder()) - ->withPreserveEmptyObjects(true) - ->toArray(), + defaultContext: [ + AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS => true, + ], ), ], [new JsonEncoder()],