Trim trailing whitespace
authorSam Reed <reedy@users.mediawiki.org>
Sun, 4 Sep 2011 21:40:17 +0000 (21:40 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 4 Sep 2011 21:40:17 +0000 (21:40 +0000)
Add/tweak/update documentation

Simplify some boolean returns

13 files changed:
includes/BacklinkCache.php
includes/Categoryfinder.php
includes/Cookie.php
includes/EditPage.php
includes/Fallback.php
includes/FeedUtils.php
includes/ForkController.php
includes/IP.php
includes/Init.php
includes/Licenses.php
includes/LogEventsList.php
includes/LogPage.php
includes/MagicWord.php

index 4de4afb..a6ad003 100644 (file)
@@ -75,6 +75,8 @@ class BacklinkCache {
         * Serialization handler, diasallows to serialize the database to prevent
         * failures after this class is deserialized from cache with dead DB
         * connection.
+        *
+        * @return array
         */
        function __sleep() {
                return array( 'partitionCache', 'fullResultCache', 'title' );
index 2567de0..4a8ed70 100644 (file)
@@ -29,6 +29,10 @@ class Categoryfinder {
        var $targets = array(); # Array of DBKEY category names
        var $name2id = array();
        var $mode; # "AND" or "OR"
+
+       /**
+        * @var DatabaseBase
+        */
        var $dbr; # Read-DB slave
 
        /**
index 95a4599..76739cc 100644 (file)
@@ -139,6 +139,10 @@ class Cookie {
                return $ret;
        }
 
+       /**
+        * @param $domain
+        * @return bool
+        */
        protected function canServeDomain( $domain ) {
                if ( $domain == $this->domain
                        || ( strlen( $domain ) > strlen( $this->domain )
@@ -151,20 +155,19 @@ class Cookie {
                return false;
        }
 
+       /**
+        * @param $path
+        * @return bool
+        */
        protected function canServePath( $path ) {
-               if ( $this->path && substr_compare( $this->path, $path, 0, strlen( $this->path ) ) == 0 ) {
-                       return true;
-               }
-
-               return false;
+               return ( $this->path && substr_compare( $this->path, $path, 0, strlen( $this->path ) ) == 0 );
        }
 
+       /**
+        * @return bool
+        */
        protected function isUnExpired() {
-               if ( $this->isSessionKey || $this->expires > time() ) {
-                       return true;
-               }
-
-               return false;
+               return $this->isSessionKey || $this->expires > time();
        }
 }
 
index 6b6a01c..d2f141c 100644 (file)
@@ -868,7 +868,7 @@ class EditPage {
        function internalAttemptSave( &$result, $bot = false ) {
                global $wgFilterCallback, $wgUser, $wgRequest, $wgParser;
                global $wgMaxArticleSize;
-               
+
                $status = Status::newGood();
 
                wfProfileIn( __METHOD__  );
@@ -891,7 +891,6 @@ class EditPage {
                                $status->setResult( false, $code );
 
                                wfProfileOut( __METHOD__ . '-checks' );
-                               
                                wfProfileOut( __METHOD__  );
 
                                return $status;
@@ -936,6 +935,7 @@ class EditPage {
                        wfProfileOut( __METHOD__ );
                        return $status;
                }
+
                if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
                        # Check block state against master, thus 'false'.
                        $status->setResult( false, self::AS_BLOCKED_PAGE_FOR_USER );
@@ -943,6 +943,7 @@ class EditPage {
                        wfProfileOut( __METHOD__ );
                        return $status;
                }
+
                $this->kblength = (int)( strlen( $this->textbox1 ) / 1024 );
                if ( $this->kblength > $wgMaxArticleSize ) {
                        // Error will be displayed by showEditForm()
index 2cca1e8..b517cd1 100644 (file)
  * Fallback functions for PHP installed without mbstring support
  */
 class Fallback {
-       
+
+       /**
+        * @param $from
+        * @param $to
+        * @param $string
+        * @return string
+        */
        public static function iconv( $from, $to, $string ) {
                if ( substr( $to, -8 ) == '//IGNORE' ) {
                        $to = substr( $to, 0, strlen( $to ) - 8 );
@@ -48,7 +54,7 @@ class Fallback {
         * Larger offsets are still fairly efficient for Latin text, but
         * can be up to 100x slower than native if the text is heavily
         * multibyte and we have to slog through a few hundred kb.
-        * 
+        *
         * @param $str
         * @param $start
         * @param $count string
@@ -60,22 +66,27 @@ class Fallback {
                        $split = self::mb_substr_split_unicode( $str, intval( $start ) );
                        $str = substr( $str, $split );
                }
-       
+
                if( $count !== 'end' ) {
                        $split = self::mb_substr_split_unicode( $str, intval( $count ) );
                        $str = substr( $str, 0, $split );
                }
-       
+
                return $str;
        }
-       
+
+       /**
+        * @param $str
+        * @param $splitPos
+        * @return int
+        */
        public static function mb_substr_split_unicode( $str, $splitPos ) {
                if( $splitPos == 0 ) {
                        return 0;
                }
-       
+
                $byteLen = strlen( $str );
-       
+
                if( $splitPos > 0 ) {
                        if( $splitPos > 256 ) {
                                // Optimize large string offsets by skipping ahead N bytes.
@@ -90,7 +101,7 @@ class Fallback {
                                $charPos = 0;
                                $bytePos = 0;
                        }
-       
+
                        while( $charPos++ < $splitPos ) {
                                ++$bytePos;
                                // Move past any tail bytes
@@ -110,10 +121,10 @@ class Fallback {
                                }
                        }
                }
-       
+
                return $bytePos;
        }
-       
+
        /**
         * Fallback implementation of mb_strlen, hardcoded to UTF-8.
         * @param string $str
@@ -123,20 +134,20 @@ class Fallback {
        public static function mb_strlen( $str, $enc = '' ) {
                $counts = count_chars( $str );
                $total = 0;
-       
+
                // Count ASCII bytes
                for( $i = 0; $i < 0x80; $i++ ) {
                        $total += $counts[$i];
                }
-       
+
                // Count multibyte sequence heads
                for( $i = 0xc0; $i < 0xff; $i++ ) {
                        $total += $counts[$i];
                }
                return $total;
        }
-       
-       
+
+
        /**
         * Fallback implementation of mb_strpos, hardcoded to UTF-8.
         * @param $haystack String
@@ -147,17 +158,17 @@ class Fallback {
         */
        public static function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
                $needle = preg_quote( $needle, '/' );
-       
+
                $ar = array();
                preg_match( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
-       
+
                if( isset( $ar[0][1] ) ) {
                        return $ar[0][1];
                } else {
                        return false;
                }
-       }       
-       
+       }
+
        /**
         * Fallback implementation of mb_strrpos, hardcoded to UTF-8.
         * @param $haystack String
@@ -168,10 +179,10 @@ class Fallback {
         */
        public static function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
                $needle = preg_quote( $needle, '/' );
-       
+
                $ar = array();
                preg_match_all( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
-       
+
                if( isset( $ar[0] ) && count( $ar[0] ) > 0 &&
                        isset( $ar[0][count( $ar[0] ) - 1][1] ) ) {
                        return $ar[0][count( $ar[0] ) - 1][1];
@@ -196,5 +207,5 @@ class Fallback {
                }
                return false;
        }
-               
+
 }
index 4502c3a..e923a28 100644 (file)
@@ -167,7 +167,6 @@ class FeedUtils {
         *
         * @param $text String: diff's HTML output
         * @return String: modified HTML
-        * @private
         */
        public static function applyDiffStyle( $text ) {
                $styles = array(
index d87dfb1..7fff6ae 100644 (file)
@@ -125,7 +125,7 @@ class ForkController {
        /**
         * Fork a number of worker processes.
         *
-        * return string
+        * @return string
         */
        protected function forkWorkers( $numProcs ) {
                $this->prepareEnvironment();
index 055fe85..20760d6 100644 (file)
@@ -186,14 +186,14 @@ class IP {
        }
 
        /**
-        * Given a host/port string, like one might find in the host part of a URL 
-        * per RFC 2732, split the hostname part and the port part and return an 
-        * array with an element for each. If there is no port part, the array will 
-        * have false in place of the port. If the string was invalid in some way, 
+        * Given a host/port string, like one might find in the host part of a URL
+        * per RFC 2732, split the hostname part and the port part and return an
+        * array with an element for each. If there is no port part, the array will
+        * have false in place of the port. If the string was invalid in some way,
         * false is returned.
         *
-        * This was easy with IPv4 and was generally done in an ad-hoc way, but 
-        * with IPv6 it's somewhat more complicated due to the need to parse the 
+        * This was easy with IPv4 and was generally done in an ad-hoc way, but
+        * with IPv6 it's somewhat more complicated due to the need to parse the
         * square brackets and colons.
         *
         * A bare IPv6 address is accepted despite the lack of square brackets.
@@ -241,8 +241,13 @@ class IP {
        /**
         * Given a host name and a port, combine them into host/port string like
         * you might find in a URL. If the host contains a colon, wrap it in square
-        * brackets like in RFC 2732. If the port matches the default port, omit 
+        * brackets like in RFC 2732. If the port matches the default port, omit
         * the port specification
+        *
+        * @param $host string
+        * @param $port int
+        * @param $defaultPort bool|int
+        * @return string
         */
        public static function combineHostAndPort( $host, $port, $defaultPort = false ) {
                if ( strpos( $host, ':' ) !== false ) {
@@ -449,6 +454,10 @@ class IP {
                return $n;
        }
 
+       /**
+        * @param $ip
+        * @return String
+        */
        private static function toUnsigned6( $ip ) {
                return wfBaseConvert( self::IPv6ToRawHex( $ip ), 16, 10 );
        }
@@ -548,6 +557,8 @@ class IP {
         * Convert a network specification in IPv6 CIDR notation to an
         * integer network and a number of bits
         *
+        * @param $range
+        *
         * @return array(string, int)
         */
        private static function parseCIDR6( $range ) {
@@ -585,6 +596,9 @@ class IP {
         *     2001:0db8:85a3::7344/96                                   CIDR
         *     2001:0db8:85a3::7344 - 2001:0db8:85a3::7344   Explicit range
         *     2001:0db8:85a3::7344/96                                   Single IP
+        *
+        * @param $range
+        *
         * @return array(string, string)
         */
        private static function parseRange6( $range ) {
index de86728..c4bdc5f 100644 (file)
@@ -23,7 +23,7 @@ class MWInit {
        }
 
        /**
-        * Returns true if we are running under HipHop, whether in compiled or 
+        * Returns true if we are running under HipHop, whether in compiled or
         * interpreted mode.
         *
         * @return bool
@@ -47,10 +47,10 @@ class MWInit {
        }
 
        /**
-        * If we are running code compiled by HipHop, this will pass through the 
-        * input path, assumed to be relative to $IP. If the code is interpreted, 
-        * it will converted to a fully qualified path. It is necessary to use a 
-        * path which is relative to $IP in order to make HipHop use its compiled 
+        * If we are running code compiled by HipHop, this will pass through the
+        * input path, assumed to be relative to $IP. If the code is interpreted,
+        * it will converted to a fully qualified path. It is necessary to use a
+        * path which is relative to $IP in order to make HipHop use its compiled
         * code.
         *
         * @param $file string
@@ -94,7 +94,7 @@ class MWInit {
        }
 
        /**
-        * Register an extension setup file and return its path for compiled 
+        * Register an extension setup file and return its path for compiled
         * inclusion. Use this function in LocalSettings.php to add extensions
         * to the build. For example:
         *
@@ -130,13 +130,13 @@ class MWInit {
        /**
         * Determine whether a class exists, using a method which works under HipHop.
         *
-        * Note that it's not possible to implement this with any variant of 
-        * class_exists(), because class_exists() returns false for classes which 
-        * are compiled in. 
+        * Note that it's not possible to implement this with any variant of
+        * class_exists(), because class_exists() returns false for classes which
+        * are compiled in.
         *
-        * Calling class_exists() on a literal string causes the class to be made 
-        * "volatile", which means (as of March 2011) that the class is broken and 
-        * can't be used at all. So don't do that. See 
+        * Calling class_exists() on a literal string causes the class to be made
+        * "volatile", which means (as of March 2011) that the class is broken and
+        * can't be used at all. So don't do that. See
         * https://github.com/facebook/hiphop-php/issues/314
         *
         * @param $class string
@@ -153,11 +153,11 @@ class MWInit {
        }
 
        /**
-        * Determine whether a function exists, using a method which works under 
+        * Determine whether a function exists, using a method which works under
         * HipHop.
         *
         * @param $function string
-        * 
+        *
         * @return bool
         */
        static function functionExists( $function ) {
index 09fa8db..8a06c6f 100644 (file)
@@ -134,6 +134,10 @@ class Licenses extends HTMLFormField {
                return str_repeat( "\t", $depth ) . Xml::element( 'option', $attribs, $val ) . "\n";
        }
 
+       /**
+        * @param $str string
+        * @return String
+        */
        protected function msg( $str ) {
                $msg = wfMessage( $str );
                return $msg->exists() ? $msg->text() : $str;
index a18d849..edebf86 100644 (file)
@@ -279,7 +279,8 @@ class LogEventsList {
        }
 
        /**
-        * @return boolean Checkbox
+        * @param $pattern
+        * @return string Checkbox
         */
        private function getTitlePattern( $pattern ) {
                return '<span style="white-space: nowrap">' .
@@ -287,6 +288,10 @@ class LogEventsList {
                        '</span>';
        }
 
+       /**
+        * @param $types
+        * @return string
+        */
        private function getExtraInputs( $types ) {
                global $wgRequest;
                $offender = $wgRequest->getVal('offender');
@@ -301,10 +306,16 @@ class LogEventsList {
                return '';
        }
 
+       /**
+        * @return string
+        */
        public function beginLogEventsList() {
                return "<ul>\n";
        }
 
+       /**
+        * @return string
+        */
        public function endLogEventsList() {
                return "</ul>\n";
        }
@@ -347,6 +358,10 @@ class LogEventsList {
                return htmlspecialchars( $time );
        }
 
+       /**
+        * @param $row
+        * @return String
+        */
        private function logUserLinks( $row ) {
                if( self::isDeleted( $row, LogPage::DELETED_USER ) ) {
                        $userLinks = '<span class="history-deleted">' .
@@ -362,6 +377,12 @@ class LogEventsList {
                return $userLinks;
        }
 
+       /**
+        * @param $row
+        * @param $title
+        * @param $paramArray
+        * @return string
+        */
        private function logAction( $row, $title, $paramArray ) {
                if( self::isDeleted( $row, LogPage::DELETED_ACTION ) ) {
                        $action = '<span class="history-deleted">' .
@@ -373,6 +394,10 @@ class LogEventsList {
                return $action;
        }
 
+       /**
+        * @param $row
+        * @return string
+        */
        private function logComment( $row ) {
                if( self::isDeleted( $row, LogPage::DELETED_COMMENT ) ) {
                        $comment = '<span class="history-deleted">' .
@@ -811,6 +836,9 @@ class LogPager extends ReverseChronologicalPager {
                return $query;
        }
 
+       /**
+        * @return Title
+        */
        function getTitle() {
                return $this->mLogEventsList->getDisplayTitle();
        }
@@ -1038,10 +1066,16 @@ class LogPager extends ReverseChronologicalPager {
                return $this->types;
        }
 
+       /**
+        * @return string
+        */
        public function getUser() {
                return $this->user;
        }
 
+       /**
+        * @return string
+        */
        public function getPage() {
                return $this->title;
        }
index a52ac2a..a948693 100644 (file)
@@ -123,6 +123,8 @@ class LogPage {
 
        /**
         * Get the RC comment from the last addEntry() call
+        *
+        * @return string
         */
        public function getRcComment() {
                $rcComment = $this->actionText;
@@ -434,6 +436,8 @@ class LogPage {
         * @param $comment String: description associated
         * @param $params Array: parameters passed later to wfMsg.* functions
         * @param $doer User object: the user doing the action
+        *
+        * @return bool|int|null
         */
        public function addEntry( $action, $target, $comment, $params = array(), $doer = null ) {
                global $wgContLang;
index d157938..e327971 100644 (file)
@@ -230,7 +230,7 @@ class MagicWord {
         * Get an array of parser substitution modifier IDs
         */
        static function getSubstIDs() {
-               return self::$mSubstIDs; 
+               return self::$mSubstIDs;
        }
 
        /**
@@ -309,8 +309,8 @@ class MagicWord {
        }
 
        /**
-        * A comparison function that returns -1, 0 or 1 depending on whether the 
-        * first string is longer, the same length or shorter than the second 
+        * A comparison function that returns -1, 0 or 1 depending on whether the
+        * first string is longer, the same length or shorter than the second
         * string.
         *
         * @param $s1 string
@@ -633,7 +633,7 @@ class MagicWordArray {
        /**
         * Add a number of magic words by name
         *
-        * $param $names array
+        * @param $names array
         */
        public function addArray( $names ) {
                $this->names = array_merge( $this->names, array_values( $names ) );
@@ -721,7 +721,7 @@ class MagicWordArray {
                        $newRegex[0] = "/^(?:{$base[0]})/iuS";
                }
                if ( $base[1] !== '' ) {
-                       $newRegex[1] = "/^(?:{$base[1]})/S"; 
+                       $newRegex[1] = "/^(?:{$base[1]})/S";
                }
                return $newRegex;
        }