r100127 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100126‎ | r100127 | r100128 >
Date:17:27, 18 October 2011
Author:reedy
Status:ok
Tags:
Comment:
Documentation

Explicit member variable definitions

Simplify some code
Modified paths:
  • /trunk/phase3/includes/WebRequest.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)
  • /trunk/phase3/languages/classes/LanguageIu.php (modified) (history)
  • /trunk/phase3/languages/classes/LanguageQqx.php (modified) (history)
  • /trunk/phase3/languages/classes/LanguageShi.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WebRequest.php
@@ -946,7 +946,7 @@
947947
948948 /**
949949 * Parse the Accept-Language header sent by the client into an array
950 - * @return array( languageCode => q-value ) sorted by q-value in descending order
 950+ * @return array array( languageCode => q-value ) sorted by q-value in descending order
951951 * May contain the "language" '*', which applies to languages other than those explicitly listed.
952952 * This is aligned with rfc2616 section 14.4
953953 */
Index: trunk/phase3/languages/LanguageConverter.php
@@ -117,7 +117,7 @@
118118 * in this case. Right now this is only used by zh.
119119 *
120120 * @param $variant String: the language code of the variant
121 - * @return String: The code of the fallback language or the
 121+ * @return String|array: The code of the fallback language or the
122122 * main code if there is no fallback
123123 */
124124 public function getVariantFallbacks( $variant ) {
@@ -368,11 +368,11 @@
369369 $sourceBlob .= substr( $text, $startPos, $elementPos - $startPos ) . "\000";
370370
371371 // Advance to the next position
372 - $startPos = $elementPos + strlen( $element );
 372+ $startPos = $elementPos + strlen( $element );
373373
374374 // Translate any alt or title attributes inside the matched element
375 - if ( $element !== '' && preg_match( '/^(<[^>\s]*)\s([^>]*)(.*)$/', $element,
376 - $elementMatches ) )
 375+ if ( $element !== '' && preg_match( '/^(<[^>\s]*)\s([^>]*)(.*)$/', $element,
 376+ $elementMatches ) )
377377 {
378378 $attrs = Sanitizer::decodeTagAttributes( $elementMatches[2] );
379379 $changed = false;
@@ -385,7 +385,7 @@
386386 if ( !strpos( $attr, '://' ) ) {
387387 $attr = $this->translate( $attr, $toVariant );
388388 }
389 -
 389+
390390 // Remove HTML tags to avoid disrupting the layout
391391 $attr = preg_replace( '/<[^>]+>/', '', $attr );
392392 if ( $attr !== $attrs[$attrName] ) {
@@ -394,7 +394,7 @@
395395 }
396396 }
397397 if ( $changed ) {
398 - $element = $elementMatches[1] . Html::expandAttributes( $attrs ) .
 398+ $element = $elementMatches[1] . Html::expandAttributes( $attrs ) .
399399 $elementMatches[3];
400400 }
401401 }
Index: trunk/phase3/languages/Language.php
@@ -239,7 +239,7 @@
240240 /**
241241 * Includes language class files
242242 *
243 - * @param $class Name of the language class
 243+ * @param $class string Name of the language class
244244 */
245245 public static function preloadLanguageClass( $class ) {
246246 global $IP;
@@ -1212,7 +1212,7 @@
12131213 }
12141214
12151215 // Days passed in current month
1216 - $gDayNo += $gd;
 1216+ $gDayNo += (int)$gd;
12171217
12181218 $jDayNo = $gDayNo - 79;
12191219
@@ -1573,7 +1573,7 @@
15741574 $s = '';
15751575 for ( $pow10 = 1000, $i = 3; $i >= 0; $pow10 /= 10, $i-- ) {
15761576 if ( $num >= $pow10 ) {
1577 - $s .= $table[$i][floor( $num / $pow10 )];
 1577+ $s .= $table[$i][(int)floor( $num / $pow10 )];
15781578 }
15791579 $num = $num % $pow10;
15801580 }
@@ -3097,10 +3097,10 @@
30983098 * truncateHtml() helper function
30993099 * (a) push or pop $tag from $openTags as needed
31003100 * (b) clear $tag value
3101 - * @param String &$tag Current HTML tag name we are looking at
3102 - * @param int $tagType (0-open tag, 1-close tag)
3103 - * @param char $lastCh Character before the '>' that ended this tag
3104 - * @param array &$openTags Open tag stack (not accounting for $tag)
 3101+ * @param &$tag string Current HTML tag name we are looking at
 3102+ * @param $tagType int (0-open tag, 1-close tag)
 3103+ * @param $lastCh char|string Character before the '>' that ended this tag
 3104+ * @param &$openTags array Open tag stack (not accounting for $tag)
31053105 */
31063106 private function truncate_endBracket( &$tag, $tagType, $lastCh, &$openTags ) {
31073107 $tag = ltrim( $tag );
@@ -3762,7 +3762,7 @@
37633763 if ( $bps <= 0 ) {
37643764 return $this->formatNum( $bps ) . $units[0];
37653765 }
3766 - $unitIndex = floor( log10( $bps ) / 3 );
 3766+ $unitIndex = (int)floor( log10( $bps ) / 3 );
37673767 $mantissa = $bps / pow( 1000, $unitIndex );
37683768 if ( $mantissa < 10 ) {
37693769 $mantissa = round( $mantissa, 1 );
Index: trunk/phase3/languages/classes/LanguageIu.php
@@ -7,8 +7,8 @@
88 * Conversion script between Latin and Syllabics for Inuktitut.
99 * - Syllabics -> lowercase Latin
1010 * - lowercase/uppercase Latin -> Syllabics
11 -*
1211 *
 12+*
1313 * Based on:
1414 * - http://commons.wikimedia.org/wiki/Image:Inuktitut.png
1515 * - LanguageSr.php
@@ -21,6 +21,8 @@
2222 *
2323 */
2424 class IuConverter extends LanguageConverter {
 25+
 26+ protected $mDoContentConvert;
2527 var $mToLatin = array(
2628 'ᐦ' => 'h', 'ᐃ' => 'i', 'ᐄ' => 'ii', 'ᐅ' => 'u', 'ᐆ' => 'uu', 'ᐊ' => 'a', 'ᐋ' => 'aa',
2729 'ᑉ' => 'p', 'ᐱ' => 'pi', 'ᐲ' => 'pii', 'ᐳ' => 'pu', 'ᐴ' => 'puu', 'ᐸ' => 'pa', 'ᐹ' => 'paa',
@@ -111,10 +113,7 @@
112114 * @return string
113115 */
114116 function parserConvert( $text, &$parser ) {
115 - if ( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() )
116 - $this->mDoContentConvert = false;
117 - else
118 - $this->mDoContentConvert = true;
 117+ $this->mDoContentConvert = !( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() );
119118
120119 return parent::parserConvert( $text, $parser );
121120 }
Index: trunk/phase3/languages/classes/LanguageShi.php
@@ -7,8 +7,8 @@
88 * Conversion script between Latin and Tifinagh for Tachelhit.
99 * - Tifinagh -> lowercase Latin
1010 * - lowercase/uppercase Latin -> Tifinagh
11 -*
1211 *
 12+*
1313 * Based on:
1414 * - http://en.wikipedia.org/wiki/Shilha_language
1515 * - LanguageSr.php
@@ -21,6 +21,9 @@
2222 *
2323 */
2424 class ShiConverter extends LanguageConverter {
 25+
 26+ protected $mDoContentConvert;
 27+
2528 var $mToLatin = array(
2629 'ⴰ' => 'a', 'ⴱ' => 'b', 'ⴳ' => 'g', 'ⴷ' => 'd', 'ⴹ' => 'ḍ', 'ⴻ' => 'e',
2730 'ⴼ' => 'f', 'ⴽ' => 'k', 'ⵀ' => 'h', 'ⵃ' => 'ḥ', 'ⵄ' => 'ε', 'ⵅ' => 'x',
@@ -89,10 +92,7 @@
9093 * @return string
9194 */
9295 function parserConvert( $text, &$parser ) {
93 - if ( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() )
94 - $this->mDoContentConvert = false;
95 - else
96 - $this->mDoContentConvert = true;
 96+ $this->mDoContentConvert = !( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() );
9797
9898 return parent::parserConvert( $text, $parser );
9999 }
Index: trunk/phase3/languages/classes/LanguageQqx.php
@@ -9,6 +9,10 @@
1010 * @ingroup Language
1111 */
1212 class LanguageQqx extends Language {
 13+ /**
 14+ * @param $key string
 15+ * @return string
 16+ */
1317 function getMessage( $key ) {
1418 return "($key)";
1519 }

Status & tagging log