Ignore:
Timestamp:
Nov 20, 2020, 12:08:12 AM (3 years ago)
Author:
chronos
Message:
  • Added: Static types added to almost all classes, methods and function. Supported by PHP 7.4.
  • Fixed: Various found code issues.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Notify/Notify.php

    r874 r887  
    55class ModuleNotify extends AppModule
    66{
    7   var $Checks;
    8 
    9   function __construct($System)
     7  public array $Checks;
     8
     9  function __construct(System $System)
    1010  {
    1111    parent::__construct($System);
     
    1919  }
    2020
    21   function DoStart()
     21  function DoStart(): void
    2222  {
    2323    $this->System->FormManager->RegisterClass('NotifyUser', array(
     
    3838      ),
    3939    ));
    40     $this->System->RegisterCommandLine('notify', array($this, 'RunCheck'));
    41     $this->System->ModuleManager->Modules['RSS']->RegisterRSS(array('Title' => 'Notify log',
    42     'Channel' => 'notifylog', 'Callback' => array('ModuleNotify', 'ShowLogRSS'),
     40    $this->System->RegisterCommandLine('notify', 'Perform notifications processing.', array($this, 'RunCheck'));
     41    ModuleRSS::Cast($this->System->GetModule('RSS'))->RegisterRSS(array('Title' => 'Notify log',
     42    'Channel' => 'notifylog', 'Callback' => array($this, 'ShowLogRSS'),
    4343    'Permission' => array('Module' => 'Notify', 'Operation' => 'RSS')));
    4444  }
    4545
    46   function RegisterCheck($Name, $Callback)
     46  function RegisterCheck(string $Name, callable $Callback): void
    4747  {
    4848    if (array_key_exists($Name, $this->Checks))
     
    5151  }
    5252
    53   function UnregisterCheck($Name)
     53  function UnregisterCheck(string $Name): void
    5454  {
    5555    if (!array_key_exists($Name, $this->Checks))
     
    5858  }
    5959
    60   function Check()
     60  function Check(): string
    6161  {
    6262    $Output = '';
     
    123123  }
    124124
    125   function RunCheck($Parameters)
     125  function RunCheck(array $Parameters): void
    126126  {
    127127    RepeatFunction(30, array($this, 'Check'));
    128128  }
    129129
    130   function DoInstall()
     130  function DoInstall(): void
    131131  {
    132132    $this->Database->query('CREATE TABLE IF NOT EXISTS `NotifyCategory` (
     
    160160  }
    161161
    162   function DoUninstall()
     162  function DoUninstall(): void
    163163  {
    164164    $this->Database->query('DROP TABLE `NotifyUser`');
     
    166166  }
    167167
    168   function ShowLogRSS()
     168  function ShowLogRSS(): string
    169169  {
    170170    $this->ClearPage = true;
     
    197197    return $RSS->Generate();
    198198  }
     199
     200  static function Cast(AppModule $AppModule): ModuleNotify
     201  {
     202    if ($AppModule instanceof ModuleNotify)
     203    {
     204      return $AppModule;
     205    }
     206    throw new Exception('Expected ModuleNotify type but got '.gettype($AppModule));
     207  }
    199208}
Note: See TracChangeset for help on using the changeset viewer.