Rector changes and immplementations of required methods

This commit is contained in:
2025-05-22 17:47:07 +02:00
parent 053b92b77c
commit 17db59d221
1138 changed files with 2656 additions and 2616 deletions

View File

@@ -20,7 +20,7 @@ use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
class AddressNormalizer implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface, NormalizerAwareInterface
{
use NormalizerAwareTrait;
@@ -53,7 +53,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
* @param Address $address
* @param string|null $format
*/
public function normalize($address, $format = null, array $context = [])
public function normalize($address, $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
{
if ($address instanceof Address) {
$data = [

View File

@@ -22,7 +22,7 @@ class CenterNormalizer implements DenormalizerInterface, NormalizerInterface
{
public function __construct(private readonly CenterRepository $repository) {}
public function denormalize($data, $type, $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = []): mixed
{
if (null === $data) {
return null;
@@ -49,7 +49,7 @@ class CenterNormalizer implements DenormalizerInterface, NormalizerInterface
return $center;
}
public function normalize($center, $format = null, array $context = [])
public function normalize($center, $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
{
/* @var Center $center */
return [
@@ -60,12 +60,12 @@ class CenterNormalizer implements DenormalizerInterface, NormalizerInterface
];
}
public function supportsDenormalization($data, $type, $format = null)
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return Center::class === $type;
}
public function supportsNormalization($data, $format = null): bool
public function supportsNormalization($data, $format = null, array $context = []): bool
{
return $data instanceof Center && 'json' === $format;
}

View File

@@ -24,7 +24,7 @@ class CollectionNormalizer implements NormalizerAwareInterface, NormalizerInterf
* @param Collection $collection
* @param string|null $format
*/
public function normalize($collection, $format = null, array $context = [])
public function normalize($collection, $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
{
$paginator = $collection->getPaginator();
@@ -41,7 +41,7 @@ class CollectionNormalizer implements NormalizerAwareInterface, NormalizerInterf
];
}
public function supportsNormalization($data, $format = null): bool
public function supportsNormalization($data, $format = null, array $context = []): bool
{
return $data instanceof Collection;
}

View File

@@ -19,7 +19,7 @@ use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
class CommentEmbeddableDocGenNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
class CommentEmbeddableDocGenNormalizer implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface, NormalizerAwareInterface
{
use NormalizerAwareTrait;

View File

@@ -18,11 +18,11 @@ use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface
class DateNormalizer implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface, DenormalizerInterface
{
public function __construct(private readonly RequestStack $requestStack, private readonly ParameterBagInterface $parameterBag) {}
public function denormalize($data, $type, $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = []): mixed
{
if (null === $data) {
return null;
@@ -51,7 +51,7 @@ class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInt
return $result;
}
public function normalize($date, $format = null, array $context = [])
public function normalize($date, $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
{
/* @var DateTimeInterface $date */
switch ($format) {
@@ -93,7 +93,7 @@ class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInt
throw new UnexpectedValueException("format not supported: {$format}");
}
public function supportsDenormalization($data, $type, $format = null): bool
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return \DateTimeInterface::class === $type
|| \DateTime::class === $type

View File

@@ -20,7 +20,7 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
/**
* Denormalize an object given a list of supported class.
*/
class DiscriminatedObjectDenormalizer implements ContextAwareDenormalizerInterface, DenormalizerAwareInterface
class DiscriminatedObjectDenormalizer implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface, DenormalizerAwareInterface
{
use DenormalizerAwareTrait;
@@ -35,7 +35,7 @@ class DiscriminatedObjectDenormalizer implements ContextAwareDenormalizerInterfa
*/
final public const TYPE = '@multi';
public function denormalize($data, $type, $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = []): mixed
{
foreach ($context[self::ALLOWED_TYPES] as $localType) {
if ($this->denormalizer->supportsDenormalization($data, $localType, $format)) {
@@ -50,7 +50,7 @@ class DiscriminatedObjectDenormalizer implements ContextAwareDenormalizerInterfa
throw new RuntimeException(sprintf('Could not find any denormalizer for those ALLOWED_TYPES: %s', \implode(', ', $context[self::ALLOWED_TYPES])), previous: $lastException ?? null);
}
public function supportsDenormalization($data, $type, $format = null, array $context = [])
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
if (self::TYPE !== $type) {
return false;

View File

@@ -21,7 +21,7 @@ class DoctrineExistingEntityNormalizer implements DenormalizerInterface
{
public function __construct(private readonly EntityManagerInterface $em, private readonly ClassMetadataFactoryInterface $serializerMetadataFactory) {}
public function denormalize($data, $type, $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = []): mixed
{
if (\array_key_exists(AbstractNormalizer::OBJECT_TO_POPULATE, $context)) {
return $context[AbstractNormalizer::OBJECT_TO_POPULATE];
@@ -31,7 +31,7 @@ class DoctrineExistingEntityNormalizer implements DenormalizerInterface
->find($data['id']);
}
public function supportsDenormalization($data, $type, $format = null)
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
if (false === \is_array($data)) {
return false;

View File

@@ -47,8 +47,19 @@ class EntityWorkflowAttachmentNormalizer implements NormalizerInterface, Normali
];
}
public function supportsNormalization($data, ?string $format = null)
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return 'json' === $format && $data instanceof EntityWorkflowAttachment;
}
public function getSupportedTypes(?string $format): array
{
if ('json' !== $format) {
return [];
}
return [
EntityWorkflowAttachment::class => true,
];
}
}

View File

@@ -30,7 +30,7 @@ class EntityWorkflowNormalizer implements NormalizerInterface, NormalizerAwareIn
*
* @return array
*/
public function normalize($object, ?string $format = null, array $context = [])
public function normalize($object, ?string $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
{
$workflow = $this->registry->get($object, $object->getWorkflowName());
$handler = $this->entityWorkflowManager->getHandler($object);
@@ -49,8 +49,19 @@ class EntityWorkflowNormalizer implements NormalizerInterface, NormalizerAwareIn
];
}
public function supportsNormalization($data, ?string $format = null): bool
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return $data instanceof EntityWorkflow && 'json' === $format;
}
public function getSupportedTypes(?string $format): array
{
if ('json' !== $format) {
return [];
}
return [
EntityWorkflow::class => true,
];
}
}

View File

@@ -75,7 +75,7 @@ class EntityWorkflowStepNormalizer implements NormalizerAwareInterface, Normaliz
return $data;
}
public function supportsNormalization($data, ?string $format = null): bool
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return $data instanceof EntityWorkflowStep && 'json' === $format;
}

View File

@@ -17,18 +17,18 @@ use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
class GenderDocGenNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
class GenderDocGenNormalizer implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface, NormalizerAwareInterface
{
use NormalizerAwareTrait;
public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
public function supportsNormalization($data, ?string $format = null, array $context = [])
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return $data instanceof Gender;
}
public function normalize($gender, ?string $format = null, array $context = [])
public function normalize($gender, ?string $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
{
return [
'id' => $gender->getId(),

View File

@@ -30,7 +30,7 @@ class NotificationNormalizer implements NormalizerAwareInterface, NormalizerInte
*
* @return array|\ArrayObject|bool|float|int|string|void|null
*/
public function normalize($object, ?string $format = null, array $context = [])
public function normalize($object, ?string $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
{
$entity = $this->entityManager
->getRepository($object->getRelatedEntityClass())
@@ -51,7 +51,7 @@ class NotificationNormalizer implements NormalizerAwareInterface, NormalizerInte
];
}
public function supportsNormalization($data, ?string $format = null)
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return $data instanceof Notification && 'json' === $format;
}

View File

@@ -19,7 +19,7 @@ use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
class PhonenumberNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface
class PhonenumberNormalizer implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface, DenormalizerInterface
{
private readonly string $defaultCarrierCode;
@@ -37,7 +37,7 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal
*
* @throws UnexpectedValueException
*/
public function denormalize($data, $type, $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = []): mixed
{
if ('' === trim((string) $data)) {
return null;
@@ -59,7 +59,7 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal
return $this->phoneNumberUtil->formatOutOfCountryCallingNumber($object, $this->defaultCarrierCode);
}
public function supportsDenormalization($data, $type, $format = null)
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return 'libphonenumber\PhoneNumber' === $type;
}

View File

@@ -17,7 +17,7 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
class PointNormalizer implements DenormalizerInterface
{
public function denormalize($data, $type, $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = []): mixed
{
if (!\is_array($data)) {
throw new InvalidArgumentException('point data is not an array. It should be an array of 2 coordinates.');
@@ -30,7 +30,7 @@ class PointNormalizer implements DenormalizerInterface
return Point::fromLonLat($data[0], $data[1]);
}
public function supportsDenormalization($data, $type, $format = null): bool
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return Point::class === $type;
}

View File

@@ -38,13 +38,20 @@ class PrivateCommentEmbeddableNormalizer implements NormalizerInterface, Denorma
return $object->getCommentForUser($this->security->getUser());
}
public function supportsDenormalization($data, string $type, ?string $format = null): bool
public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool
{
return PrivateCommentEmbeddable::class === $type;
}
public function supportsNormalization($data, ?string $format = null): bool
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return $data instanceof PrivateCommentEmbeddable;
}
public function getSupportedTypes(?string $format): array
{
return [
PrivateCommentEmbeddable::class => true,
];
}
}

View File

@@ -24,7 +24,7 @@ class UserGroupDenormalizer implements DenormalizerInterface
return $this->userGroupRepository->find($data['id']);
}
public function supportsDenormalization($data, string $type, ?string $format = null): bool
public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool
{
return UserGroup::class === $type
&& 'json' === $format

View File

@@ -19,7 +19,7 @@ class UserGroupNormalizer implements NormalizerInterface
{
public function __construct(private readonly UserGroupRenderInterface $userGroupRender) {}
public function normalize($object, ?string $format = null, array $context = [])
public function normalize($object, ?string $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
{
/* @var UserGroup $object */
@@ -34,8 +34,15 @@ class UserGroupNormalizer implements NormalizerInterface
];
}
public function supportsNormalization($data, ?string $format = null)
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return $data instanceof UserGroup;
}
public function getSupportedTypes(?string $format): array
{
return [
UserGroup::class => true,
];
}
}

View File

@@ -24,7 +24,7 @@ use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
class UserNormalizer implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface, NormalizerAwareInterface
{
use NormalizerAwareTrait;
@@ -48,7 +48,7 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
*
* @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
{
/** @var array{"chill:user:at_date"?: \DateTimeImmutable|\DateTime} $context */
/** @var User $object */