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

@@ -47,40 +47,8 @@ use function array_merge;
final class SingleTaskController extends AbstractController
{
private CenterResolverDispatcherInterface $centerResolverDispatcher;
private EventDispatcherInterface $eventDispatcher;
private FilterOrderHelperFactoryInterface $filterOrderHelperFactory;
private LoggerInterface $logger;
private PaginatorFactory $paginatorFactory;
private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository;
private TimelineBuilder $timelineBuilder;
private TranslatorInterface $translator;
public function __construct(
CenterResolverDispatcherInterface $centerResolverDispatcher,
PaginatorFactory $paginatorFactory,
SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository,
TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher,
TimelineBuilder $timelineBuilder,
LoggerInterface $logger,
FilterOrderHelperFactoryInterface $filterOrderHelperFactory
) {
$this->eventDispatcher = $eventDispatcher;
$this->timelineBuilder = $timelineBuilder;
$this->logger = $logger;
$this->translator = $translator;
$this->centerResolverDispatcher = $centerResolverDispatcher;
$this->paginatorFactory = $paginatorFactory;
$this->singleTaskAclAwareRepository = $singleTaskAclAwareRepository;
$this->filterOrderHelperFactory = $filterOrderHelperFactory;
public function __construct(private CenterResolverDispatcherInterface $centerResolverDispatcher, private PaginatorFactory $paginatorFactory, private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, private TranslatorInterface $translator, private EventDispatcherInterface $eventDispatcher, private TimelineBuilder $timelineBuilder, private LoggerInterface $logger, private FilterOrderHelperFactoryInterface $filterOrderHelperFactory)
{
}
/**
@@ -88,10 +56,8 @@ final class SingleTaskController extends AbstractController
* "/{_locale}/task/single-task/{id}/delete",
* name="chill_task_single_task_delete"
* )
*
* @param mixed $id
*/
public function deleteAction(Request $request, $id)
public function deleteAction(Request $request, mixed $id)
{
$course = null;
$em = $this->getDoctrine()->getManager();
@@ -593,24 +559,19 @@ final class SingleTaskController extends AbstractController
}
}
switch ($entityType) {
case 'person':
return $this->render('@ChillTask/SingleTask/Person/new.html.twig', [
'form' => $form->createView(),
'task' => $task,
'person' => $task->getPerson(),
]);
case 'course':
return $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', [
'form' => $form->createView(),
'task' => $task,
'accompanyingCourse' => $task->getCourse(),
]);
default:
throw new LogicException('entity context not supported');
}
return match ($entityType) {
'person' => $this->render('@ChillTask/SingleTask/Person/new.html.twig', [
'form' => $form->createView(),
'task' => $task,
'person' => $task->getPerson(),
]),
'course' => $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', [
'form' => $form->createView(),
'task' => $task,
'accompanyingCourse' => $task->getCourse(),
]),
default => throw new LogicException('entity context not supported'),
};
}
/**
@@ -687,7 +648,7 @@ final class SingleTaskController extends AbstractController
* Creates a form to delete a Task entity by id.
* @param mixed $id
*/
private function createDeleteForm($id): FormInterface
private function createDeleteForm(mixed $id): FormInterface
{
return $this->createFormBuilder()
->setAction($this->generateUrl(

View File

@@ -30,11 +30,6 @@ class UIEvent extends Event
*/
protected $form;
/**
* @var string
*/
protected $kind;
/**
* @var Response|null
*/
@@ -50,16 +45,15 @@ class UIEvent extends Event
*/
protected $transition;
public function __construct($kind, AbstractTask $task)
/**
* @param string $kind
*/
public function __construct(protected $kind, AbstractTask $task)
{
$this->kind = $kind;
$this->task = $task;
}
/**
* @return FormInterface|null
*/
public function getForm()
public function getForm(): ?\Symfony\Component\Form\FormInterface
{
return $this->form;
}

View File

@@ -230,11 +230,10 @@ class SingleTaskListType extends AbstractType
/**
* Return a list of user having a task assigned.
*
* @param mixed $options
*
* @return User[]
*/
protected function getUsersAssigneedToTask($options)
protected function getUsersAssigneedToTask(mixed $options)
{
$qb = $this->em->createQueryBuilder();
$user = $this->tokenStorage->getToken()->getUser();

View File

@@ -28,20 +28,8 @@ use Symfony\Component\Security\Core\Role\Role;
class SingleTaskType extends AbstractType
{
private CenterResolverDispatcherInterface $centerResolverDispatcher;
private ParameterBagInterface $parameterBag;
private ScopeResolverDispatcher $scopeResolverDispatcher;
public function __construct(
ParameterBagInterface $parameterBag,
CenterResolverDispatcherInterface $centerResolverDispatcher,
ScopeResolverDispatcher $scopeResolverDispatcher
) {
$this->parameterBag = $parameterBag;
$this->centerResolverDispatcher = $centerResolverDispatcher;
$this->scopeResolverDispatcher = $scopeResolverDispatcher;
public function __construct(private ParameterBagInterface $parameterBag, private CenterResolverDispatcherInterface $centerResolverDispatcher, private ScopeResolverDispatcher $scopeResolverDispatcher)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -59,25 +59,12 @@ class MenuBuilder implements LocalMenuBuilderInterface
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
switch ($menuId) {
case 'person':
$this->buildPersonMenu($menu, $parameters);
break;
case 'accompanyingCourse':
$this->buildAccompanyingCourseMenu($menu, $parameters);
break;
case 'section':
$menu->setExtras('icons');
break;
default:
throw new LogicException("this menuid {$menuId} is not implemented");
}
match ($menuId) {
'person' => $this->buildPersonMenu($menu, $parameters),
'accompanyingCourse' => $this->buildAccompanyingCourseMenu($menu, $parameters),
'section' => $menu->setExtras('icons'),
default => throw new LogicException("this menuid {$menuId} is not implemented"),
};
}
public function buildPersonMenu($menu, $parameters)

View File

@@ -29,24 +29,8 @@ use function substr;
final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepositoryInterface
{
private AuthorizationHelperInterface $authorizationHelper;
private CenterResolverManagerInterface $centerResolverDispatcher;
private EntityManagerInterface $em;
private Security $security;
public function __construct(
CenterResolverManagerInterface $centerResolverDispatcher,
EntityManagerInterface $em,
Security $security,
AuthorizationHelperInterface $authorizationHelper
) {
$this->centerResolverDispatcher = $centerResolverDispatcher;
$this->em = $em;
$this->security = $security;
$this->authorizationHelper = $authorizationHelper;
public function __construct(private CenterResolverManagerInterface $centerResolverDispatcher, private EntityManagerInterface $em, private Security $security, private AuthorizationHelperInterface $authorizationHelper)
{
}
public function buildBaseQuery(
@@ -119,7 +103,7 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
break;
case substr($flag, 0, 6) === 'state_':
case str_starts_with($flag, 'state_'):
$state = substr($flag, 6);
$orXState
->add(

View File

@@ -18,16 +18,6 @@ class AuthorizationEvent extends Event
{
public const VOTE = 'chill_task.vote';
/**
* @var string
*/
protected $attribute;
/**
* @var \Chill\PersonBundle\Entity\Person|Chill\TaskBundle\Entity\AbstractTask|null
*/
protected $subject;
/**
* @var TokenInterface
*/
@@ -38,13 +28,15 @@ class AuthorizationEvent extends Event
*/
protected $vote;
/**
* @param string $attribute
* @param \Chill\PersonBundle\Entity\Person|\Chill\TaskBundle\Entity\AbstractTask|null $subject
*/
public function __construct(
$subject,
$attribute,
protected \Chill\PersonBundle\Entity\Person|\Chill\TaskBundle\Security\Authorization\Chill\TaskBundle\Entity\AbstractTask|null $subject,
protected $attribute,
TokenInterface $token
) {
$this->subject = $subject;
$this->attribute = $attribute;
$this->token = $token;
}

View File

@@ -48,24 +48,14 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
public const UPDATE = 'CHILL_TASK_TASK_UPDATE';
private AccessDecisionManagerInterface $accessDecisionManager;
private EventDispatcherInterface $eventDispatcher;
private LoggerInterface $logger;
private VoterHelperInterface $voter;
public function __construct(
AccessDecisionManagerInterface $accessDecisionManager,
EventDispatcherInterface $eventDispatcher,
LoggerInterface $logger,
private AccessDecisionManagerInterface $accessDecisionManager,
private EventDispatcherInterface $eventDispatcher,
private LoggerInterface $logger,
VoterHelperFactoryInterface $voterFactory
) {
$this->accessDecisionManager = $accessDecisionManager;
$this->eventDispatcher = $eventDispatcher;
$this->logger = $logger;
$this->voter = $voterFactory
->generate(AbstractTask::class)
->addCheckFor(AbstractTask::class, self::ROLES)

View File

@@ -76,11 +76,9 @@ final class SingleTaskControllerTest extends WebTestCase
}
/**
* @param mixed $centerName
*
* @return \Chill\PersonBundle\Entity\Person
*/
protected function getRandomPerson($centerName)
protected function getRandomPerson(mixed $centerName)
{
$em = self::$kernel
->getContainer()

View File

@@ -40,24 +40,8 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
{
public const TYPE = 'chill_task.transition';
protected AuthorizationHelper $authorizationHelper;
protected EntityManagerInterface $em;
protected Registry $registry;
protected Security $security;
public function __construct(
EntityManagerInterface $em,
Registry $registry,
AuthorizationHelper $authorizationHelper,
Security $security
) {
$this->em = $em;
$this->registry = $registry;
$this->authorizationHelper = $authorizationHelper;
$this->security = $security;
public function __construct(protected EntityManagerInterface $em, protected Registry $registry, protected AuthorizationHelper $authorizationHelper, protected Security $security)
{
}
public function fetchQuery($context, $args)
@@ -65,20 +49,11 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
$metadata = $this->em
->getClassMetadata(SingleTaskPlaceEvent::class);
switch ($context) {
case 'person':
[ $where, $parameters ] = $this->getWhereClauseForPerson($args['person']);
break;
case 'center':
[ $where, $parameters ] = $this->getWhereClauseForCenter($args['centers']);
break;
default:
throw new UnexpectedValueException("context {$context} is not supported");
}
[ $where, $parameters ] = match ($context) {
'person' => $this->getWhereClauseForPerson($args['person']),
'center' => $this->getWhereClauseForCenter($args['centers']),
default => throw new UnexpectedValueException("context {$context} is not supported"),
};
return TimelineSingleQuery::fromArray([
'id' => sprintf('%s.%s.%s', $metadata->getSchemaName(), $metadata->getTableName(), $metadata->getColumnName('id')),