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

@@ -21,11 +21,8 @@ use Symfony\Component\HttpFoundation\Request;
final class AsideActivityController extends CRUDController
{
private AsideActivityCategoryRepository $categoryRepository;
public function __construct(AsideActivityCategoryRepository $categoryRepository)
public function __construct(private AsideActivityCategoryRepository $categoryRepository)
{
$this->categoryRepository = $categoryRepository;
}
public function createEntity(string $action, Request $request): object

View File

@@ -24,11 +24,8 @@ use function random_int;
class LoadAsideActivity extends Fixture implements DependentFixtureInterface
{
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
public function __construct(private UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function getDependencies(): array

View File

@@ -114,10 +114,8 @@ class AsideActivityCategory
/**
* @Assert\Callback
*
* @param mixed $payload
*/
public function preventRecursiveParent(ExecutionContextInterface $context, $payload)
public function preventRecursiveParent(ExecutionContextInterface $context, mixed $payload)
{
if (!$this->hasParent()) {
return;

View File

@@ -20,14 +20,8 @@ use Symfony\Component\Form\FormBuilderInterface;
class ByActivityTypeAggregator implements AggregatorInterface
{
private AsideActivityCategoryRepository $asideActivityCategoryRepository;
private TranslatableStringHelper $translatableStringHelper;
public function __construct(AsideActivityCategoryRepository $asideActivityCategoryRepository, TranslatableStringHelper $translatableStringHelper)
public function __construct(private AsideActivityCategoryRepository $asideActivityCategoryRepository, private TranslatableStringHelper $translatableStringHelper)
{
$this->asideActivityCategoryRepository = $asideActivityCategoryRepository;
$this->translatableStringHelper = $translatableStringHelper;
}
public function addRole(): ?string

View File

@@ -22,14 +22,8 @@ use function in_array;
class ByUserJobAggregator implements AggregatorInterface
{
private TranslatableStringHelperInterface $translatableStringHelper;
private UserJobRepositoryInterface $userJobRepository;
public function __construct(UserJobRepositoryInterface $userJobRepository, TranslatableStringHelperInterface $translatableStringHelper)
public function __construct(private UserJobRepositoryInterface $userJobRepository, private TranslatableStringHelperInterface $translatableStringHelper)
{
$this->userJobRepository = $userJobRepository;
$this->translatableStringHelper = $translatableStringHelper;
}
public function addRole(): ?string

View File

@@ -22,14 +22,8 @@ use function in_array;
class ByUserScopeAggregator implements AggregatorInterface
{
private ScopeRepositoryInterface $scopeRepository;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(ScopeRepositoryInterface $scopeRepository, TranslatableStringHelperInterface $translatableStringHelper)
public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper)
{
$this->scopeRepository = $scopeRepository;
$this->translatableStringHelper = $translatableStringHelper;
}
public function addRole(): ?string

View File

@@ -23,12 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface;
class AvgAsideActivityDuration implements ExportInterface, GroupedExportInterface
{
private AsideActivityRepository $repository;
public function __construct(
AsideActivityRepository $repository
) {
$this->repository = $repository;
public function __construct(private AsideActivityRepository $repository)
{
}
public function buildForm(FormBuilderInterface $builder)

View File

@@ -23,12 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface;
class CountAsideActivity implements ExportInterface, GroupedExportInterface
{
private AsideActivityRepository $repository;
public function __construct(
AsideActivityRepository $repository
) {
$this->repository = $repository;
public function __construct(private AsideActivityRepository $repository)
{
}
public function buildForm(FormBuilderInterface $builder)

View File

@@ -34,40 +34,8 @@ use Symfony\Component\Form\FormBuilderInterface;
final class ListAsideActivity implements ListInterface, GroupedExportInterface
{
private AsideActivityCategoryRepository $asideActivityCategoryRepository;
private CategoryRender $categoryRender;
private CenterRepositoryInterface $centerRepository;
private DateTimeHelper $dateTimeHelper;
private EntityManagerInterface $em;
private ScopeRepositoryInterface $scopeRepository;
private TranslatableStringHelperInterface $translatableStringHelper;
private UserHelper $userHelper;
public function __construct(
EntityManagerInterface $em,
DateTimeHelper $dateTimeHelper,
UserHelper $userHelper,
ScopeRepositoryInterface $scopeRepository,
CenterRepositoryInterface $centerRepository,
AsideActivityCategoryRepository $asideActivityCategoryRepository,
CategoryRender $categoryRender,
TranslatableStringHelperInterface $translatableStringHelper
) {
$this->em = $em;
$this->dateTimeHelper = $dateTimeHelper;
$this->userHelper = $userHelper;
$this->scopeRepository = $scopeRepository;
$this->centerRepository = $centerRepository;
$this->asideActivityCategoryRepository = $asideActivityCategoryRepository;
$this->categoryRender = $categoryRender;
$this->translatableStringHelper = $translatableStringHelper;
public function __construct(private EntityManagerInterface $em, private DateTimeHelper $dateTimeHelper, private UserHelper $userHelper, private ScopeRepositoryInterface $scopeRepository, private CenterRepositoryInterface $centerRepository, private AsideActivityCategoryRepository $asideActivityCategoryRepository, private CategoryRender $categoryRender, private TranslatableStringHelperInterface $translatableStringHelper)
{
}
public function buildForm(FormBuilderInterface $builder)
@@ -91,86 +59,67 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
public function getLabels($key, array $values, $data)
{
switch ($key) {
case 'id':
case 'note':
return static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.aside_activity.' . $key;
}
return match ($key) {
'id', 'note' => static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.aside_activity.' . $key;
}
return $value ?? '';
};
return $value ?? '';
},
'duration' => static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.aside_activity.' . $key;
}
case 'duration':
return static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.aside_activity.' . $key;
}
if (null === $value) {
return '';
}
if (null === $value) {
return '';
}
if ($value instanceof DateTimeInterface) {
return $value->format('H:i:s');
}
if ($value instanceof DateTimeInterface) {
return $value->format('H:i:s');
}
return $value;
},
'createdAt', 'updatedAt', 'date' => $this->dateTimeHelper->getLabel('export.aside_activity.' . $key),
'agent_id', 'creator_id' => $this->userHelper->getLabel($key, $values, 'export.aside_activity.' . $key),
'aside_activity_type' => function ($value) {
if ('_header' === $value) {
return 'export.aside_activity.aside_activity_type';
}
return $value;
};
if (null === $value || '' === $value || null === $c = $this->asideActivityCategoryRepository->find($value)) {
return '';
}
case 'createdAt':
case 'updatedAt':
case 'date':
return $this->dateTimeHelper->getLabel('export.aside_activity.' . $key);
return $this->categoryRender->renderString($c, []);
},
'main_scope' => function ($value) {
if ('_header' === $value) {
return 'export.aside_activity.main_scope';
}
case 'agent_id':
case 'creator_id':
return $this->userHelper->getLabel($key, $values, 'export.aside_activity.' . $key);
if (null === $value || '' === $value || null === $c = $this->scopeRepository->find($value)) {
return '';
}
case 'aside_activity_type':
return function ($value) {
if ('_header' === $value) {
return 'export.aside_activity.aside_activity_type';
}
return $this->translatableStringHelper->localize($c->getName());
},
'main_center' => function ($value) {
if ('_header' === $value) {
return 'export.aside_activity.main_center';
}
if (null === $value || '' === $value || null === $c = $this->asideActivityCategoryRepository->find($value)) {
return '';
}
if (null === $value || '' === $value || null === $c = $this->centerRepository->find($value)) {
/** @var Center $c */
return '';
}
return $this->categoryRender->renderString($c, []);
};
case 'main_scope':
return function ($value) {
if ('_header' === $value) {
return 'export.aside_activity.main_scope';
}
if (null === $value || '' === $value || null === $c = $this->scopeRepository->find($value)) {
return '';
}
return $this->translatableStringHelper->localize($c->getName());
};
case 'main_center':
return function ($value) {
if ('_header' === $value) {
return 'export.aside_activity.main_center';
}
if (null === $value || '' === $value || null === $c = $this->centerRepository->find($value)) {
/** @var Center $c */
return '';
}
return $c->getName();
};
default:
throw new LogicException('this key is not supported : ' . $key);
}
return $c->getName();
},
default => throw new LogicException('this key is not supported : ' . $key),
};
}
public function getQueryKeys($data)

View File

@@ -23,12 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface;
class SumAsideActivityDuration implements ExportInterface, GroupedExportInterface
{
private AsideActivityRepository $repository;
public function __construct(
AsideActivityRepository $repository
) {
$this->repository = $repository;
public function __construct(private AsideActivityRepository $repository)
{
}
public function buildForm(FormBuilderInterface $builder)

View File

@@ -23,20 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface;
class ByActivityTypeFilter implements FilterInterface
{
private AsideActivityCategoryRepository $asideActivityTypeRepository;
private CategoryRender $categoryRender;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(
CategoryRender $categoryRender,
TranslatableStringHelperInterface $translatableStringHelper,
AsideActivityCategoryRepository $asideActivityTypeRepository
) {
$this->categoryRender = $categoryRender;
$this->asideActivityTypeRepository = $asideActivityTypeRepository;
$this->translatableStringHelper = $translatableStringHelper;
public function __construct(private CategoryRender $categoryRender, private TranslatableStringHelperInterface $translatableStringHelper, private AsideActivityCategoryRepository $asideActivityTypeRepository)
{
}
public function addRole(): ?string

View File

@@ -26,16 +26,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class ByDateFilter implements FilterInterface
{
protected TranslatorInterface $translator;
private RollingDateConverterInterface $rollingDateConverter;
public function __construct(
RollingDateConverterInterface $rollingDateConverter,
TranslatorInterface $translator
) {
$this->translator = $translator;
$this->rollingDateConverter = $rollingDateConverter;
public function __construct(private RollingDateConverterInterface $rollingDateConverter, protected TranslatorInterface $translator)
{
}
public function addRole(): ?string

View File

@@ -20,11 +20,8 @@ use Symfony\Component\Form\FormBuilderInterface;
class ByUserFilter implements FilterInterface
{
private UserRender $userRender;
public function __construct(UserRender $userRender)
public function __construct(private UserRender $userRender)
{
$this->userRender = $userRender;
}
public function addRole(): ?string

View File

@@ -22,11 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface;
class ByUserJobFilter implements FilterInterface
{
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(TranslatableStringHelperInterface $translatableStringHelper)
public function __construct(private TranslatableStringHelperInterface $translatableStringHelper)
{
$this->translatableStringHelper = $translatableStringHelper;
}
public function addRole(): ?string

View File

@@ -23,16 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface;
class ByUserScopeFilter implements FilterInterface
{
private ScopeRepositoryInterface $scopeRepository;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(
ScopeRepositoryInterface $scopeRepository,
TranslatableStringHelperInterface $translatableStringHelper
) {
$this->scopeRepository = $scopeRepository;
$this->translatableStringHelper = $translatableStringHelper;
public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper)
{
}
public function addRole(): ?string

View File

@@ -22,12 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface;
final class AsideActivityCategoryType extends AbstractType
{
private CategoryRender $categoryRender;
public function __construct(
CategoryRender $categoryRender
) {
$this->categoryRender = $categoryRender;
public function __construct(private CategoryRender $categoryRender)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -20,12 +20,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
final class PickAsideActivityCategoryType extends AbstractType
{
private CategoryRender $categoryRender;
public function __construct(
CategoryRender $categoryRender
) {
$this->categoryRender = $categoryRender;
public function __construct(private CategoryRender $categoryRender)
{
}
public function configureOptions(OptionsResolver $resolver)

View File

@@ -16,11 +16,8 @@ use Symfony\Component\Security\Core\Security;
final class AdminMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface
{
private Security $security;
public function __construct(Security $security)
public function __construct(private Security $security)
{
$this->security = $security;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)

View File

@@ -21,14 +21,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/
class SectionMenuBuilder implements LocalMenuBuilderInterface
{
public AuthorizationCheckerInterface $authorizationChecker;
protected TranslatorInterface $translator;
public function __construct(TranslatorInterface $translator, AuthorizationCheckerInterface $authorizationChecker)
public function __construct(protected TranslatorInterface $translator, public AuthorizationCheckerInterface $authorizationChecker)
{
$this->translator = $translator;
$this->authorizationChecker = $authorizationChecker;
}
/**

View File

@@ -27,14 +27,8 @@ final class CategoryRender implements ChillEntityRenderInterface
public const SEPERATOR_KEY = 'default.separator';
private EngineInterface $engine;
private TranslatableStringHelper $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine)
public function __construct(private TranslatableStringHelper $translatableStringHelper, private EngineInterface $engine)
{
$this->translatableStringHelper = $translatableStringHelper;
$this->engine = $engine;
}
public function buildParents(AsideActivityCategory $asideActivityCategory)