From: Sam Reed Date: Sun, 4 Sep 2011 21:40:17 +0000 (+0000) Subject: Trim trailing whitespace X-Git-Tag: 1.31.0-rc.0~27911 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=ad39f2da8660219768f46db739be66a27c8eb651;p=lhc%2Fweb%2Fwiklou.git Trim trailing whitespace Add/tweak/update documentation Simplify some boolean returns --- diff --git a/includes/BacklinkCache.php b/includes/BacklinkCache.php index 4de4afb15c..a6ad003986 100644 --- a/includes/BacklinkCache.php +++ b/includes/BacklinkCache.php @@ -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' ); diff --git a/includes/Categoryfinder.php b/includes/Categoryfinder.php index 2567de0d38..4a8ed70938 100644 --- a/includes/Categoryfinder.php +++ b/includes/Categoryfinder.php @@ -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 /** diff --git a/includes/Cookie.php b/includes/Cookie.php index 95a4599fd9..76739ccc39 100644 --- a/includes/Cookie.php +++ b/includes/Cookie.php @@ -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(); } } diff --git a/includes/EditPage.php b/includes/EditPage.php index 6b6a01cd94..d2f141ca43 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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() diff --git a/includes/Fallback.php b/includes/Fallback.php index 2cca1e8184..b517cd169e 100644 --- a/includes/Fallback.php +++ b/includes/Fallback.php @@ -22,7 +22,13 @@ * 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; } - + } diff --git a/includes/FeedUtils.php b/includes/FeedUtils.php index 4502c3a861..e923a282cf 100644 --- a/includes/FeedUtils.php +++ b/includes/FeedUtils.php @@ -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( diff --git a/includes/ForkController.php b/includes/ForkController.php index d87dfb1e72..7fff6aee5a 100644 --- a/includes/ForkController.php +++ b/includes/ForkController.php @@ -125,7 +125,7 @@ class ForkController { /** * Fork a number of worker processes. * - * return string + * @return string */ protected function forkWorkers( $numProcs ) { $this->prepareEnvironment(); diff --git a/includes/IP.php b/includes/IP.php index 055fe85c05..20760d6a28 100644 --- a/includes/IP.php +++ b/includes/IP.php @@ -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 ) { diff --git a/includes/Init.php b/includes/Init.php index de8672828f..c4bdc5f7a0 100644 --- a/includes/Init.php +++ b/includes/Init.php @@ -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 ) { diff --git a/includes/Licenses.php b/includes/Licenses.php index 09fa8db350..8a06c6fcfe 100644 --- a/includes/Licenses.php +++ b/includes/Licenses.php @@ -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; diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index a18d84923e..edebf866c3 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -279,7 +279,8 @@ class LogEventsList { } /** - * @return boolean Checkbox + * @param $pattern + * @return string Checkbox */ private function getTitlePattern( $pattern ) { return '' . @@ -287,6 +288,10 @@ class LogEventsList { ''; } + /** + * @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 "\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 = '' . @@ -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 = '' . @@ -373,6 +394,10 @@ class LogEventsList { return $action; } + /** + * @param $row + * @return string + */ private function logComment( $row ) { if( self::isDeleted( $row, LogPage::DELETED_COMMENT ) ) { $comment = '' . @@ -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; } diff --git a/includes/LogPage.php b/includes/LogPage.php index a52ac2ac4b..a9486938f8 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -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; diff --git a/includes/MagicWord.php b/includes/MagicWord.php index d15793802b..e3279718a4 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -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; }