mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-04 20:39:40 +00:00
Rector changes and immplementations of required methods
This commit is contained in:
@@ -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 = [
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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(),
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user