Ignore:
Timestamp:
Nov 20, 2020, 12:08:12 AM (4 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/Scheduler/Scheduler.php

    r874 r887  
    33class ModuleScheduler extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->System->FormManager->RegisterClass('Scheduler', array(
     
    4848      'Filter' => '1',
    4949    ));
    50     $this->System->RegisterCommandLine('run-scheduler', array($this->System->ModuleManager->Modules['Scheduler'], 'Run'));
     50    $this->System->RegisterCommandLine('run-scheduler', 'Runs scheduled tasks',
     51      array(ModuleScheduler::Cast($this->System->GetModule('Scheduler')), 'Run'));
    5152  }
    5253
    53   function DoInstall()
     54  function DoInstall(): void
    5455  {
    5556  }
    5657
    57   function DoUnInstall()
     58  function DoUnInstall(): void
    5859  {
    5960  }
    6061
    61   function Run($Parameters)
     62  function Run(array $Parameters): void
    6263  {
    6364    while (true)
     
    100101    }
    101102  }
     103
     104  static function Cast(AppModule $AppModule): ModuleScheduler
     105  {
     106    if ($AppModule instanceof ModuleScheduler)
     107    {
     108      return $AppModule;
     109    }
     110    throw new Exception('Expected ModuleScheduler type but got '.gettype($AppModule));
     111  }
    102112}
    103113
    104114class SchedulerTask extends Model
    105115{
    106   function Execute()
     116  function Execute(): string
    107117  {
     118    return '';
    108119  }
    109120}
    110121
    111 
    112122class ScheduleTaskTest extends SchedulerTask
    113123{
    114   function Execute()
     124  function Execute(): string
    115125  {
    116126    $Output = '#';
Note: See TracChangeset for help on using the changeset viewer.