DX: apply rector rules up to php8.0

This commit is contained in:
2023-04-15 01:05:37 +02:00
parent d8870e906f
commit dde3002100
714 changed files with 2348 additions and 9263 deletions

View File

@@ -19,11 +19,8 @@ use Symfony\Component\Security\Core\Security;
final class PrivateCommentDataMapper extends AbstractType implements DataMapperInterface
{
private Security $security;
public function __construct(Security $security)
public function __construct(private Security $security)
{
$this->security = $security;
}
public function mapDataToForms($viewData, $forms)

View File

@@ -16,14 +16,8 @@ use Symfony\Component\Form\DataMapperInterface;
class ScopePickerDataMapper implements DataMapperInterface
{
/**
* @var \Chill\MainBundle\Entity\Scope
*/
private $scope;
public function __construct(?Scope $scope = null)
public function __construct(private ?Scope $scope = null)
{
$this->scope = $scope;
}
public function mapDataToForms($data, $forms)

View File

@@ -31,17 +31,11 @@ class IdToEntityDataTransformer implements DataTransformerInterface
{
private Closure $getId;
private bool $multiple = false;
private ObjectRepository $repository;
/**
* @param Closure $getId
*/
public function __construct(ObjectRepository $repository, bool $multiple = false, ?callable $getId = null)
public function __construct(private ObjectRepository $repository, private bool $multiple = false, ?callable $getId = null)
{
$this->repository = $repository;
$this->multiple = $multiple;
$this->getId = $getId ?? static fn (object $o) => $o->getId();
}

View File

@@ -17,14 +17,8 @@ class CustomizeFormEvent extends \Symfony\Component\EventDispatcher\Event
{
public const NAME = 'chill_main.customize_form';
protected FormBuilderInterface $builder;
protected string $type;
public function __construct(string $type, FormBuilderInterface $builder)
public function __construct(protected string $type, protected FormBuilderInterface $builder)
{
$this->type = $type;
$this->builder = $builder;
}
public function getBuilder(): FormBuilderInterface

View File

@@ -24,11 +24,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
final class LocationFormType extends AbstractType
{
private TranslatableStringHelper $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper)
public function __construct(private TranslatableStringHelper $translatableStringHelper)
{
$this->translatableStringHelper = $translatableStringHelper;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -43,18 +43,12 @@ class ComposedRoleScopeType extends AbstractType
*/
private $rolesWithoutScope = [];
/**
* @var TranslatableStringHelper
*/
private $translatableStringHelper;
public function __construct(
TranslatableStringHelper $translatableStringHelper,
private TranslatableStringHelper $translatableStringHelper,
RoleProvider $roleProvider
) {
$this->roles = $roleProvider->getRoles();
$this->rolesWithoutScope = $roleProvider->getRolesWithoutScopes();
$this->translatableStringHelper = $translatableStringHelper;
$this->roleProvider = $roleProvider;
}

View File

@@ -17,11 +17,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
final class AddressToIdDataTransformer implements DataTransformerInterface
{
private AddressRepository $addressRepository;
public function __construct(AddressRepository $addressRepository)
public function __construct(private AddressRepository $addressRepository)
{
$this->addressRepository = $addressRepository;
}
public function reverseTransform($value)

View File

@@ -23,16 +23,8 @@ use function count;
class CenterTransformer implements DataTransformerInterface
{
private CenterRepository $centerRepository;
private bool $multiple = false;
public function __construct(
CenterRepository $centerRepository,
bool $multiple = false
) {
$this->centerRepository = $centerRepository;
$this->multiple = $multiple;
public function __construct(private CenterRepository $centerRepository, private bool $multiple = false)
{
}
public function reverseTransform($id)

View File

@@ -25,20 +25,8 @@ use function array_key_exists;
class EntityToJsonTransformer implements DataTransformerInterface
{
private DenormalizerInterface $denormalizer;
private bool $multiple;
private SerializerInterface $serializer;
private string $type;
public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, bool $multiple, string $type)
public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private bool $multiple, private string $type)
{
$this->denormalizer = $denormalizer;
$this->serializer = $serializer;
$this->multiple = $multiple;
$this->type = $type;
}
public function reverseTransform($value)
@@ -87,25 +75,12 @@ class EntityToJsonTransformer implements DataTransformerInterface
throw new TransformationFailedException('the key "id" is missing on element');
}
switch ($this->type) {
case 'user':
$class = User::class;
break;
case 'person':
$class = Person::class;
break;
case 'thirdparty':
$class = ThirdParty::class;
break;
default:
throw new UnexpectedValueException('This type is not supported');
}
$class = match ($this->type) {
'user' => User::class,
'person' => Person::class,
'thirdparty' => ThirdParty::class,
default => throw new UnexpectedValueException('This type is not supported'),
};
return
$this->denormalizer->denormalize(

View File

@@ -17,14 +17,8 @@ use Symfony\Component\Form\DataTransformerInterface;
class MultipleObjectsToIdTransformer implements DataTransformerInterface
{
private ?string $class;
private EntityManagerInterface $em;
public function __construct(EntityManagerInterface $em, ?string $class = null)
public function __construct(private EntityManagerInterface $em, private ?string $class = null)
{
$this->em = $em;
$this->class = $class;
}
/**

View File

@@ -17,14 +17,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
class ObjectToIdTransformer implements DataTransformerInterface
{
private ?string $class;
private EntityManagerInterface $em;
public function __construct(EntityManagerInterface $em, ?string $class = null)
public function __construct(private EntityManagerInterface $em, private ?string $class = null)
{
$this->em = $em;
$this->class = $class;
}
/**
@@ -33,10 +27,8 @@ class ObjectToIdTransformer implements DataTransformerInterface
* @param string $id
*
* @throws TransformationFailedException if object is not found.
*
* @return object|null
*/
public function reverseTransform($id)
public function reverseTransform($id): ?object
{
if (null === $id) {
return null;

View File

@@ -20,11 +20,8 @@ use function is_int;
class PostalCodeToIdTransformer implements DataTransformerInterface
{
private PostalCodeRepositoryInterface $postalCodeRepository;
public function __construct(PostalCodeRepositoryInterface $postalCodeRepository)
public function __construct(private PostalCodeRepositoryInterface $postalCodeRepository)
{
$this->postalCodeRepository = $postalCodeRepository;
}
public function reverseTransform($value)

View File

@@ -18,11 +18,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
class ScopeTransformer implements DataTransformerInterface
{
private EntityManagerInterface $em;
public function __construct(EntityManagerInterface $em)
public function __construct(private EntityManagerInterface $em)
{
$this->em = $em;
}
public function reverseTransform($id)

View File

@@ -33,24 +33,15 @@ final class PickCenterType extends AbstractType
{
public const CENTERS_IDENTIFIERS = 'c';
private AuthorizationHelperInterface $authorizationHelper;
private ExportManager $exportManager;
private RegroupmentRepository $regroupmentRepository;
private UserInterface $user;
public function __construct(
TokenStorageInterface $tokenStorage,
ExportManager $exportManager,
RegroupmentRepository $regroupmentRepository,
AuthorizationHelperInterface $authorizationHelper
private ExportManager $exportManager,
private RegroupmentRepository $regroupmentRepository,
private AuthorizationHelperInterface $authorizationHelper
) {
$this->exportManager = $exportManager;
$this->user = $tokenStorage->getToken()->getUser();
$this->authorizationHelper = $authorizationHelper;
$this->regroupmentRepository = $regroupmentRepository;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -27,11 +27,8 @@ use function count;
final class FilterOrderType extends \Symfony\Component\Form\AbstractType
{
private RequestStack $requestStack;
public function __construct(RequestStack $requestStack)
public function __construct(private RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -43,16 +43,8 @@ use function uniqid;
*/
final class PickAddressType extends AbstractType
{
private AddressToIdDataTransformer $addressToIdDataTransformer;
private TranslatorInterface $translator;
public function __construct(
AddressToIdDataTransformer $addressToIdDataTransformer,
TranslatorInterface $translator
) {
$this->addressToIdDataTransformer = $addressToIdDataTransformer;
$this->translator = $translator;
public function __construct(private AddressToIdDataTransformer $addressToIdDataTransformer, private TranslatorInterface $translator)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -38,20 +38,8 @@ use function count;
*/
class PickCenterType extends AbstractType
{
protected AuthorizationHelperInterface $authorizationHelper;
protected CenterRepository $centerRepository;
protected Security $security;
public function __construct(
AuthorizationHelperInterface $authorizationHelper,
Security $security,
CenterRepository $centerRepository
) {
$this->authorizationHelper = $authorizationHelper;
$this->security = $security;
$this->centerRepository = $centerRepository;
public function __construct(protected AuthorizationHelperInterface $authorizationHelper, protected Security $security, protected CenterRepository $centerRepository)
{
}
/**

View File

@@ -21,11 +21,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickCivilityType extends AbstractType
{
private TranslatableStringHelper $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper)
public function __construct(private TranslatableStringHelper $translatableStringHelper)
{
$this->translatableStringHelper = $translatableStringHelper;
}
public function configureOptions(OptionsResolver $resolver)

View File

@@ -19,11 +19,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickLocationTypeType extends AbstractType
{
private TranslatableStringHelper $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper)
public function __construct(private TranslatableStringHelper $translatableStringHelper)
{
$this->translatableStringHelper = $translatableStringHelper;
}
public function configureOptions(OptionsResolver $resolver)

View File

@@ -21,11 +21,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickPostalCodeType extends AbstractType
{
private PostalCodeToIdTransformer $postalCodeToIdTransformer;
public function __construct(PostalCodeToIdTransformer $postalCodeToIdTransformer)
public function __construct(private PostalCodeToIdTransformer $postalCodeToIdTransformer)
{
$this->postalCodeToIdTransformer = $postalCodeToIdTransformer;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -27,17 +27,8 @@ use Symfony\Component\Serializer\SerializerInterface;
*/
class PickUserDynamicType extends AbstractType
{
private DenormalizerInterface $denormalizer;
private NormalizerInterface $normalizer;
private SerializerInterface $serializer;
public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, NormalizerInterface $normalizer)
public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private NormalizerInterface $normalizer)
{
$this->denormalizer = $denormalizer;
$this->serializer = $serializer;
$this->normalizer = $normalizer;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -20,14 +20,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PickUserLocationType extends AbstractType
{
private LocationRepository $locationRepository;
private TranslatableStringHelper $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper, LocationRepository $locationRepository)
public function __construct(private TranslatableStringHelper $translatableStringHelper, private LocationRepository $locationRepository)
{
$this->translatableStringHelper = $translatableStringHelper;
$this->locationRepository = $locationRepository;
}
public function configureOptions(OptionsResolver $resolver)

View File

@@ -24,14 +24,11 @@ use Symfony\Component\Security\Core\User\UserInterface;
class PrivateCommentType extends AbstractType
{
protected PrivateCommentDataMapper $dataMapper;
protected UserInterface $user;
public function __construct(TokenStorageInterface $tokenStorage, PrivateCommentDataMapper $dataMapper)
public function __construct(TokenStorageInterface $tokenStorage, protected PrivateCommentDataMapper $dataMapper)
{
$this->user = $tokenStorage->getToken()->getUser();
$this->dataMapper = $dataMapper;
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -42,20 +42,8 @@ use function count;
*/
class ScopePickerType extends AbstractType
{
private AuthorizationHelperInterface $authorizationHelper;
private Security $security;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(
AuthorizationHelperInterface $authorizationHelper,
Security $security,
TranslatableStringHelperInterface $translatableStringHelper
) {
$this->authorizationHelper = $authorizationHelper;
$this->security = $security;
$this->translatableStringHelper = $translatableStringHelper;
public function __construct(private AuthorizationHelperInterface $authorizationHelper, private Security $security, private TranslatableStringHelperInterface $translatableStringHelper)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -29,24 +29,8 @@ use const SORT_STRING;
*/
class Select2CountryType extends AbstractType
{
protected ParameterBagInterface $parameterBag;
protected TranslatableStringHelper $translatableStringHelper;
private ObjectManager $em;
private RequestStack $requestStack;
public function __construct(
RequestStack $requestStack,
ObjectManager $em,
TranslatableStringHelper $translatableStringHelper,
ParameterBagInterface $parameterBag
) {
$this->requestStack = $requestStack;
$this->em = $em;
$this->translatableStringHelper = $translatableStringHelper;
$this->parameterBag = $parameterBag;
public function __construct(private RequestStack $requestStack, private ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -29,24 +29,8 @@ use const SORT_STRING;
*/
class Select2LanguageType extends AbstractType
{
protected ParameterBagInterface $parameterBag;
protected TranslatableStringHelper $translatableStringHelper;
private ObjectManager $em;
private RequestStack $requestStack;
public function __construct(
RequestStack $requestStack,
ObjectManager $em,
TranslatableStringHelper $translatableStringHelper,
ParameterBagInterface $parameterBag
) {
$this->requestStack = $requestStack;
$this->em = $em;
$this->translatableStringHelper = $translatableStringHelper;
$this->parameterBag = $parameterBag;
public function __construct(private RequestStack $requestStack, private ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -24,13 +24,12 @@ use function in_array;
class TranslatableStringFormType extends AbstractType
{
private $availableLanguages; // The langauges availaible
// The langauges availaible
private $frameworkTranslatorFallback; // The langagues used for the translation
public function __construct(array $availableLanguages, Translator $translator)
public function __construct(private array $availableLanguages, Translator $translator)
{
$this->availableLanguages = $availableLanguages;
$this->frameworkTranslatorFallback = $translator->getFallbackLocales();
}

View File

@@ -44,24 +44,15 @@ class UserPickerType extends AbstractType
*/
protected $tokenStorage;
protected UserACLAwareRepositoryInterface $userACLAwareRepository;
protected UserRepository $userRepository;
private UserRender $userRender;
public function __construct(
AuthorizationHelper $authorizationHelper,
TokenStorageInterface $tokenStorage,
UserRepository $userRepository,
UserACLAwareRepositoryInterface $userACLAwareRepository,
UserRender $userRender
protected UserRepository $userRepository,
protected UserACLAwareRepositoryInterface $userACLAwareRepository,
private UserRender $userRender
) {
$this->authorizationHelper = $authorizationHelper;
$this->tokenStorage = $tokenStorage;
$this->userRepository = $userRepository;
$this->userACLAwareRepository = $userACLAwareRepository;
$this->userRender = $userRender;
}
public function configureOptions(OptionsResolver $resolver)

View File

@@ -35,16 +35,8 @@ use Symfony\Component\Validator\Constraints\Regex;
class UserType extends AbstractType
{
protected ParameterBagInterface $parameterBag;
private TranslatableStringHelper $translatableStringHelper;
public function __construct(
TranslatableStringHelper $translatableStringHelper,
ParameterBagInterface $parameterBag
) {
$this->translatableStringHelper = $translatableStringHelper;
$this->parameterBag = $parameterBag;
public function __construct(private TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -36,17 +36,8 @@ use function array_key_exists;
class WorkflowStepType extends AbstractType
{
private EntityWorkflowManager $entityWorkflowManager;
private Registry $registry;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(EntityWorkflowManager $entityWorkflowManager, Registry $registry, TranslatableStringHelperInterface $translatableStringHelper)
public function __construct(private EntityWorkflowManager $entityWorkflowManager, private Registry $registry, private TranslatableStringHelperInterface $translatableStringHelper)
{
$this->entityWorkflowManager = $entityWorkflowManager;
$this->registry = $registry;
$this->translatableStringHelper = $translatableStringHelper;
}
public function buildForm(FormBuilderInterface $builder, array $options)