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

@@ -17,7 +17,7 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
class ChillThirdPartyBundle extends Bundle
{
public function build(\Symfony\Component\DependencyInjection\ContainerBuilder $container)
public function build(\Symfony\Component\DependencyInjection\ContainerBuilder $container): void
{
parent::build($container);
$container->registerForAutoconfiguration(ThirdPartyTypeProviderInterface::class)

View File

@@ -20,7 +20,7 @@ class AdminController extends AbstractController
* ThirdParty admin.
*/
#[Route(path: '/{_locale}/admin/thirdparty', name: 'chill_thirdparty_admin_index')]
public function indexAdminAction()
public function indexAdminAction(): \Symfony\Component\HttpFoundation\Response
{
return $this->render('@ChillThirdParty/Admin/index.html.twig');
}

View File

@@ -90,7 +90,7 @@ final class ThirdPartyController extends CRUDController
return parent::createFormFor($action, $entity, $formClass, $formOptions);
}
protected function getQueryResult(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, ?FilterOrderHelper $filterOrder = null)
protected function getQueryResult(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, ?FilterOrderHelper $filterOrder = null): array
{
return $this->thirdPartyACLAwareRepository
->listThirdParties(

View File

@@ -33,7 +33,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
*/
class ChillThirdPartyExtension extends Extension implements PrependExtensionInterface
{
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
@@ -53,7 +53,7 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte
$loader->load('services/doctrineEventListener.yaml');
}
public function prepend(ContainerBuilder $container)
public function prepend(ContainerBuilder $container): void
{
$this->preprendRoutes($container);
$this->prependRoleHierarchy($container);

View File

@@ -24,7 +24,7 @@ class ThirdPartyTypeCompilerPass implements CompilerPassInterface
{
final public const TAG = 'chill_3party.provider';
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$definition = $container->getDefinition(ThirdPartyTypeManager::class);
$usedKeys = [];

View File

@@ -271,7 +271,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin
return $this;
}
public function addCenter(Center $center)
public function addCenter(Center $center): void
{
if (false === $this->centers->contains($center)) {
$this->centers->add($center);
@@ -519,7 +519,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin
return $this;
}
public function removeCenter(Center $center)
public function removeCenter(Center $center): void
{
if ($this->centers->contains($center)) {
$this->centers->removeElement($center);

View File

@@ -50,7 +50,7 @@ class ThirdPartyChoiceLoader implements ChoiceLoaderInterface
return new ArrayChoiceList($this->lazyLoadedParties, $value);
}
public function loadChoicesForValues($values, $value = null)
public function loadChoicesForValues($values, $value = null): array
{
$choices = [];
@@ -67,7 +67,7 @@ class ThirdPartyChoiceLoader implements ChoiceLoaderInterface
return $choices;
}
public function loadValuesForChoices(array $choices, $value = null)
public function loadValuesForChoices(array $choices, $value = null): array
{
$values = [];

View File

@@ -20,7 +20,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class ThirdPartyCategoryType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TranslatableStringFormType::class)
@@ -29,7 +29,7 @@ class ThirdPartyCategoryType extends AbstractType
]);
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver
->setDefault('class', ThirdPartyCategory::class);

View File

@@ -49,7 +49,7 @@ class ThirdPartyType extends AbstractType
$this->askCenter = $parameterBag->get('chill_main')['acl']['form_show_centers'];
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, [
@@ -152,7 +152,7 @@ class ThirdPartyType extends AbstractType
}
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => ThirdParty::class,

View File

@@ -63,7 +63,7 @@ class PickThirdPartyType extends AbstractType
$this->typesManager = $typesManager;
}
public function buildView(\Symfony\Component\Form\FormView $view, \Symfony\Component\Form\FormInterface $form, array $options)
public function buildView(\Symfony\Component\Form\FormView $view, \Symfony\Component\Form\FormInterface $form, array $options): void
{
$view->vars['attr']['class'] = \array_merge(['select2 '], $view->vars['attr']['class'] ?? []);
$view->vars['attr']['data-3party-picker'] = true;
@@ -82,7 +82,7 @@ class PickThirdPartyType extends AbstractType
$view->vars['attr']['data-searching-label'] = $this->translator->trans('select2.searching');
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver
->setRequired('center')

View File

@@ -26,7 +26,7 @@ class PickThirdPartyTypeCategoryType extends \Symfony\Component\Form\AbstractTyp
public function __construct(private readonly ThirdPartyCategoryRepository $thirdPartyCategoryRepository, private readonly ThirdPartyTypeManager $thirdPartyTypeManager, private readonly TranslatableStringHelper $translatableStringHelper, private readonly TranslatorInterface $translator) {}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$choices = \array_merge(
$this->thirdPartyCategoryRepository->findBy(['active' => true]),
@@ -57,7 +57,7 @@ class PickThirdPartyTypeCategoryType extends \Symfony\Component\Form\AbstractTyp
]);
}
public function getParent()
public function getParent(): ?string
{
return ChoiceType::class;
}

View File

@@ -28,12 +28,12 @@ class PickThirdpartyDynamicType extends AbstractType
{
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer) {}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addViewTransformer(new EntityToJsonTransformer($this->denormalizer, $this->serializer, $options['multiple'], 'thirdparty'));
}
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['multiple'] = $options['multiple'];
$view->vars['types'] = ['thirdparty'];
@@ -47,7 +47,7 @@ class PickThirdpartyDynamicType extends AbstractType
}
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver
->setDefault('multiple', false)
@@ -60,7 +60,7 @@ class PickThirdpartyDynamicType extends AbstractType
->setAllowedTypes('submit_on_adding_new_entity', ['bool']);
}
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return 'pick_entity_dynamic';
}

View File

@@ -27,7 +27,7 @@ class AdminMenuBuilder implements LocalMenuBuilderInterface
$this->authorizationChecker = $authorizationChecker;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
public function buildMenu($menuId, MenuItem $menu, array $parameters): void
{
if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) {
return;

View File

@@ -40,7 +40,7 @@ class MenuBuilder implements LocalMenuBuilderInterface
$this->translator = $translator;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
public function buildMenu($menuId, MenuItem $menu, array $parameters): void
{
if ($this->authorizationChecker->isGranted(ThirdPartyVoter::SHOW)) {
$menu

View File

@@ -212,7 +212,7 @@ class ThirdPartyRepository implements ObjectRepository
return $qb;
}
private function setIsActiveCondition(QueryBuilder $qb, array $terms)
private function setIsActiveCondition(QueryBuilder $qb, array $terms): void
{
if (\array_key_exists('is_active', $terms)) {
$qb->andWhere(
@@ -226,7 +226,7 @@ class ThirdPartyRepository implements ObjectRepository
* Add parameters to filter by containing $terms["name"] or
* $terms["_default"].
*/
private function setNameCondition(QueryBuilder $qb, array $terms)
private function setNameCondition(QueryBuilder $qb, array $terms): void
{
if (\array_key_exists('name', $terms) || \array_key_exists('_default', $terms)) {
$term = $terms['name'] ?? $terms['_default'];
@@ -239,7 +239,7 @@ class ThirdPartyRepository implements ObjectRepository
}
}
private function setTypesCondition(QueryBuilder $qb, array $terms)
private function setTypesCondition(QueryBuilder $qb, array $terms): void
{
if (\array_key_exists('types', $terms)) {
$orx = $qb->expr()->orX();

View File

@@ -46,7 +46,7 @@ class ThirdPartyApiSearch implements SearchApiInterface
{
public function __construct(private readonly ThirdPartyRepository $thirdPartyRepository) {}
public function getResult(string $key, array $metadata, float $pertinence)
public function getResult(string $key, array $metadata, float $pertinence): ?\Chill\ThirdPartyBundle\Entity\ThirdParty
{
return $this->thirdPartyRepository->find($metadata['id']);
}

View File

@@ -29,14 +29,8 @@ class ThirdPartyVoter extends AbstractChillVoter implements ProvideRoleHierarchy
final public const UPDATE = 'CHILL_3PARTY_3PARTY_UPDATE';
/**
* @var AuthorizationHelper
*/
protected $authorizationHelper;
public function __construct(AuthorizationHelper $authorizationHelper)
public function __construct(protected AuthorizationHelper $authorizationHelper)
{
$this->authorizationHelper = $authorizationHelper;
}
public function getRoles(): array
@@ -58,7 +52,7 @@ class ThirdPartyVoter extends AbstractChillVoter implements ProvideRoleHierarchy
return $this->getRoles();
}
protected function supports($attribute, $subject)
protected function supports(string $attribute, mixed $subject): bool
{
if ($subject instanceof ThirdParty) {
return \in_array($attribute, $this->getRoles(), true);
@@ -71,11 +65,7 @@ class ThirdPartyVoter extends AbstractChillVoter implements ProvideRoleHierarchy
return false;
}
/**
* @param string $attribute
* @param ThirdParty|null $subject
*/
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
{
return true;
$user = $token->getUser();

View File

@@ -26,7 +26,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
public function __construct(private readonly ThirdPartyRender $thirdPartyRender, private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
public function normalize($thirdParty, $format = null, array $context = [])
public function normalize($thirdParty, $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null
{
if (!$thirdParty instanceof ThirdParty) {
throw new UnexpectedValueException();
@@ -64,7 +64,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
];
}
public function supportsNormalization($data, $format = null)
public function supportsNormalization($data, $format = null, array $context = []): bool
{
return $data instanceof ThirdParty && 'json' === $format;
}

View File

@@ -23,7 +23,7 @@ final class ThirdPartyControllerTest extends WebTestCase
/**
* @doesNotPerformAssertions
*/
public function testIndex()
public function testIndex(): void
{
$client = self::createClient();
@@ -33,7 +33,7 @@ final class ThirdPartyControllerTest extends WebTestCase
/**
* @doesNotPerformAssertions
*/
public function testNew()
public function testNew(): void
{
$client = self::createClient();
@@ -43,7 +43,7 @@ final class ThirdPartyControllerTest extends WebTestCase
/**
* @doesNotPerformAssertions
*/
public function testUpdate()
public function testUpdate(): void
{
$client = self::createClient();

View File

@@ -22,7 +22,7 @@ use PHPUnit\Framework\TestCase;
*/
final class ThirdPartyTest extends TestCase
{
public function testAddingRemovingActivityTypes()
public function testAddingRemovingActivityTypes(): void
{
$tp = new ThirdParty();
$cat1 = new ThirdPartyCategory();
@@ -64,7 +64,7 @@ final class ThirdPartyTest extends TestCase
$this->assertNotContains('type', $tp->getTypesAndCategories());
}
public function testSyncingActivityTypes()
public function testSyncingActivityTypes(): void
{
$tp = new ThirdParty();
$tp->setTypesAndCategories([

View File

@@ -36,7 +36,7 @@ final class ThirdPartyDocGenNormalizerTest extends KernelTestCase
$this->phoneNumberUtil = PhoneNumberUtil::getInstance();
}
public function testAvoidRecursionWithNullParent()
public function testAvoidRecursionWithNullParent(): void
{
$thirdparty = new ThirdParty();
$thirdparty
@@ -88,7 +88,7 @@ final class ThirdPartyDocGenNormalizerTest extends KernelTestCase
$this->assertEquals('', $actual['parent']['acronym']);
}
public function testNormalize()
public function testNormalize(): void
{
$thirdparty = new ThirdParty();
$thirdparty

View File

@@ -31,7 +31,7 @@ final class ThirdPartyJsonDenormalizerTest extends KernelTestCase
$this->normalizer = self::getContainer()->get(DenormalizerInterface::class);
}
public function testDenormalizeContact()
public function testDenormalizeContact(): void
{
$str = <<<'JSON'
{