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/NetworkConfig/NetworkConfig.php

    r874 r887  
    55  var $ConfigItems;
    66
    7   function __construct($System)
     7  function __construct(System $System)
    88  {
    99    parent::__construct($System);
     
    1717  }
    1818
    19   function DoInstall()
     19  function DoInstall(): void
    2020  {
    2121  }
    2222
    23   function DoUnInstall()
     23  function DoUnInstall(): void
    2424  {
    2525  }
    2626
    27   function DoStart()
     27  function DoStart(): void
    2828  {
    2929    $this->System->FormManager->RegisterClass('NetworkConfiguration', array(
     
    5555      'States' => array('Neplánováno', 'V plánu', 'Provádí se'),
    5656    ));
    57    
    58     $this->System->RegisterCommandLine('config', array($this, 'Config'));
     57
     58    $this->System->RegisterCommandLine('config', 'Configures network services.', array($this, 'Config'));
    5959    $this->System->Models['NetworkDevice']->RegisterOnChange('NetworkConfig', array($this, 'DoNetworkChange'));
    6060    $this->System->Models['NetworkInterface']->RegisterOnChange('NetworkConfig', array($this, 'DoNetworkChange'));
    6161  }
    62  
    63   function DoNetworkChange()
     62
     63  function DoNetworkChange(): void
    6464  {
    6565    $this->Database->query('UPDATE `NetworkConfiguration` SET `Changed`=1 WHERE '.
     
    6767  }
    6868
    69   function RegisterConfigItem($Name, $ClassName)
     69  function RegisterConfigItem(string $Name, string $ClassName): void
    7070  {
    7171    $this->ConfigItems[$Name] = $ClassName;
    7272  }
    7373
    74   function UnregisterConfigItem($Name)
     74  function UnregisterConfigItem(string $Name): void
    7575  {
    7676    unset($this->ConfigItems[$Name]);
    7777  }
    7878
    79   function Config($Parameters)
     79  function Config(array $Parameters): void
    8080  {
    8181    $Output = '';
     
    9090      } else $Output = 'Config item '.$ConfigItemName.' not found';
    9191    } else $Output = 'Not enough parameters';
    92     return $Output;
     92    echo($Output);
     93  }
     94
     95  static function Cast(AppModule $AppModule): ModuleNetworkConfig
     96  {
     97    if ($AppModule instanceof ModuleNetworkConfig)
     98    {
     99      return $AppModule;
     100    }
     101    throw new Exception('Expected ModuleNetworkConfig type but got '.gettype($AppModule));
    93102  }
    94103}
     
    96105class NetworkConfigItem extends Model
    97106{
    98   function Run()
     107  function Run(): void
    99108  {
    100 
    101109  }
    102110}
Note: See TracChangeset for help on using the changeset viewer.