]> source.dussan.org Git - nextcloud-server.git/commitdiff
refactor lib/private/Notification
authorHamid Dehnavi <hamid.dev.pro@gmail.com>
Wed, 5 Jul 2023 17:55:05 +0000 (21:25 +0330)
committerCôme Chilliet <91878298+come-nc@users.noreply.github.com>
Tue, 2 Jan 2024 15:54:54 +0000 (16:54 +0100)
Signed-off-by: Hamid Dehnavi <hamid.dev.pro@gmail.com>
lib/private/Notification/Action.php
lib/private/Notification/Manager.php
lib/private/Notification/Notification.php

index ff9cf9e38f5615659086a369f30d8b405e2767dd..f0e40f6e1d6acfe16d74a0a3dbfb53ce96b317f3 100644 (file)
@@ -28,22 +28,22 @@ use OCP\Notification\IAction;
 
 class Action implements IAction {
        /** @var string */
-       protected $label;
+       protected string $label;
 
        /** @var string */
-       protected $labelParsed;
+       protected string $labelParsed;
 
        /** @var string */
-       protected $link;
+       protected string $link;
 
        /** @var string */
-       protected $requestType;
+       protected string $requestType;
 
        /** @var string */
-       protected $icon;
+       protected string $icon;
 
        /** @var bool */
-       protected $primary;
+       protected bool $primary;
 
        public function __construct() {
                $this->label = '';
index e81b6c4fa35637c2cf67ebf91cb12041385d3f6e..c712d2754e2581bfee33bd09b27325ee9ca7ac3c 100644 (file)
@@ -43,48 +43,35 @@ use Psr\Container\ContainerExceptionInterface;
 use Psr\Log\LoggerInterface;
 
 class Manager implements IManager {
-       /** @var IValidator */
-       protected $validator;
-       /** @var IUserManager */
-       private $userManager;
        /** @var ICache */
-       protected $cache;
-       /** @var IRegistry */
-       protected $subscription;
-       /** @var LoggerInterface */
-       protected $logger;
-       /** @var Coordinator */
-       private $coordinator;
+       protected ICache $cache;
 
        /** @var IApp[] */
-       protected $apps;
+       protected array $apps;
        /** @var string[] */
-       protected $appClasses;
+       protected array $appClasses;
 
        /** @var INotifier[] */
-       protected $notifiers;
+       protected array $notifiers;
        /** @var string[] */
-       protected $notifierClasses;
+       protected array $notifierClasses;
 
        /** @var bool */
-       protected $preparingPushNotification;
+       protected bool $preparingPushNotification;
        /** @var bool */
-       protected $deferPushing;
+       protected bool $deferPushing;
        /** @var bool */
-       private $parsedRegistrationContext;
+       private bool $parsedRegistrationContext;
 
-       public function __construct(IValidator $validator,
-               IUserManager $userManager,
+       public function __construct(
+               protected IValidator $validator,
+               private IUserManager $userManager,
                ICacheFactory $cacheFactory,
-               IRegistry $subscription,
-               LoggerInterface $logger,
-               Coordinator $coordinator) {
-               $this->validator = $validator;
-               $this->userManager = $userManager;
+               protected IRegistry $subscription,
+               protected LoggerInterface $logger,
+               private Coordinator $coordinator,
+       ) {
                $this->cache = $cacheFactory->createDistributed('notifications');
-               $this->subscription = $subscription;
-               $this->logger = $logger;
-               $this->coordinator = $coordinator;
 
                $this->apps = [];
                $this->notifiers = [];
@@ -111,7 +98,7 @@ class Manager implements IManager {
         * @deprecated 17.0.0 use registerNotifierService instead.
         * @since 8.2.0 - Parameter $info was added in 9.0.0
         */
-       public function registerNotifier(\Closure $service, \Closure $info) {
+       public function registerNotifier(\Closure $service, \Closure $info): void {
                $infoData = $info();
                $exception = new \InvalidArgumentException(
                        'Notifier ' . $infoData['name'] . ' (id: ' . $infoData['id'] . ') is not considered because it is using the old way to register.'
index 2291c4ae34f785d046d2738ecbb53ea25a32b9c0..fcacc897c53c78e6a5908e34a9fae0168d550b5b 100644 (file)
@@ -32,74 +32,73 @@ use OCP\RichObjectStrings\InvalidObjectExeption;
 use OCP\RichObjectStrings\IValidator;
 
 class Notification implements INotification {
-       /** @var IValidator */
-       protected $richValidator;
 
        /** @var string */
-       protected $app;
+       protected string $app;
 
        /** @var string */
-       protected $user;
+       protected string $user;
 
        /** @var \DateTime */
-       protected $dateTime;
+       protected \DateTime $dateTime;
 
        /** @var string */
-       protected $objectType;
+       protected string $objectType;
 
        /** @var string */
-       protected $objectId;
+       protected string $objectId;
 
        /** @var string */
-       protected $subject;
+       protected string $subject;
 
        /** @var array */
-       protected $subjectParameters;
+       protected array $subjectParameters;
 
        /** @var string */
-       protected $subjectParsed;
+       protected string $subjectParsed;
 
        /** @var string */
-       protected $subjectRich;
+       protected string $subjectRich;
 
        /** @var array */
-       protected $subjectRichParameters;
+       protected array $subjectRichParameters;
 
        /** @var string */
-       protected $message;
+       protected string $message;
 
        /** @var array */
-       protected $messageParameters;
+       protected array $messageParameters;
 
        /** @var string */
-       protected $messageParsed;
+       protected string $messageParsed;
 
        /** @var string */
-       protected $messageRich;
+       protected string $messageRich;
 
        /** @var array */
-       protected $messageRichParameters;
+       protected array $messageRichParameters;
 
        /** @var string */
-       protected $link;
+       protected string $link;
 
        /** @var string */
-       protected $icon;
+       protected string $icon;
 
        /** @var array */
-       protected $actions;
+       protected array $actions;
 
        /** @var array */
-       protected $actionsParsed;
+       protected array $actionsParsed;
 
        /** @var bool */
-       protected $hasPrimaryAction;
+       protected bool $hasPrimaryAction;
 
        /** @var bool */
-       protected $hasPrimaryParsedAction;
+       protected bool $hasPrimaryParsedAction;
 
-       public function __construct(IValidator $richValidator) {
-               $this->richValidator = $richValidator;
+       public function __construct(
+               protected IValidator $richValidator,
+       ) {
                $this->app = '';
                $this->user = '';
                $this->dateTime = new \DateTime();