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

@@ -53,35 +53,22 @@ final class NotificationVoter extends Voter
}
if ($subject instanceof Notification) {
switch ($attribute) {
case self::COMMENT_ADD:
return false === $subject->isSystem() && (
$subject->getAddressees()->contains($user) || $subject->getSender() === $user
);
case self::NOTIFICATION_SEE:
case self::NOTIFICATION_TOGGLE_READ_STATUS:
return $subject->getSender() === $user || $subject->getAddressees()->contains($user);
case self::NOTIFICATION_UPDATE:
return $subject->getSender() === $user && false === $subject->isSystem();
default:
throw new UnexpectedValueException("this subject {$attribute} is not implemented");
}
return match ($attribute) {
self::COMMENT_ADD => false === $subject->isSystem() && (
$subject->getAddressees()->contains($user) || $subject->getSender() === $user
),
self::NOTIFICATION_SEE, self::NOTIFICATION_TOGGLE_READ_STATUS => $subject->getSender() === $user || $subject->getAddressees()->contains($user),
self::NOTIFICATION_UPDATE => $subject->getSender() === $user && false === $subject->isSystem(),
default => throw new UnexpectedValueException("this subject {$attribute} is not implemented"),
};
} elseif ($subject instanceof NotificationComment) {
switch ($attribute) {
case self::COMMENT_ADD:
return false === $subject->getNotification()->isSystem() && (
$subject->getNotification()->getAddressees()->contains($user) || $subject->getNotification()->getSender() === $user
);
case self::COMMENT_EDIT:
return $subject->getCreatedBy() === $user && false === $subject->getNotification()->isSystem();
default:
throw new UnexpectedValueException("this subject {$attribute} is not implemented");
}
return match ($attribute) {
self::COMMENT_ADD => false === $subject->getNotification()->isSystem() && (
$subject->getNotification()->getAddressees()->contains($user) || $subject->getNotification()->getSender() === $user
),
self::COMMENT_EDIT => $subject->getCreatedBy() === $user && false === $subject->getNotification()->isSystem(),
default => throw new UnexpectedValueException("this subject {$attribute} is not implemented"),
};
}
throw new UnexpectedValueException();