Skip to content

Commit

Permalink
Merge 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed May 30, 2024
2 parents e5928a0 + 487b596 commit 73a4c32
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ parameters:
- '#Class Symfony\\Component\\Serializer\\Normalizer\\CacheableSupportsMethodInterface not found\.#'
- '#Access to undefined constant Symfony\\Component\\HttpKernel\\HttpKernelInterface::MASTER_REQUEST\.#'
- '#Attribute class PHPUnit\\Framework\\Attributes\\DataProvider does not exist.#'
# Because of a bc-layer in MetadataAwareNameConverter it does not implement AdvancedNameConverterInterface
- '#Instanceof between Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface\|null and Symfony\\Component\\Serializer\\NameConverter\\MetadataAwareNameConverter will always evaluate to false\.#'
- '#Instanceof between Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface and Symfony\\Component\\Serializer\\NameConverter\\MetadataAwareNameConverter will always evaluate to false\.#'
3 changes: 2 additions & 1 deletion src/GraphQl/Serializer/SerializerContextBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use ApiPlatform\Metadata\GraphQl\Subscription;
use GraphQL\Type\Definition\ResolveInfo;
use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface;
use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;

/**
Expand Down Expand Up @@ -101,7 +102,7 @@ private function denormalizePropertyName(string $property, ?string $resourceClas
if (null === $this->nameConverter) {
return $property;
}
if ($this->nameConverter instanceof AdvancedNameConverterInterface) {
if ($this->nameConverter instanceof AdvancedNameConverterInterface || $this->nameConverter instanceof MetadataAwareNameConverter) {
return $this->nameConverter->denormalize($property, $resourceClass, null, $context);
}

Expand Down
3 changes: 2 additions & 1 deletion src/GraphQl/Type/FieldsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface;
use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;

/**
Expand Down Expand Up @@ -682,7 +683,7 @@ private function normalizePropertyName(string $property, string $resourceClass):
if (null === $this->nameConverter) {
return $property;
}
if ($this->nameConverter instanceof AdvancedNameConverterInterface) {
if ($this->nameConverter instanceof AdvancedNameConverterInterface || $this->nameConverter instanceof MetadataAwareNameConverter) {
return $this->nameConverter->normalize($property, $resourceClass);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Serializer/AbstractConstraintViolationListNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace ApiPlatform\Serializer;

use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface;
use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Serializer;
Expand Down Expand Up @@ -76,7 +77,7 @@ protected function getMessagesAndViolations(ConstraintViolationListInterface $co
foreach ($constraintViolationList as $violation) {
$class = \is_object($root = $violation->getRoot()) ? $root::class : null;

if ($this->nameConverter instanceof AdvancedNameConverterInterface) {
if ($this->nameConverter instanceof AdvancedNameConverterInterface || $this->nameConverter instanceof MetadataAwareNameConverter) {
$propertyPath = $this->nameConverter->normalize($violation->getPropertyPath(), $class, static::FORMAT);
} elseif ($this->nameConverter instanceof NameConverterInterface) {
$propertyPath = $this->nameConverter->normalize($violation->getPropertyPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use ApiPlatform\Serializer\CacheableSupportsMethodInterface;
use ApiPlatform\Validator\Exception\ValidationException;
use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface;
use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Serializer;
Expand All @@ -32,7 +33,7 @@ public function normalize(mixed $object, ?string $format = null, array $context
foreach ($object->getConstraintViolationList() as $violation) {
$class = \is_object($root = $violation->getRoot()) ? $root::class : null;

if ($this->nameConverter instanceof AdvancedNameConverterInterface) {
if ($this->nameConverter instanceof AdvancedNameConverterInterface || $this->nameConverter instanceof MetadataAwareNameConverter) {
$propertyPath = $this->nameConverter->normalize($violation->getPropertyPath(), $class, $format);
} elseif ($this->nameConverter instanceof NameConverterInterface) {
$propertyPath = $this->nameConverter->normalize($violation->getPropertyPath());
Expand Down

0 comments on commit 73a4c32

Please sign in to comment.