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/Common/Global.php

    r874 r887  
    2020$YesNo = array(false => 'Ne', true => 'Ano');
    2121
    22 function HumanSize($Value)
     22function HumanSize(int $Value): string
    2323{
    2424  global $UnitNames;
     
    3333}
    3434
    35 function GetMicrotime()
     35function GetMicrotime(): float
    3636{
    3737  list($Usec, $Sec) = explode(' ', microtime());
     
    3939}
    4040
    41 function ShowArray($Pole)
     41function ShowArray(array $Array): void
    4242{
    4343  echo('<pre style="font-size: 8pt;">');
    44   print_r($Pole);
     44  print_r($Array);
    4545  echo('</pre>');
    4646}
    4747
    48 function HumanDate($Time)
     48function HumanDate(?string $Time): string
    4949{
    5050  if ($Time != '')
     
    5858
    5959// Show page listing numbers
    60 function PagesList($URL, $Page, $TotalCount, $CountPerPage)
     60function PagesList(string $URL, int $Page, int $TotalCount, int $CountPerPage): string
    6161{
    6262  $Count = ceil($TotalCount / $CountPerPage);
     
    9494}
    9595
    96 function ExtractTime($Time)
     96function ExtractTime($Time): array
    9797{
    9898  return array(
     
    106106}
    107107
    108 function GetQueryStringArray($QueryString)
     108function GetQueryStringArray(string $QueryString): array
    109109{
    110110  $Result = array();
     
    122122}
    123123
    124 function SetQueryStringArray($QueryStringArray)
     124function SetQueryStringArray(array $QueryStringArray): string
    125125{
    126126  $Parts = array();
     
    132132}
    133133
    134 function GetPageList($ObjectName, $TotalCount)
     134function GetPageList(string $ObjectName, int $TotalCount): array
    135135{
    136136  global $System;
     
    209209$OrderArrowImage = array('sort_asc.png', 'sort_desc.png');
    210210
    211 function GetOrderTableHeader($ObjectName, $Columns, $DefaultColumn, $DefaultOrder = 0)
     211function GetOrderTableHeader(string $ObjectName, array $Columns, string $DefaultColumn, int $DefaultOrder = 0): array
    212212{
    213213  global $OrderDirSQL, $OrderArrowImage, $Config, $System;
     
    262262}
    263263
    264 function GetRemoteAddress()
     264function GetRemoteAddress(): string
    265265{
    266266  if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
     
    269269}
    270270
    271 function IsInternetAddr()
     271function IsInternetAddr(): bool
    272272{
    273273  global $Config;
     
    286286}
    287287
    288 function GetMemberByIP($IP)
    289 {
    290   global $Database;
    291 
     288function GetMemberByIP(Database $Database, string $IP): string
     289{
    292290  $DbResult = $Database->query('SELECT `Id` FROM `Member` WHERE '.
    293291  '(SELECT `Member` FROM `NetworkDevice` WHERE (SELECT `Device` FROM `NetworkInterface` '.
     
    300298}
    301299
    302 function CommandExist($Command)
     300function CommandExist(string $Command): bool
    303301{
    304302  $Result = shell_exec('which '.$Command);
     
    306304}
    307305
    308 function RemoveDiacritic($Text)
     306function RemoveDiacritic(string $Text): string
    309307{
    310308  return str_replace(
     
    316314}
    317315
    318 function RouterOSIdent($Name)
     316function RouterOSIdent(string $Name): string
    319317{
    320318  return strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', ',' => '-',
     
    328326}
    329327
    330 function NotBlank($Text)
     328function NotBlank(string $Text): string
    331329{
    332330  if ($Text == '') return '&nbsp';
     
    334332}
    335333
    336 function strip_cdata($string)
     334function strip_cdata(string $string): string
    337335{
    338336  preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches);
     
    351349}
    352350
    353 function ProcessURL()
     351function ProcessURL(): array
    354352{
    355353  if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
     
    365363}
    366364
    367 function RepeatFunction($Period, $Callback)
     365function RepeatFunction(int $Period, callable $Callback): void
    368366{
    369367  while (1)
     
    384382  return call_user_func_array('pack', array_merge(array($v), (array)$a));
    385383}
    386 
Note: See TracChangeset for help on using the changeset viewer.