diff --git a/src/Elasticsearch/Serializer/ItemNormalizer.php b/src/Elasticsearch/Serializer/ItemNormalizer.php index 74e9f5f7e97..dbb01a76766 100644 --- a/src/Elasticsearch/Serializer/ItemNormalizer.php +++ b/src/Elasticsearch/Serializer/ItemNormalizer.php @@ -13,10 +13,12 @@ namespace ApiPlatform\Elasticsearch\Serializer; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Exception\LogicException; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; +use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\SerializerAwareInterface; use Symfony\Component\Serializer\SerializerInterface; @@ -39,8 +41,17 @@ public function __construct(private readonly NormalizerInterface $decorated) */ public function hasCacheableSupportsMethod(): bool { - if (!$this->decorated instanceof CacheableSupportsMethodInterface) { - throw new LogicException(sprintf('The decorated normalizer must be an instance of "%s".', CacheableSupportsMethodInterface::class)); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } + + if (!$this->decorated instanceof BaseCacheableSupportsMethodInterface) { + throw new LogicException(sprintf('The decorated normalizer must be an instance of "%s".', BaseCacheableSupportsMethodInterface::class)); } return $this->decorated->hasCacheableSupportsMethod(); @@ -96,11 +107,11 @@ public function getSupportedTypes($format): array if (!method_exists($this->decorated, 'getSupportedTypes')) { return [ DocumentNormalizer::FORMAT => null, - '*' => $this->decorated instanceof CacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(), + '*' => $this->decorated instanceof BaseCacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(), ]; } - return DocumentNormalizer::FORMAT !== $format ? $this->decorated->getSupportedTypes($format) : []; + return DocumentNormalizer::FORMAT === $format ? $this->decorated->getSupportedTypes($format) : []; } /** diff --git a/src/GraphQl/Serializer/ObjectNormalizer.php b/src/GraphQl/Serializer/ObjectNormalizer.php index 1fe29b9311a..5c2cbba2e02 100644 --- a/src/GraphQl/Serializer/ObjectNormalizer.php +++ b/src/GraphQl/Serializer/ObjectNormalizer.php @@ -16,9 +16,11 @@ use ApiPlatform\Api\IdentifiersExtractorInterface; use ApiPlatform\Api\IriConverterInterface; use ApiPlatform\Metadata\Util\ClassInfoTrait; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Exception\UnexpectedValueException; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; +use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Decorates the output with GraphQL metadata when appropriate, but otherwise just @@ -49,7 +51,7 @@ public function getSupportedTypes($format): array // @deprecated remove condition when support for symfony versions under 6.3 is dropped if (!method_exists($this->decorated, 'getSupportedTypes')) { return [ - '*' => $this->decorated instanceof CacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(), + '*' => $this->decorated instanceof BaseCacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(), ]; } @@ -61,9 +63,16 @@ public function getSupportedTypes($format): array */ public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } - return $this->decorated instanceof CacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(); + return $this->decorated instanceof BaseCacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(); } /** diff --git a/src/Hal/Serializer/EntrypointNormalizer.php b/src/Hal/Serializer/EntrypointNormalizer.php index 93ab6ca21c5..6685581dd87 100644 --- a/src/Hal/Serializer/EntrypointNormalizer.php +++ b/src/Hal/Serializer/EntrypointNormalizer.php @@ -20,8 +20,9 @@ use ApiPlatform\Metadata\CollectionOperationInterface; use ApiPlatform\Metadata\Operation; use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Normalizes the API entrypoint. @@ -81,7 +82,14 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/Hal/Serializer/ObjectNormalizer.php b/src/Hal/Serializer/ObjectNormalizer.php index 7ef480aa8a8..2dfbf6d61bf 100644 --- a/src/Hal/Serializer/ObjectNormalizer.php +++ b/src/Hal/Serializer/ObjectNormalizer.php @@ -14,10 +14,12 @@ namespace ApiPlatform\Hal\Serializer; use ApiPlatform\Api\IriConverterInterface; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Exception\LogicException; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; +use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Decorates the output with JSON HAL metadata when appropriate, but otherwise @@ -44,7 +46,7 @@ public function getSupportedTypes($format): array // @deprecated remove condition when support for symfony versions under 6.3 is dropped if (!method_exists($this->decorated, 'getSupportedTypes')) { return [ - '*' => $this->decorated instanceof CacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(), + '*' => $this->decorated instanceof BaseCacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(), ]; } @@ -56,9 +58,16 @@ public function getSupportedTypes($format): array */ public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } - return $this->decorated instanceof CacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(); + return $this->decorated instanceof BaseCacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(); } /** diff --git a/src/Hydra/Serializer/CollectionFiltersNormalizer.php b/src/Hydra/Serializer/CollectionFiltersNormalizer.php index 11909f083b9..b40f390cd2b 100644 --- a/src/Hydra/Serializer/CollectionFiltersNormalizer.php +++ b/src/Hydra/Serializer/CollectionFiltersNormalizer.php @@ -18,12 +18,14 @@ use ApiPlatform\Api\ResourceClassResolverInterface; use ApiPlatform\Doctrine\Orm\State\Options; use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Psr\Container\ContainerInterface; use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; +use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Enhances the result of collection by adding the filters applied on collection. @@ -54,7 +56,7 @@ public function getSupportedTypes($format): array { // @deprecated remove condition when support for symfony versions under 6.3 is dropped if (!method_exists($this->collectionNormalizer, 'getSupportedTypes')) { - return ['*' => $this->collectionNormalizer instanceof CacheableSupportsMethodInterface && $this->collectionNormalizer->hasCacheableSupportsMethod()]; + return ['*' => $this->collectionNormalizer instanceof BaseCacheableSupportsMethodInterface && $this->collectionNormalizer->hasCacheableSupportsMethod()]; } return $this->collectionNormalizer->getSupportedTypes($format); @@ -62,9 +64,16 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } - return $this->collectionNormalizer instanceof CacheableSupportsMethodInterface && $this->collectionNormalizer->hasCacheableSupportsMethod(); + return $this->collectionNormalizer instanceof BaseCacheableSupportsMethodInterface && $this->collectionNormalizer->hasCacheableSupportsMethod(); } /** diff --git a/src/Hydra/Serializer/DocumentationNormalizer.php b/src/Hydra/Serializer/DocumentationNormalizer.php index f09e8d157a6..06fb60899e1 100644 --- a/src/Hydra/Serializer/DocumentationNormalizer.php +++ b/src/Hydra/Serializer/DocumentationNormalizer.php @@ -26,11 +26,12 @@ use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface; use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use ApiPlatform\Metadata\Resource\ResourceMetadataCollection; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Symfony\Component\PropertyInfo\Type; use Symfony\Component\Serializer\NameConverter\NameConverterInterface; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Creates a machine readable Hydra API documentation. @@ -551,7 +552,14 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/Hydra/Serializer/EntrypointNormalizer.php b/src/Hydra/Serializer/EntrypointNormalizer.php index 0f0f2ce4afb..4b011490aca 100644 --- a/src/Hydra/Serializer/EntrypointNormalizer.php +++ b/src/Hydra/Serializer/EntrypointNormalizer.php @@ -20,8 +20,9 @@ use ApiPlatform\Exception\OperationNotFoundException; use ApiPlatform\Metadata\CollectionOperationInterface; use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Normalizes the API entrypoint. @@ -90,7 +91,14 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/Hydra/Serializer/ErrorNormalizer.php b/src/Hydra/Serializer/ErrorNormalizer.php index 1b76b5c3953..d31c4a5d7b4 100644 --- a/src/Hydra/Serializer/ErrorNormalizer.php +++ b/src/Hydra/Serializer/ErrorNormalizer.php @@ -15,9 +15,10 @@ use ApiPlatform\Api\UrlGeneratorInterface; use ApiPlatform\Problem\Serializer\ErrorNormalizerTrait; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Symfony\Component\ErrorHandler\Exception\FlattenException; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Converts {@see \Exception} or {@see FlattenException} to a Hydra error representation. @@ -79,7 +80,14 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/Hydra/Serializer/PartialCollectionViewNormalizer.php b/src/Hydra/Serializer/PartialCollectionViewNormalizer.php index efd96212700..ebfe7fb793e 100644 --- a/src/Hydra/Serializer/PartialCollectionViewNormalizer.php +++ b/src/Hydra/Serializer/PartialCollectionViewNormalizer.php @@ -15,15 +15,17 @@ use ApiPlatform\Metadata\HttpOperation; use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use ApiPlatform\State\Pagination\PaginatorInterface; use ApiPlatform\State\Pagination\PartialPaginatorInterface; use ApiPlatform\Util\IriHelper; use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\Serializer\Exception\UnexpectedValueException; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; +use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Adds a view key to the result of a paginated Hydra collection. @@ -111,7 +113,7 @@ public function getSupportedTypes($format): array // @deprecated remove condition when support for symfony versions under 6.3 is dropped if (!method_exists($this->collectionNormalizer, 'getSupportedTypes')) { return [ - '*' => $this->collectionNormalizer instanceof CacheableSupportsMethodInterface && $this->collectionNormalizer->hasCacheableSupportsMethod(), + '*' => $this->collectionNormalizer instanceof BaseCacheableSupportsMethodInterface && $this->collectionNormalizer->hasCacheableSupportsMethod(), ]; } @@ -120,9 +122,16 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } - return $this->collectionNormalizer instanceof CacheableSupportsMethodInterface && $this->collectionNormalizer->hasCacheableSupportsMethod(); + return $this->collectionNormalizer instanceof BaseCacheableSupportsMethodInterface && $this->collectionNormalizer->hasCacheableSupportsMethod(); } /** diff --git a/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php b/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php index 60802039475..148119dd57c 100644 --- a/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php +++ b/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php @@ -14,9 +14,10 @@ namespace ApiPlatform\JsonApi\Serializer; use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\NameConverter\NameConverterInterface; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\ConstraintViolationListInterface; @@ -61,12 +62,19 @@ public function supportsNormalization(mixed $data, string $format = null, array public function getSupportedTypes($format): array { - return (self::FORMAT === $format) ? [ConstraintViolationListInterface::class => true] : []; + return self::FORMAT === $format ? [ConstraintViolationListInterface::class => true] : []; } public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/JsonApi/Serializer/EntrypointNormalizer.php b/src/JsonApi/Serializer/EntrypointNormalizer.php index 9feb1b6dc5f..849effbac07 100644 --- a/src/JsonApi/Serializer/EntrypointNormalizer.php +++ b/src/JsonApi/Serializer/EntrypointNormalizer.php @@ -20,8 +20,9 @@ use ApiPlatform\Metadata\CollectionOperationInterface; use ApiPlatform\Metadata\HttpOperation; use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Normalizes the API entrypoint. @@ -81,7 +82,14 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/JsonApi/Serializer/ErrorNormalizer.php b/src/JsonApi/Serializer/ErrorNormalizer.php index 52fddd5c167..2d4b26ad7eb 100644 --- a/src/JsonApi/Serializer/ErrorNormalizer.php +++ b/src/JsonApi/Serializer/ErrorNormalizer.php @@ -14,9 +14,10 @@ namespace ApiPlatform\JsonApi\Serializer; use ApiPlatform\Problem\Serializer\ErrorNormalizerTrait; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Symfony\Component\ErrorHandler\Exception\FlattenException; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Converts {@see \Exception} or {@see FlattenException} or to a JSON API error representation. @@ -81,7 +82,14 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/JsonApi/Serializer/ObjectNormalizer.php b/src/JsonApi/Serializer/ObjectNormalizer.php index da115f45db2..94fe5df46e1 100644 --- a/src/JsonApi/Serializer/ObjectNormalizer.php +++ b/src/JsonApi/Serializer/ObjectNormalizer.php @@ -17,8 +17,10 @@ use ApiPlatform\Api\ResourceClassResolverInterface; use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use ApiPlatform\Metadata\Util\ClassInfoTrait; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; +use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Decorates the output with JSON API metadata when appropriate, but otherwise @@ -47,7 +49,7 @@ public function getSupportedTypes($format): array // @deprecated remove condition when support for symfony versions under 6.3 is dropped if (!method_exists($this->decorated, 'getSupportedTypes')) { return [ - '*' => $this->decorated instanceof CacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(), + '*' => $this->decorated instanceof BaseCacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(), ]; } @@ -56,9 +58,16 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } - return $this->decorated instanceof CacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(); + return $this->decorated instanceof BaseCacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(); } /** diff --git a/src/JsonLd/Serializer/ObjectNormalizer.php b/src/JsonLd/Serializer/ObjectNormalizer.php index e21b8dbacfa..5b5bea2b0de 100644 --- a/src/JsonLd/Serializer/ObjectNormalizer.php +++ b/src/JsonLd/Serializer/ObjectNormalizer.php @@ -16,8 +16,10 @@ use ApiPlatform\Api\IriConverterInterface; use ApiPlatform\Exception\InvalidArgumentException; use ApiPlatform\JsonLd\AnonymousContextBuilderInterface; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; +use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Decorates the output with JSON-LD metadata when appropriate, but otherwise just @@ -46,7 +48,7 @@ public function getSupportedTypes($format): array // @deprecated remove condition when support for symfony versions under 6.3 is dropped if (!method_exists($this->decorated, 'getSupportedTypes')) { return [ - '*' => $this->decorated instanceof CacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(), + '*' => $this->decorated instanceof BaseCacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(), ]; } @@ -55,9 +57,16 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } - return $this->decorated instanceof CacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(); + return $this->decorated instanceof BaseCacheableSupportsMethodInterface && $this->decorated->hasCacheableSupportsMethod(); } /** diff --git a/src/OpenApi/Serializer/ApiGatewayNormalizer.php b/src/OpenApi/Serializer/ApiGatewayNormalizer.php index 2ffea4727f2..78b84c63ce1 100644 --- a/src/OpenApi/Serializer/ApiGatewayNormalizer.php +++ b/src/OpenApi/Serializer/ApiGatewayNormalizer.php @@ -14,8 +14,9 @@ namespace ApiPlatform\OpenApi\Serializer; use Symfony\Component\Serializer\Exception\UnexpectedValueException; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; +use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Removes features unsupported by Amazon API Gateway. @@ -124,7 +125,7 @@ public function getSupportedTypes($format): array { // @deprecated remove condition when support for symfony versions under 6.3 is dropped if (!method_exists($this->documentationNormalizer, 'getSupportedTypes')) { - return ['*' => $this->documentationNormalizer instanceof CacheableSupportsMethodInterface && $this->documentationNormalizer->hasCacheableSupportsMethod()]; + return ['*' => $this->documentationNormalizer instanceof BaseCacheableSupportsMethodInterface && $this->documentationNormalizer->hasCacheableSupportsMethod()]; } return $this->documentationNormalizer->getSupportedTypes($format); @@ -135,9 +136,16 @@ public function getSupportedTypes($format): array */ public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } - return $this->documentationNormalizer instanceof CacheableSupportsMethodInterface && $this->documentationNormalizer->hasCacheableSupportsMethod(); + return $this->documentationNormalizer instanceof BaseCacheableSupportsMethodInterface && $this->documentationNormalizer->hasCacheableSupportsMethod(); } private function isLocalRef(string $ref): bool diff --git a/src/OpenApi/Serializer/CacheableSupportsMethodInterface.php b/src/OpenApi/Serializer/CacheableSupportsMethodInterface.php new file mode 100644 index 00000000000..f131ecdaea1 --- /dev/null +++ b/src/OpenApi/Serializer/CacheableSupportsMethodInterface.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\OpenApi\Serializer; + +use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface; +use Symfony\Component\Serializer\Serializer; + +if (method_exists(Serializer::class, 'getSupportedTypes')) { + /** + * Backward compatibility layer for getSupportedTypes(). + * + * @internal + * + * @author Kévin Dunglas + * + * @todo remove this interface when dropping support for Serializer < 6.3 + */ + interface CacheableSupportsMethodInterface + { + public function getSupportedTypes(?string $format): array; + } +} else { + /** + * Backward compatibility layer for NormalizerInterface::getSupportedTypes(). + * + * @internal + * + * @author Kévin Dunglas + * + * @todo remove this interface when dropping support for Serializer < 6.3 + */ + interface CacheableSupportsMethodInterface extends BaseCacheableSupportsMethodInterface + { + } +} diff --git a/src/OpenApi/Serializer/OpenApiNormalizer.php b/src/OpenApi/Serializer/OpenApiNormalizer.php index 1c0ed7cacff..83ebf63deca 100644 --- a/src/OpenApi/Serializer/OpenApiNormalizer.php +++ b/src/OpenApi/Serializer/OpenApiNormalizer.php @@ -17,8 +17,8 @@ use ApiPlatform\OpenApi\OpenApi; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Generates an OpenAPI v3 specification. @@ -82,7 +82,14 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/OpenApi/Tests/Serializer/ApiGatewayNormalizerTest.php b/src/OpenApi/Tests/Serializer/ApiGatewayNormalizerTest.php index 1e07ea49e88..37dc30516d1 100644 --- a/src/OpenApi/Tests/Serializer/ApiGatewayNormalizerTest.php +++ b/src/OpenApi/Tests/Serializer/ApiGatewayNormalizerTest.php @@ -23,6 +23,7 @@ use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; final class ApiGatewayNormalizerTest extends TestCase { @@ -34,14 +35,19 @@ final class ApiGatewayNormalizerTest extends TestCase public function testSupportsNormalization(): void { $normalizerProphecy = $this->prophesize(NormalizerInterface::class); - $normalizerProphecy->willImplement(CacheableSupportsMethodInterface::class); $normalizerProphecy->supportsNormalization(OpenApiNormalizer::FORMAT, OpenApi::class)->willReturn(true); - $normalizerProphecy->hasCacheableSupportsMethod()->willReturn(true); + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $normalizerProphecy->willImplement(CacheableSupportsMethodInterface::class); + $normalizerProphecy->hasCacheableSupportsMethod()->willReturn(true); + } $normalizer = new ApiGatewayNormalizer($normalizerProphecy->reveal()); $this->assertTrue($normalizer->supportsNormalization(OpenApiNormalizer::FORMAT, OpenApi::class)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalize(): void diff --git a/src/Problem/Serializer/ErrorNormalizer.php b/src/Problem/Serializer/ErrorNormalizer.php index da86321e69e..0bd6d9fd3e0 100644 --- a/src/Problem/Serializer/ErrorNormalizer.php +++ b/src/Problem/Serializer/ErrorNormalizer.php @@ -13,9 +13,10 @@ namespace ApiPlatform\Problem\Serializer; +use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use Symfony\Component\ErrorHandler\Exception\FlattenException; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Normalizes errors according to the API Problem spec (RFC 7807). @@ -80,7 +81,14 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/Serializer/AbstractCollectionNormalizer.php b/src/Serializer/AbstractCollectionNormalizer.php index 47b6ff76bba..9397f4090d7 100644 --- a/src/Serializer/AbstractCollectionNormalizer.php +++ b/src/Serializer/AbstractCollectionNormalizer.php @@ -18,7 +18,6 @@ use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use ApiPlatform\State\Pagination\PaginatorInterface; use ApiPlatform\State\Pagination\PartialPaginatorInterface; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -56,7 +55,14 @@ public function supportsNormalization(mixed $data, string $format = null, array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/Serializer/AbstractConstraintViolationListNormalizer.php b/src/Serializer/AbstractConstraintViolationListNormalizer.php index 8f920c723a0..45eca2ef9bd 100644 --- a/src/Serializer/AbstractConstraintViolationListNormalizer.php +++ b/src/Serializer/AbstractConstraintViolationListNormalizer.php @@ -15,8 +15,8 @@ use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface; use Symfony\Component\Serializer\NameConverter\NameConverterInterface; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationListInterface; @@ -53,7 +53,14 @@ public function getSupportedTypes($format): array public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/Serializer/AbstractItemNormalizer.php b/src/Serializer/AbstractItemNormalizer.php index 9905110ce7c..5ce92695d54 100644 --- a/src/Serializer/AbstractItemNormalizer.php +++ b/src/Serializer/AbstractItemNormalizer.php @@ -42,6 +42,7 @@ use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * Base item normalizer. @@ -89,9 +90,7 @@ public function supportsNormalization(mixed $data, string $format = null, array public function getSupportedTypes(?string $format): array { - return [ - '*' => true, - ]; + return ['*' => true]; } /** @@ -99,7 +98,14 @@ public function getSupportedTypes(?string $format): array */ public function hasCacheableSupportsMethod(): bool { - trigger_deprecation('api-platform/core', '3.1', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + trigger_deprecation( + 'api-platform/core', + '3.1', + 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', + __METHOD__ + ); + } return true; } diff --git a/src/Serializer/CacheableSupportsMethodInterface.php b/src/Serializer/CacheableSupportsMethodInterface.php new file mode 100644 index 00000000000..6fb8e0c6214 --- /dev/null +++ b/src/Serializer/CacheableSupportsMethodInterface.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Serializer; + +use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface; +use Symfony\Component\Serializer\Serializer; + +if (method_exists(Serializer::class, 'getSupportedTypes')) { + /** + * Backward compatibility layer for getSupportedTypes(). + * + * @internal + * + * @author Kévin Dunglas + * + * @todo remove this interface when dropping support for Serializer < 6.3 + */ + interface CacheableSupportsMethodInterface + { + public function getSupportedTypes(?string $format): array; + } +} else { + /** + * Backward compatibility layer for NormalizerInterface::getSupportedTypes(). + * + * @internal + * + * @author Kévin Dunglas + * + * @todo remove this interface when dropping support for Serializer < 6.3 + */ + interface CacheableSupportsMethodInterface extends BaseCacheableSupportsMethodInterface + { + public function getSupportedTypes(?string $format): array; + } +} diff --git a/tests/Elasticsearch/Serializer/ItemNormalizerTest.php b/tests/Elasticsearch/Serializer/ItemNormalizerTest.php index c29e482f241..554e0ccc08a 100644 --- a/tests/Elasticsearch/Serializer/ItemNormalizerTest.php +++ b/tests/Elasticsearch/Serializer/ItemNormalizerTest.php @@ -22,6 +22,7 @@ use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\SerializerAwareInterface; use Symfony\Component\Serializer\SerializerInterface; @@ -34,15 +35,16 @@ final class ItemNormalizerTest extends TestCase protected function setUp(): void { - $this->itemNormalizer = new ItemNormalizer( - ( - $this->normalizerProphecy = $this - ->prophesize(NormalizerInterface::class) - ->willImplement(DenormalizerInterface::class) - ->willImplement(SerializerAwareInterface::class) - ->willImplement(CacheableSupportsMethodInterface::class) - )->reveal() - ); + $this->normalizerProphecy = $this + ->prophesize(NormalizerInterface::class) + ->willImplement(DenormalizerInterface::class) + ->willImplement(SerializerAwareInterface::class); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->normalizerProphecy->willImplement(CacheableSupportsMethodInterface::class); + } + + $this->itemNormalizer = new ItemNormalizer($this->normalizerProphecy->reveal()); } public function testConstruct(): void @@ -50,11 +52,17 @@ public function testConstruct(): void self::assertInstanceOf(NormalizerInterface::class, $this->itemNormalizer); self::assertInstanceOf(DenormalizerInterface::class, $this->itemNormalizer); self::assertInstanceOf(SerializerAwareInterface::class, $this->itemNormalizer); - self::assertInstanceOf(CacheableSupportsMethodInterface::class, $this->itemNormalizer); } + /** + * @group legacy + */ public function testHasCacheableSupportsMethod(): void { + if (method_exists(Serializer::class, 'getSupportedTypes')) { + $this->markTestSkipped('Symfony Serializer >= 6.3'); + } + $this->normalizerProphecy->hasCacheableSupportsMethod()->willReturn(true)->shouldBeCalledOnce(); self::assertTrue($this->itemNormalizer->hasCacheableSupportsMethod()); @@ -99,6 +107,9 @@ public function testSetSerializer(): void $this->itemNormalizer->setSerializer($serializer); } + /** + * @group legacy + */ public function testHasCacheableSupportsMethodWithDecoratedNormalizerNotAnInstanceOfCacheableSupportsMethodInterface(): void { $this->expectException(LogicException::class); @@ -130,4 +141,16 @@ public function testSetSerializerWithDecoratedNormalizerNotAnInstanceOfSerialize (new ItemNormalizer($this->prophesize(NormalizerInterface::class)->reveal()))->setSerializer($this->prophesize(SerializerInterface::class)->reveal()); } + + public function testGetSupportedTypes(): void + { + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->markTestSkipped('Symfony Serializer < 6.3'); + } + + $this->normalizerProphecy->getSupportedTypes(Argument::any())->willReturn(['*' => true]); + + $this->assertEmpty($this->itemNormalizer->getSupportedTypes('json')); + $this->assertSame(['*' => true], $this->itemNormalizer->getSupportedTypes($this->itemNormalizer::FORMAT)); + } } diff --git a/tests/Hal/Serializer/CollectionNormalizerTest.php b/tests/Hal/Serializer/CollectionNormalizerTest.php index 2b919476278..d30cf4d4d6b 100644 --- a/tests/Hal/Serializer/CollectionNormalizerTest.php +++ b/tests/Hal/Serializer/CollectionNormalizerTest.php @@ -25,6 +25,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * @author Kévin Dunglas @@ -48,7 +49,16 @@ public function testSupportsNormalize(): void $this->assertTrue($normalizer->supportsNormalization(new \ArrayObject(), CollectionNormalizer::FORMAT, ['resource_class' => 'Foo'])); $this->assertFalse($normalizer->supportsNormalization([], 'xml', ['resource_class' => 'Foo'])); $this->assertFalse($normalizer->supportsNormalization(new \ArrayObject(), 'xml', ['resource_class' => 'Foo'])); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame([ + 'native-array' => true, + '\Traversable' => true, + ], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalizePaginator(): void diff --git a/tests/Hal/Serializer/EntrypointNormalizerTest.php b/tests/Hal/Serializer/EntrypointNormalizerTest.php index 68a91bf4270..fc5b26e8bd9 100644 --- a/tests/Hal/Serializer/EntrypointNormalizerTest.php +++ b/tests/Hal/Serializer/EntrypointNormalizerTest.php @@ -26,6 +26,7 @@ use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Dummy; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +use Symfony\Component\Serializer\Serializer; /** * @author Kévin Dunglas @@ -51,7 +52,13 @@ public function testSupportNormalization(): void $this->assertTrue($normalizer->supportsNormalization($entrypoint, EntrypointNormalizer::FORMAT)); $this->assertFalse($normalizer->supportsNormalization($entrypoint, 'json')); $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), EntrypointNormalizer::FORMAT)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame([Entrypoint::class => true], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalize(): void diff --git a/tests/Hal/Serializer/ItemNormalizerTest.php b/tests/Hal/Serializer/ItemNormalizerTest.php index e58718705b6..93e49a018a5 100644 --- a/tests/Hal/Serializer/ItemNormalizerTest.php +++ b/tests/Hal/Serializer/ItemNormalizerTest.php @@ -95,10 +95,15 @@ public function testSupportsNormalization(): void $nameConverter->reveal() ); - $this->assertTrue($normalizer->supportsNormalization($dummy, 'jsonhal')); + $this->assertTrue($normalizer->supportsNormalization($dummy, $normalizer::FORMAT)); $this->assertFalse($normalizer->supportsNormalization($dummy, 'xml')); - $this->assertFalse($normalizer->supportsNormalization($std, 'jsonhal')); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertFalse($normalizer->supportsNormalization($std, $normalizer::FORMAT)); + $this->assertEmpty($normalizer->getSupportedTypes('xml')); + $this->assertSame(['*' => true], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalize(): void diff --git a/tests/Hydra/Serializer/CollectionFiltersNormalizerTest.php b/tests/Hydra/Serializer/CollectionFiltersNormalizerTest.php index e8d9b2b87c3..2d8b3bc4a56 100644 --- a/tests/Hydra/Serializer/CollectionFiltersNormalizerTest.php +++ b/tests/Hydra/Serializer/CollectionFiltersNormalizerTest.php @@ -32,6 +32,7 @@ use Psr\Container\ContainerInterface; use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * @author Kévin Dunglas @@ -46,9 +47,13 @@ class CollectionFiltersNormalizerTest extends TestCase public function testSupportsNormalization(): void { $decoratedProphecy = $this->prophesize(NormalizerInterface::class); - $decoratedProphecy->willImplement(CacheableSupportsMethodInterface::class); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + $decoratedProphecy->getSupportedTypes(Argument::any())->willReturn(['*' => true]); + } else { + $decoratedProphecy->willImplement(CacheableSupportsMethodInterface::class); + $decoratedProphecy->hasCacheableSupportsMethod()->willReturn(true)->shouldBeCalled(); + } $decoratedProphecy->supportsNormalization('foo', 'abc', Argument::type('array'))->willReturn(true)->shouldBeCalled(); - $decoratedProphecy->hasCacheableSupportsMethod()->willReturn(true)->shouldBeCalled(); $normalizer = new CollectionFiltersNormalizer( $decoratedProphecy->reveal(), @@ -58,7 +63,12 @@ public function testSupportsNormalization(): void ); $this->assertTrue($normalizer->supportsNormalization('foo', 'abc')); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + + if (method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertSame(['*' => true], $normalizer->getSupportedTypes('jsonld')); + } else { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalizeNonResourceCollection(): void diff --git a/tests/Hydra/Serializer/CollectionNormalizerTest.php b/tests/Hydra/Serializer/CollectionNormalizerTest.php index df477860b2d..a479a5601c9 100644 --- a/tests/Hydra/Serializer/CollectionNormalizerTest.php +++ b/tests/Hydra/Serializer/CollectionNormalizerTest.php @@ -26,6 +26,7 @@ use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\SerializerInterface; /** @@ -55,7 +56,15 @@ public function testSupportsNormalize(): void $this->assertTrue($normalizer->supportsNormalization(new \ArrayObject(), CollectionNormalizer::FORMAT, ['resource_class' => 'Foo'])); $this->assertFalse($normalizer->supportsNormalization([], 'xml', ['resource_class' => 'Foo'])); $this->assertFalse($normalizer->supportsNormalization(new \ArrayObject(), 'xml', ['resource_class' => 'Foo'])); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertEmpty($normalizer->getSupportedTypes('xml')); + $this->assertSame([ + 'native-array' => true, + '\Traversable' => true, + ], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalizeResourceCollection(): void diff --git a/tests/Hydra/Serializer/ConstraintViolationNormalizerTest.php b/tests/Hydra/Serializer/ConstraintViolationNormalizerTest.php index f5b690a9a3c..5e50ce5f89d 100644 --- a/tests/Hydra/Serializer/ConstraintViolationNormalizerTest.php +++ b/tests/Hydra/Serializer/ConstraintViolationNormalizerTest.php @@ -20,9 +20,11 @@ use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface; use Symfony\Component\Serializer\NameConverter\NameConverterInterface; +use Symfony\Component\Serializer\Serializer; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\ConstraintViolationListInterface; /** * @author Kévin Dunglas @@ -44,7 +46,12 @@ public function testSupportNormalization(): void $this->assertTrue($normalizer->supportsNormalization(new ConstraintViolationList(), ConstraintViolationListNormalizer::FORMAT)); $this->assertFalse($normalizer->supportsNormalization(new ConstraintViolationList(), 'xml')); $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), ConstraintViolationListNormalizer::FORMAT)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame([ConstraintViolationListInterface::class => true], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } /** diff --git a/tests/Hydra/Serializer/DocumentationNormalizerTest.php b/tests/Hydra/Serializer/DocumentationNormalizerTest.php index 5bd6ccdbccd..b83fe60ea1c 100644 --- a/tests/Hydra/Serializer/DocumentationNormalizerTest.php +++ b/tests/Hydra/Serializer/DocumentationNormalizerTest.php @@ -35,6 +35,7 @@ use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\Serializer\Serializer; /** * @author Amrouche Hamza @@ -363,7 +364,12 @@ private function doTestNormalize($resourceMetadataFactory = null): void $this->assertEquals($expected, $documentationNormalizer->normalize($documentation)); $this->assertTrue($documentationNormalizer->supportsNormalization($documentation, 'jsonld')); $this->assertFalse($documentationNormalizer->supportsNormalization($documentation, 'hal')); - $this->assertTrue($documentationNormalizer->hasCacheableSupportsMethod()); + $this->assertEmpty($documentationNormalizer->getSupportedTypes('json')); + $this->assertSame([Documentation::class => true], $documentationNormalizer->getSupportedTypes($documentationNormalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($documentationNormalizer->hasCacheableSupportsMethod()); + } } public function testNormalizeInputOutputClass(): void diff --git a/tests/Hydra/Serializer/EntrypointNormalizerTest.php b/tests/Hydra/Serializer/EntrypointNormalizerTest.php index 4ac1d65b305..3e3513953c8 100644 --- a/tests/Hydra/Serializer/EntrypointNormalizerTest.php +++ b/tests/Hydra/Serializer/EntrypointNormalizerTest.php @@ -28,6 +28,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; +use Symfony\Component\Serializer\Serializer; /** * @author Kévin Dunglas @@ -53,7 +54,12 @@ public function testSupportNormalization(): void $this->assertTrue($normalizer->supportsNormalization($entrypoint, EntrypointNormalizer::FORMAT)); $this->assertFalse($normalizer->supportsNormalization($entrypoint, 'json')); $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), EntrypointNormalizer::FORMAT)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame([Entrypoint::class => true], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalizeWithResourceMetadata(): void diff --git a/tests/Hydra/Serializer/ErrorNormalizerTest.php b/tests/Hydra/Serializer/ErrorNormalizerTest.php index 9f1ad08014c..8b83d654d72 100644 --- a/tests/Hydra/Serializer/ErrorNormalizerTest.php +++ b/tests/Hydra/Serializer/ErrorNormalizerTest.php @@ -19,6 +19,7 @@ use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\ErrorHandler\Exception\FlattenException; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Serializer\Serializer; /** * @author Kévin Dunglas @@ -43,7 +44,15 @@ public function testSupportsNormalization(): void $this->assertTrue($normalizer->supportsNormalization(new FlattenException(), ErrorNormalizer::FORMAT)); $this->assertFalse($normalizer->supportsNormalization(new FlattenException(), 'xml')); $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), ErrorNormalizer::FORMAT)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame([ + \Exception::class => true, + FlattenException::class => true, + ], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } /** diff --git a/tests/Hydra/Serializer/PartialCollectionViewNormalizerTest.php b/tests/Hydra/Serializer/PartialCollectionViewNormalizerTest.php index 10da718f583..f6819e92b9d 100644 --- a/tests/Hydra/Serializer/PartialCollectionViewNormalizerTest.php +++ b/tests/Hydra/Serializer/PartialCollectionViewNormalizerTest.php @@ -28,6 +28,7 @@ use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * @author Kévin Dunglas @@ -164,14 +165,26 @@ private function normalizePaginator(bool $partial = false, bool $cursor = false) public function testSupportsNormalization(): void { $decoratedNormalizerProphecy = $this->prophesize(NormalizerInterface::class); - $decoratedNormalizerProphecy->willImplement(CacheableSupportsMethodInterface::class); + if (method_exists(Serializer::class, 'getSupportedTypes')) { + $decoratedNormalizerProphecy->getSupportedTypes('jsonld')->willReturn(['*' => true]); + $decoratedNormalizerProphecy->getSupportedTypes(Argument::any())->willReturn([]); + } else { + $decoratedNormalizerProphecy->willImplement(CacheableSupportsMethodInterface::class); + $decoratedNormalizerProphecy->hasCacheableSupportsMethod()->willReturn(true)->shouldBeCalled(); + } $decoratedNormalizerProphecy->supportsNormalization(Argument::any(), null, Argument::type('array'))->willReturn(true)->shouldBeCalled(); - $decoratedNormalizerProphecy->hasCacheableSupportsMethod()->willReturn(true)->shouldBeCalled(); + $resourceMetadataFactory = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class); $normalizer = new PartialCollectionViewNormalizer($decoratedNormalizerProphecy->reveal(), 'page', 'pagination', $resourceMetadataFactory->reveal()); $this->assertTrue($normalizer->supportsNormalization(new \stdClass())); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + + if (method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame(['*' => true], $normalizer->getSupportedTypes('jsonld')); + } else { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testSetNormalizer(): void diff --git a/tests/JsonApi/Serializer/CollectionNormalizerTest.php b/tests/JsonApi/Serializer/CollectionNormalizerTest.php index 87ac5b7352f..53adf6dadea 100644 --- a/tests/JsonApi/Serializer/CollectionNormalizerTest.php +++ b/tests/JsonApi/Serializer/CollectionNormalizerTest.php @@ -26,6 +26,7 @@ use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; /** * @author Amrouche Hamza @@ -50,7 +51,15 @@ public function testSupportsNormalize(): void $this->assertTrue($normalizer->supportsNormalization(new \ArrayObject(), CollectionNormalizer::FORMAT, ['resource_class' => 'Foo'])); $this->assertFalse($normalizer->supportsNormalization([], 'xml', ['resource_class' => 'Foo'])); $this->assertFalse($normalizer->supportsNormalization(new \ArrayObject(), 'xml', ['resource_class' => 'Foo'])); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame([ + 'native-array' => true, + '\Traversable' => true, + ], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalizePaginator(): void diff --git a/tests/JsonApi/Serializer/ConstraintViolationNormalizerTest.php b/tests/JsonApi/Serializer/ConstraintViolationNormalizerTest.php index 7c14b5d57be..3c38247aefc 100644 --- a/tests/JsonApi/Serializer/ConstraintViolationNormalizerTest.php +++ b/tests/JsonApi/Serializer/ConstraintViolationNormalizerTest.php @@ -22,8 +22,10 @@ use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\PropertyInfo\Type; use Symfony\Component\Serializer\NameConverter\NameConverterInterface; +use Symfony\Component\Serializer\Serializer; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\ConstraintViolationListInterface; /** * @author Baptiste Meyer @@ -45,7 +47,12 @@ public function testSupportNormalization(): void $this->assertTrue($normalizer->supportsNormalization(new ConstraintViolationList(), ConstraintViolationListNormalizer::FORMAT)); $this->assertFalse($normalizer->supportsNormalization(new ConstraintViolationList(), 'xml')); $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), ConstraintViolationListNormalizer::FORMAT)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame([ConstraintViolationListInterface::class => true], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalize(): void diff --git a/tests/JsonApi/Serializer/EntrypointNormalizerTest.php b/tests/JsonApi/Serializer/EntrypointNormalizerTest.php index 848adf8f6ea..53ac1b3389d 100644 --- a/tests/JsonApi/Serializer/EntrypointNormalizerTest.php +++ b/tests/JsonApi/Serializer/EntrypointNormalizerTest.php @@ -32,6 +32,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; +use Symfony\Component\Serializer\Serializer; /** * @author Amrouche Hamza @@ -57,7 +58,12 @@ public function testSupportNormalization(): void $this->assertTrue($normalizer->supportsNormalization($entrypoint, EntrypointNormalizer::FORMAT)); $this->assertFalse($normalizer->supportsNormalization($entrypoint, 'json')); $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), EntrypointNormalizer::FORMAT)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame([Entrypoint::class => true], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalize(): void diff --git a/tests/JsonApi/Serializer/ErrorNormalizerTest.php b/tests/JsonApi/Serializer/ErrorNormalizerTest.php index 5bc67633e62..a3e34b88dee 100644 --- a/tests/JsonApi/Serializer/ErrorNormalizerTest.php +++ b/tests/JsonApi/Serializer/ErrorNormalizerTest.php @@ -18,6 +18,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\ErrorHandler\Exception\FlattenException; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Serializer\Serializer; /** * @author Baptiste Meyer @@ -38,7 +39,15 @@ public function testSupportsNormalization(): void $this->assertTrue($normalizer->supportsNormalization(new FlattenException(), ErrorNormalizer::FORMAT)); $this->assertFalse($normalizer->supportsNormalization(new FlattenException(), 'xml')); $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), ErrorNormalizer::FORMAT)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame([ + \Exception::class => true, + FlattenException::class => true, + ], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } /** diff --git a/tests/Problem/Serializer/ConstraintViolationNormalizerTest.php b/tests/Problem/Serializer/ConstraintViolationNormalizerTest.php index 2b2a6ea90c6..1183126f0fb 100644 --- a/tests/Problem/Serializer/ConstraintViolationNormalizerTest.php +++ b/tests/Problem/Serializer/ConstraintViolationNormalizerTest.php @@ -19,9 +19,11 @@ use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface; use Symfony\Component\Serializer\NameConverter\NameConverterInterface; +use Symfony\Component\Serializer\Serializer; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\ConstraintViolationListInterface; /** * @author Kévin Dunglas @@ -41,7 +43,12 @@ public function testSupportNormalization(): void $this->assertTrue($normalizer->supportsNormalization(new ConstraintViolationList(), ConstraintViolationListNormalizer::FORMAT)); $this->assertFalse($normalizer->supportsNormalization(new ConstraintViolationList(), 'xml')); $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), ConstraintViolationListNormalizer::FORMAT)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame([ConstraintViolationListInterface::class => true], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } /** diff --git a/tests/Problem/Serializer/ErrorNormalizerTest.php b/tests/Problem/Serializer/ErrorNormalizerTest.php index 5c38af7aaa8..8494587e2d3 100644 --- a/tests/Problem/Serializer/ErrorNormalizerTest.php +++ b/tests/Problem/Serializer/ErrorNormalizerTest.php @@ -17,6 +17,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\ErrorHandler\Exception\FlattenException; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Serializer\Serializer; /** * @author Kévin Dunglas @@ -37,7 +38,15 @@ public function testSupportNormalization(): void $this->assertTrue($normalizer->supportsNormalization(new FlattenException(), ErrorNormalizer::FORMAT)); $this->assertFalse($normalizer->supportsNormalization(new FlattenException(), 'xml')); $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), ErrorNormalizer::FORMAT)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertEmpty($normalizer->getSupportedTypes('json')); + $this->assertSame([ + \Exception::class => true, + FlattenException::class => true, + ], $normalizer->getSupportedTypes($normalizer::FORMAT)); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalize(): void diff --git a/tests/Serializer/AbstractItemNormalizerTest.php b/tests/Serializer/AbstractItemNormalizerTest.php index d4ac401a2b4..2adef4a4078 100644 --- a/tests/Serializer/AbstractItemNormalizerTest.php +++ b/tests/Serializer/AbstractItemNormalizerTest.php @@ -40,6 +40,7 @@ use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\SerializerInterface; /** @@ -85,8 +86,12 @@ public function testSupportNormalizationAndSupportDenormalization(): void $this->assertFalse($normalizer->supportsNormalization($std)); $this->assertTrue($normalizer->supportsDenormalization($dummy, Dummy::class)); $this->assertFalse($normalizer->supportsDenormalization($std, \stdClass::class)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); $this->assertFalse($normalizer->supportsNormalization([])); + $this->assertSame(['*' => true], $normalizer->getSupportedTypes('any')); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalize(): void diff --git a/tests/Serializer/ItemNormalizerTest.php b/tests/Serializer/ItemNormalizerTest.php index 99c22a5b9fb..e21f4cd74fa 100644 --- a/tests/Serializer/ItemNormalizerTest.php +++ b/tests/Serializer/ItemNormalizerTest.php @@ -36,6 +36,7 @@ use Symfony\Component\Serializer\Exception\NotNormalizableValueException; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\SerializerInterface; /** @@ -77,7 +78,11 @@ public function testSupportNormalization(): void $this->assertTrue($normalizer->supportsDenormalization($dummy, Dummy::class)); $this->assertTrue($normalizer->supportsDenormalization($dummy, Dummy::class)); $this->assertFalse($normalizer->supportsDenormalization($std, \stdClass::class)); - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + $this->assertSame(['*' => true], $normalizer->getSupportedTypes('any')); + + if (!method_exists(Serializer::class, 'getSupportedTypes')) { + $this->assertTrue($normalizer->hasCacheableSupportsMethod()); + } } public function testNormalize(): void