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

@@ -30,23 +30,11 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
class CalendarRangeSyncer
{
private EntityManagerInterface $em;
private LoggerInterface $logger;
private HttpClientInterface $machineHttpClient;
/**
* @param MachineHttpClient $machineHttpClient
*/
public function __construct(
EntityManagerInterface $em,
LoggerInterface $logger,
HttpClientInterface $machineHttpClient
) {
$this->em = $em;
$this->logger = $logger;
$this->machineHttpClient = $machineHttpClient;
public function __construct(private EntityManagerInterface $em, private LoggerInterface $logger, private HttpClientInterface $machineHttpClient)
{
}
public function handleCalendarRangeSync(CalendarRange $calendarRange, array $notification, User $user): void

View File

@@ -32,35 +32,17 @@ use function in_array;
class CalendarSyncer
{
private LoggerInterface $logger;
private HttpClientInterface $machineHttpClient;
private UserRepositoryInterface $userRepository;
public function __construct(LoggerInterface $logger, HttpClientInterface $machineHttpClient, UserRepositoryInterface $userRepository)
public function __construct(private LoggerInterface $logger, private HttpClientInterface $machineHttpClient, private UserRepositoryInterface $userRepository)
{
$this->logger = $logger;
$this->machineHttpClient = $machineHttpClient;
$this->userRepository = $userRepository;
}
public function handleCalendarSync(Calendar $calendar, array $notification, User $user): void
{
switch ($notification['changeType']) {
case 'deleted':
$this->handleDeleteCalendar($calendar, $notification, $user);
break;
case 'updated':
$this->handleUpdateCalendar($calendar, $notification, $user);
break;
default:
throw new RuntimeException('this change type is not supported: ' . $notification['changeType']);
}
match ($notification['changeType']) {
'deleted' => $this->handleDeleteCalendar($calendar, $notification, $user),
'updated' => $this->handleUpdateCalendar($calendar, $notification, $user),
default => throw new RuntimeException('this change type is not supported: ' . $notification['changeType']),
};
}
private function handleDeleteCalendar(Calendar $calendar, array $notification, User $user): void
@@ -150,34 +132,13 @@ class CalendarSyncer
$invite = $calendar->getInviteForUser($user);
switch ($status) {
// possible cases: none, organizer, tentativelyAccepted, accepted, declined, notResponded.
case 'none':
case 'notResponded':
$invite->setStatus(Invite::PENDING);
break;
case 'tentativelyAccepted':
$invite->setStatus(Invite::TENTATIVELY_ACCEPTED);
break;
case 'accepted':
$invite->setStatus(Invite::ACCEPTED);
break;
case 'declined':
$invite->setStatus(Invite::DECLINED);
break;
default:
throw new LogicException('should not happens, not implemented: ' . $status);
break;
}
match ($status) {
'none', 'notResponded' => $invite->setStatus(Invite::PENDING),
'tentativelyAccepted' => $invite->setStatus(Invite::TENTATIVELY_ACCEPTED),
'accepted' => $invite->setStatus(Invite::ACCEPTED),
'declined' => $invite->setStatus(Invite::DECLINED),
default => throw new LogicException('should not happens, not implemented: ' . $status),
};
}
foreach ($calendar->getUsers() as $user) {