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

    r874 r887  
    1717class ModuleAPI extends AppModule
    1818{
    19   function __construct($System)
     19  function __construct(System $System)
    2020  {
    2121    parent::__construct($System);
     
    2828  }
    2929
    30   function DoStart()
     30  function DoStart(): void
    3131  {
    32     $this->System->RegisterPage(array('api'), 'PageAPI');
     32    $this->System->RegisterPage(['api'], 'PageAPI');
    3333  }
    3434}
     
    3636class PageAPI extends Page
    3737{
    38   var $DataFormat;
    39  
    40   function __construct($System)
     38  public string $DataFormat;
     39
     40  function __construct(System $System)
    4141  {
    4242    parent::__construct($System);
    4343    $this->ClearPage = true;
     44    $this->DataFormat = '';
    4445  }
    4546
    46   function Show()
     47  function Show(): string
    4748  {
    4849    // p - token
     
    5051      $Token = $_GET['p'];
    5152      $DbResult = $this->Database->query('SELECT `User` FROM `APIToken` WHERE `Token`="'.$Token.'"');
    52       if ($DbResult->num_rows > 0) 
     53      if ($DbResult->num_rows > 0)
    5354      {
    5455        $DbRow = $DbResult->fetch_assoc();
     
    7576  }
    7677
    77   function ShowList($Table, $ItemId)
     78  function ShowList(string $Table, $ItemId): string
    7879  {
    7980    if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes)))
     
    8485      $SourceTable = '('.$FormClass['SQL'].') AS `TX`';
    8586      else $SourceTable = '`'.$FormClass['Table'].'` AS `TX`';
    86      
     87
    8788    $Filter = '';
    8889    if ($ItemId != 0)
     
    112113    $dom->appendChild($root);
    113114
    114     $array2xml = function ($node, $array) use ($dom, &$array2xml) 
     115    $array2xml = function ($node, $array) use ($dom, &$array2xml)
    115116    {
    116117      foreach ($array as $key => $value)
    117118      {
    118         if ( is_array($value) ) 
     119        if ( is_array($value) )
    119120        {
    120121          if (is_numeric($key)) $key = 'N'.$key; //die('XML tag name "'.$key.'" can\'t be numeric');
Note: See TracChangeset for help on using the changeset viewer.