@@ -281,8 +281,8 @@ private function getNormalizer(mixed $data, ?string $format, array $context): ?N
281281 $ genericType = '* ' ;
282282 }
283283
284- if (!isset ($ this ->normalizerCache [$ format ][$ type ])) {
285- $ this ->normalizerCache [$ format ][$ type ] = [];
284+ if (!isset ($ this ->normalizerCache [$ format ?? '' ][$ type ])) {
285+ $ this ->normalizerCache [$ format ?? '' ][$ type ] = [];
286286
287287 foreach ($ this ->normalizers as $ k => $ normalizer ) {
288288 if (!$ normalizer instanceof NormalizerInterface) {
@@ -293,9 +293,9 @@ private function getNormalizer(mixed $data, ?string $format, array $context): ?N
293293 trigger_deprecation ('symfony/serializer ' , '6.3 ' , '"%s" should implement "NormalizerInterface::getSupportedTypes(?string $format): array". ' , $ normalizer ::class);
294294
295295 if (!$ normalizer instanceof CacheableSupportsMethodInterface || !$ normalizer ->hasCacheableSupportsMethod ()) {
296- $ this ->normalizerCache [$ format ][$ type ][$ k ] = false ;
296+ $ this ->normalizerCache [$ format ?? '' ][$ type ][$ k ] = false ;
297297 } elseif ($ normalizer ->supportsNormalization ($ data , $ format , $ context )) {
298- $ this ->normalizerCache [$ format ][$ type ][$ k ] = true ;
298+ $ this ->normalizerCache [$ format ?? '' ][$ type ][$ k ] = true ;
299299 break ;
300300 }
301301
@@ -313,7 +313,7 @@ private function getNormalizer(mixed $data, ?string $format, array $context): ?N
313313
314314 if (null === $ isCacheable ) {
315315 unset($ supportedTypes ['* ' ], $ supportedTypes ['object ' ]);
316- } elseif ($ this ->normalizerCache [$ format ][$ type ][$ k ] = $ isCacheable && $ normalizer ->supportsNormalization ($ data , $ format , $ context )) {
316+ } elseif ($ this ->normalizerCache [$ format ?? '' ][$ type ][$ k ] = $ isCacheable && $ normalizer ->supportsNormalization ($ data , $ format , $ context )) {
317317 break 2 ;
318318 }
319319
@@ -324,13 +324,13 @@ private function getNormalizer(mixed $data, ?string $format, array $context): ?N
324324 continue ;
325325 }
326326
327- if ($ this ->normalizerCache [$ format ][$ type ][$ k ] ??= $ isCacheable && $ normalizer ->supportsNormalization ($ data , $ format , $ context )) {
327+ if ($ this ->normalizerCache [$ format ?? '' ][$ type ][$ k ] ??= $ isCacheable && $ normalizer ->supportsNormalization ($ data , $ format , $ context )) {
328328 break ;
329329 }
330330 }
331331 }
332332
333- foreach ($ this ->normalizerCache [$ format ][$ type ] as $ k => $ cached ) {
333+ foreach ($ this ->normalizerCache [$ format ?? '' ][$ type ] as $ k => $ cached ) {
334334 $ normalizer = $ this ->normalizers [$ k ];
335335 if ($ cached || $ normalizer ->supportsNormalization ($ data , $ format , $ context )) {
336336 return $ normalizer ;
@@ -350,8 +350,8 @@ private function getNormalizer(mixed $data, ?string $format, array $context): ?N
350350 */
351351 private function getDenormalizer (mixed $ data , string $ class , ?string $ format , array $ context ): ?DenormalizerInterface
352352 {
353- if (!isset ($ this ->denormalizerCache [$ format ][$ class ])) {
354- $ this ->denormalizerCache [$ format ][$ class ] = [];
353+ if (!isset ($ this ->denormalizerCache [$ format ?? '' ][$ class ])) {
354+ $ this ->denormalizerCache [$ format ?? '' ][$ class ] = [];
355355 $ genericType = class_exists ($ class ) || interface_exists ($ class , false ) ? 'object ' : '* ' ;
356356
357357 foreach ($ this ->normalizers as $ k => $ normalizer ) {
@@ -363,9 +363,9 @@ private function getDenormalizer(mixed $data, string $class, ?string $format, ar
363363 trigger_deprecation ('symfony/serializer ' , '6.3 ' , '"%s" should implement "DenormalizerInterface::getSupportedTypes(?string $format): array". ' , $ normalizer ::class);
364364
365365 if (!$ normalizer instanceof CacheableSupportsMethodInterface || !$ normalizer ->hasCacheableSupportsMethod ()) {
366- $ this ->denormalizerCache [$ format ][$ class ][$ k ] = false ;
366+ $ this ->denormalizerCache [$ format ?? '' ][$ class ][$ k ] = false ;
367367 } elseif ($ normalizer ->supportsDenormalization (null , $ class , $ format , $ context )) {
368- $ this ->denormalizerCache [$ format ][$ class ][$ k ] = true ;
368+ $ this ->denormalizerCache [$ format ?? '' ][$ class ][$ k ] = true ;
369369 break ;
370370 }
371371
@@ -386,7 +386,7 @@ private function getDenormalizer(mixed $data, string $class, ?string $format, ar
386386
387387 if (null === $ isCacheable ) {
388388 unset($ supportedTypes ['* ' ], $ supportedTypes ['object ' ]);
389- } elseif ($ this ->denormalizerCache [$ format ][$ class ][$ k ] = $ isCacheable && $ normalizer ->supportsDenormalization (null , $ class , $ format , $ context )) {
389+ } elseif ($ this ->denormalizerCache [$ format ?? '' ][$ class ][$ k ] = $ isCacheable && $ normalizer ->supportsDenormalization (null , $ class , $ format , $ context )) {
390390 break 2 ;
391391 }
392392
@@ -397,13 +397,13 @@ private function getDenormalizer(mixed $data, string $class, ?string $format, ar
397397 continue ;
398398 }
399399
400- if ($ this ->denormalizerCache [$ format ][$ class ][$ k ] ??= $ isCacheable && $ normalizer ->supportsDenormalization (null , $ class , $ format , $ context )) {
400+ if ($ this ->denormalizerCache [$ format ?? '' ][$ class ][$ k ] ??= $ isCacheable && $ normalizer ->supportsDenormalization (null , $ class , $ format , $ context )) {
401401 break ;
402402 }
403403 }
404404 }
405405
406- foreach ($ this ->denormalizerCache [$ format ][$ class ] as $ k => $ cached ) {
406+ foreach ($ this ->denormalizerCache [$ format ?? '' ][$ class ] as $ k => $ cached ) {
407407 $ normalizer = $ this ->normalizers [$ k ];
408408 if ($ cached || $ normalizer ->supportsDenormalization ($ data , $ class , $ format , $ context )) {
409409 return $ normalizer ;
0 commit comments