r63513 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63512‎ | r63513 | r63514 >
Date:21:51, 9 March 2010
Author:ialex
Status:ok
Tags:
Comment:
* Fixed some doxygen warnings
* Removed some useless spaces in the begining of lines
Modified paths:
  • /trunk/phase3/includes/IP.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/IP.php
@@ -154,19 +154,19 @@
155155
156156 /**
157157 * Given an unsigned integer, returns an IPv6 address in octet notation
158 - * @param $ip integer IP address.
 158+ * @param $ip_int integer IP address.
159159 * @return string
160160 */
161161 public static function toOctet( $ip_int ) {
162 - // Convert to padded uppercase hex
163 - $ip_hex = wfBaseConvert($ip_int, 10, 16, 32, false);
164 - // Separate into 8 octets
165 - $ip_oct = substr( $ip_hex, 0, 4 );
166 - for ($n=1; $n < 8; $n++) {
167 - $ip_oct .= ':' . substr($ip_hex, 4*$n, 4);
168 - }
169 - // NO leading zeroes
170 - $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct );
 162+ // Convert to padded uppercase hex
 163+ $ip_hex = wfBaseConvert($ip_int, 10, 16, 32, false);
 164+ // Separate into 8 octets
 165+ $ip_oct = substr( $ip_hex, 0, 4 );
 166+ for ($n=1; $n < 8; $n++) {
 167+ $ip_oct .= ':' . substr($ip_hex, 4*$n, 4);
 168+ }
 169+ // NO leading zeroes
 170+ $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct );
171171 return $ip_oct;
172172 }
173173
@@ -183,19 +183,19 @@
184184
185185 /**
186186 * Given a hexadecimal number, returns to an IPv6 address in octet notation
187 - * @param $ip string hex IP
 187+ * @param $ip_hex string hex IP
188188 * @return string
189189 */
190190 public static function hextoOctet( $ip_hex ) {
191 - // Convert to padded uppercase hex
192 - $ip_hex = str_pad( strtoupper($ip_hex), 32, '0');
193 - // Separate into 8 octets
194 - $ip_oct = substr( $ip_hex, 0, 4 );
195 - for ($n=1; $n < 8; $n++) {
196 - $ip_oct .= ':' . substr($ip_hex, 4*$n, 4);
197 - }
198 - // NO leading zeroes
199 - $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct );
 191+ // Convert to padded uppercase hex
 192+ $ip_hex = str_pad( strtoupper($ip_hex), 32, '0');
 193+ // Separate into 8 octets
 194+ $ip_oct = substr( $ip_hex, 0, 4 );
 195+ for ($n=1; $n < 8; $n++) {
 196+ $ip_oct .= ':' . substr($ip_hex, 4*$n, 4);
 197+ }
 198+ // NO leading zeroes
 199+ $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct );
200200 return $ip_oct;
201201 }
202202
@@ -357,7 +357,7 @@
358358 * Split out an IP block as an array of 4 bytes and a mask,
359359 * return false if it can't be determined
360360 *
361 - * @param $ip string A quad dotted/octet IP address
 361+ * @param $ipblock string A quad dotted/octet IP address
362362 * @return array
363363 */
364364 public static function toArray( $ipblock ) {

Status & tagging log