Ignore:
Timestamp:
Nov 24, 2020, 10:58:56 AM (3 years ago)
Author:
chronos
Message:
  • Modified: More static types added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/NetworkAddress.php

    r874 r888  
    55class NetworkAddressIPv4
    66{
    7   var $Address;
    8   var $Prefix;
     7  public int $Address;
     8  public int $Prefix;
    99
    1010  function __construct()
     
    1414  }
    1515
    16   function GetNetMask()
     16  function GetNetMask(): int
    1717  {
    1818    return ((1 << IPV4_BIT_WIDTH) - 1) ^ ((1 << (IPV4_BIT_WIDTH - $this->Prefix)) - 1);
    1919  }
    2020
    21   function AddressToString()
     21  function AddressToString(): string
    2222  {
    2323    return implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255)));
    2424  }
    2525
    26   function AddressFromString($Value)
     26  function AddressFromString(string $Value): void
    2727  {
    2828    $Parts = explode('.', $Value);
     
    3030  }
    3131
    32   function GetRange()
     32  function GetRange(): array
    3333  {
    3434    $From = new NetworkAddressIPv4();
     
    4242  }
    4343
    44   function ChangePrefix($NewPrefix)
     44  function ChangePrefix(int $NewPrefix): void
    4545  {
    4646    $this->Prefix = $NewPrefix;
     
    5050  }
    5151
    52   function Contain($Address)
     52  function Contain(NetworkAddressIPv4 $Address): bool
    5353  {
    5454    $UpperNetmask = $this->GetNetMask();
     
    6363class NetworkAddressIPv6
    6464{
    65   var $Address;
    66   var $Prefix;
     65  public string $Address;
     66  public int $Prefix;
    6767
    6868  function __construct()
     
    7272  }
    7373
    74   function GetNetMask()
     74  function GetNetMask(): string
    7575  {
    7676    return Int128Xor(Int128Sub(Int128Shl(IntToInt128(1), IntToInt128(IPV6_BIT_WIDTH)), IntToInt128(1)),
     
    7878  }
    7979
    80   function AddressToString()
     80  function AddressToString(): string
    8181  {
    8282    return inet_ntop($this->Address);
    8383  }
    8484
    85   function AddressFromString($Value)
     85  function AddressFromString(string $Value)
    8686  {
    8787    $this->Address = inet_pton($Value);
    8888  }
    8989
    90   function ChangePrefix($NewPrefix)
     90  function ChangePrefix(int $NewPrefix): void
    9191  {
    9292    $this->Prefix = $NewPrefix;
     
    9696  }
    9797
    98   function GetOctets()
     98  function GetOctets(): array
    9999  {
    100100    $Result = array();
     
    109109  }
    110110
    111   function EncodeMAC($MAC)
     111  function EncodeMAC(string $MAC): void
    112112  {
    113113    $MAC = explode(':', $MAC);
     
    124124  }
    125125
    126   function Contain($Address)
     126  function Contain(NetworkAddressIPv6 $Address): bool
    127127  {
    128128    $UpperNetmask = $this->GetNetMask();
Note: See TracChangeset for help on using the changeset viewer.