r76830 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76829‎ | r76830 | r76831 >
Date:20:14, 16 November 2010
Author:ialex
Status:ok
Tags:
Comment:
Fixed some doxygen warnings
Modified paths:
  • /trunk/phase3/includes/IP.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/IP.php
@@ -69,8 +69,9 @@
7070 * Determine if a string is as valid IP address or network (CIDR prefix).
7171 * SIIT IPv4-translated addresses are rejected.
7272 * Note: canonicalize() tries to convert translated addresses to IPv4.
73 - * @param string $ip possible IP address
74 - * @return bool
 73+ *
 74+ * @param $ip String: possible IP address
 75+ * @return Boolean
7576 */
7677 public static function isIPAddress( $ip ) {
7778 return (bool)preg_match( '/^' . IP_ADDRESS_STRING . '$/', $ip );
@@ -79,8 +80,9 @@
8081 /**
8182 * Given a string, determine if it as valid IP in IPv6 only.
8283 * Note: Unlike isValid(), this looks for networks too.
83 - * @param string $ip possible IP address
84 - * @return bool
 84+ *
 85+ * @param $ip String: possible IP address
 86+ * @return Boolean
8587 */
8688 public static function isIPv6( $ip ) {
8789 return (bool)preg_match( '/^' . RE_IPV6_ADD . '(\/' . RE_IPV6_PREFIX . '|)$/', $ip );
@@ -89,8 +91,9 @@
9092 /**
9193 * Given a string, determine if it as valid IP in IPv4 only.
9294 * Note: Unlike isValid(), this looks for networks too.
93 - * @param string $ip possible IP address
94 - * @return bool
 95+ *
 96+ * @param $ip String: possible IP address
 97+ * @return Boolean
9598 */
9699 public static function isIPv4( $ip ) {
97100 return (bool)preg_match( '/^' . RE_IP_ADD . '(\/' . RE_IP_PREFIX . '|)$/', $ip );
@@ -100,8 +103,9 @@
101104 * Validate an IP address. Ranges are NOT considered valid.
102105 * SIIT IPv4-translated addresses are rejected.
103106 * Note: canonicalize() tries to convert translated addresses to IPv4.
104 - * @param string $ip
105 - * @return boolean True if it is valid.
 107+ *
 108+ * @param $ip String
 109+ * @return Boolean: True if it is valid.
106110 */
107111 public static function isValid( $ip ) {
108112 return ( preg_match( '/^' . RE_IP_ADD . '$/', $ip )
@@ -112,8 +116,9 @@
113117 * Validate an IP Block (valid address WITH a valid prefix).
114118 * SIIT IPv4-translated addresses are rejected.
115119 * Note: canonicalize() tries to convert translated addresses to IPv4.
116 - * @param string $ipblock
117 - * @return boolean True if it is valid.
 120+ *
 121+ * @param $ipblock String
 122+ * @return Boolean: True if it is valid.
118123 */
119124 public static function isValidBlock( $ipblock ) {
120125 return ( preg_match( '/^' . RE_IPV6_BLOCK . '$/', $ipblock )
@@ -124,8 +129,9 @@
125130 * Convert an IP into a nice standard form.
126131 * IPv6 addresses in octet notation are expanded to 8 words.
127132 * IPv4 addresses are just trimmed.
128 - * @param string $ip IP address in quad or octet form (CIDR or not).
129 - * @return string
 133+ *
 134+ * @param $ip String: IP address in quad or octet form (CIDR or not).
 135+ * @return String
130136 */
131137 public static function sanitizeIP( $ip ) {
132138 $ip = trim( $ip );
@@ -174,8 +180,9 @@
175181
176182 /**
177183 * Given an unsigned integer, returns an IPv6 address in octet notation
178 - * @param string $ip_int IP address.
179 - * @return string
 184+ *
 185+ * @param $ip_int String: IP address.
 186+ * @return String
180187 */
181188 public static function toOctet( $ip_int ) {
182189 return self::hexToOctet( wfBaseConvert( $ip_int, 10, 16, 32, false ) );
@@ -183,8 +190,9 @@
184191
185192 /**
186193 * Convert an IPv4 or IPv6 hexadecimal representation back to readable format
187 - * @param string $hex number, with "v6-" prefix if it is IPv6
188 - * @return string quad-dotted (IPv4) or octet notation (IPv6)
 194+ *
 195+ * @param $hex String: number, with "v6-" prefix if it is IPv6
 196+ * @return String: quad-dotted (IPv4) or octet notation (IPv6)
189197 */
190198 public static function formatHex( $hex ) {
191199 if ( substr( $hex, 0, 3 ) == 'v6-' ) { // IPv6
@@ -196,8 +204,9 @@
197205
198206 /**
199207 * Converts a hexadecimal number to an IPv6 address in octet notation
200 - * @param string $ip_hex pure hex (no v6- prefix)
201 - * @return string (of format a:b:c:d:e:f:g:h)
 208+ *
 209+ * @param $ip_hex String: pure hex (no v6- prefix)
 210+ * @return String (of format a:b:c:d:e:f:g:h)
202211 */
203212 public static function hexToOctet( $ip_hex ) {
204213 // Pad hex to 32 chars (128 bits)
@@ -214,8 +223,9 @@
215224
216225 /**
217226 * Converts a hexadecimal number to an IPv4 address in quad-dotted notation
218 - * @param string $ip_hex pure hex
219 - * @return string (of format a.b.c.d)
 227+ *
 228+ * @param $ip_hex String: pure hex
 229+ * @return String (of format a.b.c.d)
220230 */
221231 public static function hexToQuad( $ip_hex ) {
222232 // Pad hex to 8 chars (32 bits)
@@ -235,8 +245,9 @@
236246 * Determine if an IP address really is an IP address, and if it is public,
237247 * i.e. not RFC 1918 or similar
238248 * Comes from ProxyTools.php
239 - * @param string $ip
240 - * @return bool
 249+ *
 250+ * @param $ip String
 251+ * @return Boolean
241252 */
242253 public static function isPublic( $ip ) {
243254 if ( self::isIPv6( $ip ) ) {
@@ -277,8 +288,9 @@
278289 /**
279290 * Determine if an IPv6 address really is an IP address, and if it is public,
280291 * i.e. not RFC 4193 or similar
281 - * @param string $ip
282 - * @return bool
 292+ *
 293+ * @param $ip String
 294+ * @return Boolean
283295 */
284296 private static function isPublic6( $ip ) {
285297 static $privateRanges = false;
@@ -307,8 +319,8 @@
308320 * function for an IPv6 address will be prefixed with "v6-", a non-
309321 * hexadecimal string which sorts after the IPv4 addresses.
310322 *
311 - * @param string $ip Quad dotted/octet IP address.
312 - * @return string
 323+ * @param $ip String: quad dotted/octet IP address.
 324+ * @return String
313325 */
314326 public static function toHex( $ip ) {
315327 if ( self::isIPv6( $ip ) ) {
@@ -324,8 +336,9 @@
325337
326338 /**
327339 * Given an IPv6 address in octet notation, returns a pure hex string.
328 - * @param string $ip octet ipv6 IP address.
329 - * @return string pure hex (uppercase)
 340+ *
 341+ * @param $ip String: octet ipv6 IP address.
 342+ * @return String: pure hex (uppercase)
330343 */
331344 private static function IPv6ToRawHex( $ip ) {
332345 $ip = self::sanitizeIP( $ip );
@@ -343,8 +356,9 @@
344357 * Given an IP address in dotted-quad/octet notation, returns an unsigned integer.
345358 * Like ip2long() except that it actually works and has a consistent error return value.
346359 * Comes from ProxyTools.php
347 - * @param string $ip Quad dotted IP address.
348 - * @return mixed (string/int/false)
 360+ *
 361+ * @param $ip String: quad dotted IP address.
 362+ * @return Mixed: string/int/false
349363 */
350364 public static function toUnsigned( $ip ) {
351365 if ( self::isIPv6( $ip ) ) {
@@ -365,7 +379,8 @@
366380 /**
367381 * Convert a network specification in CIDR notation
368382 * to an integer network and a number of bits
369 - * @param string $range IP with CIDR prefix
 383+ *
 384+ * @param $range String: IP with CIDR prefix
370385 * @return array(int or string, int)
371386 */
372387 public static function parseCIDR( $range ) {
@@ -407,7 +422,7 @@
408423 * 2001:0db8:85a3::7344/96 CIDR
409424 * 2001:0db8:85a3::7344 - 2001:0db8:85a3::7344 Explicit range
410425 * 2001:0db8:85a3::7344 Single IP
411 - * @param string $range IP range
 426+ * @param $range String: IP range
412427 * @return array(string, string)
413428 */
414429 public static function parseRange( $range ) {
@@ -455,6 +470,7 @@
456471 /**
457472 * Convert a network specification in IPv6 CIDR notation to an
458473 * integer network and a number of bits
 474+ *
459475 * @return array(string, int)
460476 */
461477 private static function parseCIDR6( $range ) {
@@ -541,9 +557,10 @@
542558
543559 /**
544560 * Determine if a given IPv4/IPv6 address is in a given CIDR network
545 - * @param $addr The address to check against the given range.
546 - * @param $range The range to check the given address against.
547 - * @return bool Whether or not the given address is in the given range.
 561+ *
 562+ * @param $addr String: the address to check against the given range.
 563+ * @param $range String: the range to check the given address against.
 564+ * @return Boolean: whether or not the given address is in the given range.
548565 */
549566 public static function isInRange( $addr, $range ) {
550567 $hexIP = self::toHex( $addr );
@@ -559,8 +576,8 @@
560577 * This currently only checks a few IPV4-to-IPv6 related cases. More
561578 * unusual representations may be added later.
562579 *
563 - * @param $addr something that might be an IP address
564 - * @return valid dotted quad IPv4 address or null
 580+ * @param $addr String: something that might be an IP address
 581+ * @return String: valid dotted quad IPv4 address or null
565582 */
566583 public static function canonicalize( $addr ) {
567584 if ( self::isValid( $addr ) ) {

Status & tagging log