r20381 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20380‎ | r20381 | r20382 >
Date:04:55, 13 March 2007
Author:aaron
Status:old
Tags:
Comment:
*Declare static functions as such
Modified paths:
  • /trunk/phase3/includes/IP.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/IP.php
@@ -34,16 +34,16 @@
3535 * @param $ip IP address.
3636 * @return string
3737 */
38 - public function isIPAddress( $ip ) {
 38+ public static function isIPAddress( $ip ) {
3939 if ( !$ip ) return false;
4040 return preg_match( '/^' . IP_ADDRESS_STRING . '$/', $ip);
4141 }
4242
43 - public function isIPv6( $ip ) {
 43+ public static function isIPv6( $ip ) {
4444 return preg_match( '/^' . RE_IPV6_ADD . '(\/' . RE_IPV6_PREFIX . '|)$/', $ip);
4545 }
4646
47 - public function isIPv4( $ip ) {
 47+ public static function isIPv4( $ip ) {
4848 return preg_match( '/^' . RE_IP_ADD . '(\/' . RE_IP_PREFIX . '|)$/', $ip);
4949 }
5050
@@ -54,7 +54,7 @@
5555 * @param $ip quad-dotted IP address.
5656 * @return string
5757 */
58 - public function IPv4toIPv6( $ip ) {
 58+ public static function IPv4toIPv6( $ip ) {
5959 if ( !$ip ) return null;
6060 // Convert only if needed
6161 if ( self::isIPv6( $ip ) ) return $ip;
@@ -80,7 +80,7 @@
8181 * @param $ip octet ipv6 IP address.
8282 * @return string
8383 */
84 - public function toUnsigned6( $ip ) {
 84+ public static function toUnsigned6( $ip ) {
8585 if ( !$ip ) return null;
8686 $ip = explode(':', self::sanitizeIP( $ip ) );
8787 $r_ip = '';
@@ -95,7 +95,7 @@
9696 * @param $ip octet ipv6 IP address.
9797 * @return string
9898 */
99 - public function sanitizeIP( $ip ) {
 99+ public static function sanitizeIP( $ip ) {
100100 if ( !$ip ) return null;
101101 // Only IPv6 addresses can be expanded
102102 if ( !self::isIPv6( $ip ) ) return $ip;
@@ -113,7 +113,7 @@
114114 * @param $ip integer IP address.
115115 * @return string
116116 */
117 - public function toOctet( $ip_int ) {
 117+ public static function toOctet( $ip_int ) {
118118 // Convert integer to binary
119119 $ip_int = wfBaseConvert($ip_int, 10, 2, 128);
120120 // Seperate into 8 octets