Skip to content

Commit

Permalink
Merge cda684d into 1a2ba1d
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRebeilleau committed Oct 27, 2021
2 parents 1a2ba1d + cda684d commit b84d8b5
Show file tree
Hide file tree
Showing 32 changed files with 58 additions and 22 deletions.
Expand Up @@ -78,7 +78,7 @@ public function supportsNormalization($data, $format = null): bool
*
* @throws LogicException
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
throw new LogicException(sprintf('%s is a write-only format.', self::FORMAT));
}
Expand Down
8 changes: 5 additions & 3 deletions src/Core/Bridge/Elasticsearch/Serializer/ItemNormalizer.php
Expand Up @@ -53,6 +53,8 @@ public function hasCacheableSupportsMethod(): bool
* {@inheritdoc}
*
* @throws LogicException
*
* @return mixed
*/
public function denormalize($data, $type, $format = null, array $context = [])
{
Expand All @@ -68,7 +70,7 @@ public function denormalize($data, $type, $format = null, array $context = [])
*
* @throws LogicException
*/
public function supportsDenormalization($data, $type, $format = null)
public function supportsDenormalization($data, $type, $format = null): bool
{
if (!$this->decorated instanceof DenormalizerInterface) {
throw new LogicException(sprintf('The decorated normalizer must be an instance of "%s".', DenormalizerInterface::class));
Expand All @@ -80,15 +82,15 @@ public function supportsDenormalization($data, $type, $format = null)
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
return $this->decorated->normalize($object, $format, $context);
}

/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = null)
public function supportsNormalization($data, $format = null): bool
{
return DocumentNormalizer::FORMAT !== $format && $this->decorated->supportsNormalization($data, $format);
}
Expand Down
Expand Up @@ -15,6 +15,7 @@

use ApiPlatform\Exception\InvalidIdentifierException;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Uid\AbstractUid;
use Symfony\Component\Uid\Uuid;

/**
Expand All @@ -24,6 +25,8 @@ final class UuidNormalizer implements DenormalizerInterface
{
/**
* {@inheritdoc}
*
* @return AbstractUid|Uuid
*/
public function denormalize($data, $class, $format = null, array $context = [])
{
Expand All @@ -37,7 +40,7 @@ public function denormalize($data, $class, $format = null, array $context = [])
/**
* {@inheritdoc}
*/
public function supportsDenormalization($data, $type, $format = null)
public function supportsDenormalization($data, $type, $format = null): bool
{
return \is_string($data) && is_a($type, Uuid::class, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Hal/Serializer/EntrypointNormalizer.php
Expand Up @@ -60,7 +60,7 @@ public function __construct($resourceMetadataFactory, $iriConverter, UrlGenerato
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
$entrypoint = ['_links' => ['self' => ['href' => $this->urlGenerator->generate('api_entrypoint')]]];

Expand Down
1 change: 1 addition & 0 deletions src/Core/Hal/Serializer/ItemNormalizer.php
Expand Up @@ -50,6 +50,7 @@ public function supportsNormalization($data, $format = null): bool

/**
* {@inheritdoc}
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
Expand Down
1 change: 1 addition & 0 deletions src/Core/Hal/Serializer/ObjectNormalizer.php
Expand Up @@ -60,6 +60,7 @@ public function hasCacheableSupportsMethod(): bool

/**
* {@inheritdoc}
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Hydra/Serializer/CollectionFiltersNormalizer.php
Expand Up @@ -74,7 +74,7 @@ public function hasCacheableSupportsMethod(): bool
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
$data = $this->collectionNormalizer->normalize($object, $format, $context);
if (!\is_array($data)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Hydra/Serializer/CollectionNormalizer.php
Expand Up @@ -75,7 +75,7 @@ public function supportsNormalization($data, $format = null): bool
*
* @param iterable $object
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
if (!isset($context['resource_class']) || isset($context['api_sub_level'])) {
return $this->normalizeRawCollection($object, $format, $context);
Expand Down
Expand Up @@ -38,7 +38,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator, array $serializ
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
[$messages, $violations] = $this->getMessagesAndViolations($object);

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Hydra/Serializer/DocumentationNormalizer.php
Expand Up @@ -86,7 +86,7 @@ public function __construct($resourceMetadataFactory, PropertyNameCollectionFact
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
$classes = [];
$entrypointProperties = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Hydra/Serializer/EntrypointNormalizer.php
Expand Up @@ -57,7 +57,7 @@ public function __construct($resourceMetadataFactory, $iriConverter, UrlGenerato
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
$entrypoint = [
'@context' => $this->urlGenerator->generate('api_jsonld_context', ['shortName' => 'Entrypoint']),
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Hydra/Serializer/ErrorNormalizer.php
Expand Up @@ -47,7 +47,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator, bool $debug = f
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
$data = [
'@context' => $this->urlGenerator->generate('api_jsonld_context', ['shortName' => 'Error']),
Expand Down
Expand Up @@ -56,7 +56,7 @@ public function __construct(NormalizerInterface $collectionNormalizer, string $p
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
$data = $this->collectionNormalizer->normalize($object, $format, $context);
if (!\is_array($data)) {
Expand Down
Expand Up @@ -44,7 +44,7 @@ public function __construct($propertyMetadataFactory, NameConverterInterface $na
$this->nameConverter = $nameConverter;
}

public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
$violations = [];
foreach ($object as $violation) {
Expand Down
2 changes: 1 addition & 1 deletion src/Core/JsonApi/Serializer/EntrypointNormalizer.php
Expand Up @@ -57,7 +57,7 @@ public function __construct($resourceMetadataFactory, $iriConverter, UrlGenerato
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
$entrypoint = ['links' => ['self' => $this->urlGenerator->generate('api_entrypoint', [], UrlGeneratorInterface::ABS_URL)]];

Expand Down
2 changes: 1 addition & 1 deletion src/Core/JsonApi/Serializer/ErrorNormalizer.php
Expand Up @@ -42,7 +42,7 @@ public function __construct(bool $debug = false, array $defaultContext = [])
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
}

public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
$data = [
'title' => $context[self::TITLE] ?? $this->defaultContext[self::TITLE],
Expand Down
2 changes: 2 additions & 0 deletions src/Core/JsonApi/Serializer/ItemNormalizer.php
Expand Up @@ -66,6 +66,8 @@ public function supportsNormalization($data, $format = null): bool

/**
* {@inheritdoc}
*
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
Expand Down
2 changes: 2 additions & 0 deletions src/Core/JsonApi/Serializer/ObjectNormalizer.php
Expand Up @@ -79,6 +79,8 @@ public function hasCacheableSupportsMethod(): bool

/**
* {@inheritdoc}
*
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
Expand Down
2 changes: 2 additions & 0 deletions src/Core/JsonLd/Serializer/ItemNormalizer.php
Expand Up @@ -69,6 +69,8 @@ public function supportsNormalization($data, $format = null): bool
* {@inheritdoc}
*
* @throws LogicException
*
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
Expand Down
2 changes: 2 additions & 0 deletions src/Core/JsonLd/Serializer/ObjectNormalizer.php
Expand Up @@ -63,6 +63,8 @@ public function hasCacheableSupportsMethod(): bool

/**
* {@inheritdoc}
*
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
Expand Down
Expand Up @@ -44,7 +44,7 @@ public function __construct(array $serializePayloadFields = null, NameConverterI
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
[$messages, $violations] = $this->getMessagesAndViolations($object);

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Problem/Serializer/ErrorNormalizer.php
Expand Up @@ -47,7 +47,7 @@ public function __construct(bool $debug = false, array $defaultContext = [])
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
$data = [
'type' => $context[self::TYPE] ?? $this->defaultContext[self::TYPE],
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Serializer/AbstractCollectionNormalizer.php
Expand Up @@ -78,7 +78,7 @@ public function hasCacheableSupportsMethod(): bool
*
* @param iterable $object
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
if (!isset($context['resource_class']) || isset($context['api_sub_level'])) {
return $this->normalizeRawCollection($object, $format, $context);
Expand Down
4 changes: 4 additions & 0 deletions src/Core/Serializer/AbstractItemNormalizer.php
Expand Up @@ -145,6 +145,8 @@ public function hasCacheableSupportsMethod(): bool
* {@inheritdoc}
*
* @throws LogicException
*
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
Expand Down Expand Up @@ -408,6 +410,8 @@ protected function extractAttributes($object, $format = null, array $context = [

/**
* {@inheritdoc}
*
* @return array|bool
*/
protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Swagger/Serializer/ApiGatewayNormalizer.php
Expand Up @@ -45,6 +45,8 @@ public function __construct(NormalizerInterface $documentationNormalizer, $defau
* {@inheritdoc}
*
* @throws UnexpectedValueException
*
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Swagger/Serializer/DocumentationNormalizer.php
Expand Up @@ -189,7 +189,7 @@ public function __construct($resourceMetadataFactory, PropertyNameCollectionFact
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
if ($object instanceof OpenApi) {
@trigger_error('Using the swagger DocumentationNormalizer is deprecated in favor of decorating the OpenApiFactory, use the "openapi.backward_compatibility_layer" configuration to change this behavior.', \E_USER_DEPRECATED);
Expand Down
4 changes: 4 additions & 0 deletions src/GraphQl/Serializer/ItemNormalizer.php
Expand Up @@ -67,6 +67,8 @@ public function supportsNormalization($data, $format = null): bool
* {@inheritdoc}
*
* @throws UnexpectedValueException
*
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
Expand Down Expand Up @@ -110,6 +112,8 @@ public function supportsDenormalization($data, $type, $format = null): bool

/**
* {@inheritdoc}
*
* @return array|bool
*/
protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false)
{
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQl/Serializer/ObjectNormalizer.php
Expand Up @@ -68,7 +68,7 @@ public function hasCacheableSupportsMethod(): bool
*
* @throws UnexpectedValueException
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array
{
if (isset($context['api_resource'])) {
$originalResource = $context['api_resource'];
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Command/DebugResourceCommand.php
Expand Up @@ -50,7 +50,7 @@ protected function configure(): void
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$resourceClass = $input->getArgument('class');

Expand Down
Expand Up @@ -42,6 +42,8 @@ public function __construct(IriConverterInterface $iriConverter)

/**
* {@inheritdoc}
*
* @return mixed
*/
public function denormalize($data, $class, $format = null, array $context = [])
{
Expand Down
Expand Up @@ -45,6 +45,8 @@ public function __construct(IriConverterInterface $iriConverter)

/**
* {@inheritdoc}
*
* @return mixed
*/
public function denormalize($data, $class, $format = null, array $context = [])
{
Expand Down
Expand Up @@ -28,6 +28,13 @@ public function __construct(NormalizerInterface $documentationNormalizer)
$this->documentationNormalizer = $documentationNormalizer;
}

/**
* @param mixed $object
* @param null $format
* @param array $context
* @return array|\ArrayObject|bool|float|int|string|null
* @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
*/
public function normalize($object, $format = null, array $context = [])
{
$data = $this->documentationNormalizer->normalize($object, $format, $context);
Expand Down

0 comments on commit b84d8b5

Please sign in to comment.