1 | <?php |
||
22 | class PTR extends CNAME |
||
23 | { |
||
24 | const TYPE = 'PTR'; |
||
25 | const TYPE_CODE = 12; |
||
26 | |||
27 | /** |
||
28 | * Expands an IPv6 address to its full, non-shorthand representation. |
||
29 | * |
||
30 | * E.g. 2001:db8:9a::42 -> 2001:0db8:009a:0000:0000:0000:0000:0042 |
||
31 | * |
||
32 | * @param string $ip IPv6 address |
||
33 | * |
||
34 | * @throws \InvalidArgumentException |
||
35 | 10 | */ |
|
36 | public static function expandIpv6(string $ip): string |
||
54 | |||
55 | /** |
||
56 | * This function will expand in incomplete IPv6 address. |
||
57 | * An incomplete IPv6 address is of the form `2001:db8:ff:abcd` |
||
58 | * i.e. one where there is less than eight hextets. |
||
59 | 2 | * |
|
60 | * @param string $ip IPv6 address |
||
61 | 2 | * |
|
62 | 2 | * @return string Expanded incomplete IPv6 address |
|
63 | 2 | */ |
|
64 | public static function expandIncompleteIpv6(string $ip): string |
||
72 | |||
73 | /** |
||
74 | * Takes a valid IPv6 address and contracts it |
||
75 | * to its shorter version. |
||
76 | * |
||
77 | * E.g.: 2001:0000:0000:acad:0000:0000:0000:0001 -> 2001:0:0:acad::1 |
||
78 | * |
||
79 | * Note: If there is more than one set of consecutive hextets, the function |
||
80 | * will favour the larger of the sets. If both sets of zeroes are the same |
||
81 | * the first will be favoured in the omission of zeroes. |
||
82 | * |
||
83 | * E.g.: 2001:0000:0000:ab80:2390:0000:0000:000a -> 2001:0:0:ab80:2390::a |
||
84 | * |
||
85 | * @param string $ip IPv6 address |
||
86 | 11 | * |
|
87 | * @throws \InvalidArgumentException |
||
88 | 11 | * |
|
89 | * @return string Contracted IPv6 address |
||
90 | 11 | */ |
|
91 | 1 | public static function contractIpv6(string $ip): string |
|
107 | |||
108 | /** |
||
109 | * Creates a reverse IPv4 address. |
||
110 | * |
||
111 | * E.g. 192.168.1.213 -> 213.1.168.192.in-addr.arpa. |
||
112 | 2 | * |
|
113 | * @param string $ip Valid IPv4 address |
||
114 | 2 | * |
|
115 | * @return string Reversed IP address appended with ".in-addr.arpa." |
||
116 | 2 | */ |
|
117 | public static function reverseIpv4(string $ip): string |
||
123 | |||
124 | /** |
||
125 | * Creates a reverse IPv6 address. |
||
126 | * |
||
127 | * E.g. 2001:db8::567:89ab -> b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa. |
||
128 | * |
||
129 | 2 | * @param string $ip A full or partial IPv6 address |
|
130 | * @param bool $appendSuffix Whether or not to append ".ip6.arpa.' suffix. |
||
131 | * |
||
132 | 2 | * @return string The reversed address appended with ".ip6.arpa." |
|
133 | 2 | */ |
|
134 | 2 | public static function reverseIpv6(string $ip, bool $appendSuffix = true): string |
|
149 | } |
||
150 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.