Documentation
authorSam Reed <reedy@users.mediawiki.org>
Tue, 18 Oct 2011 17:27:52 +0000 (17:27 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Tue, 18 Oct 2011 17:27:52 +0000 (17:27 +0000)
Explicit member variable definitions

Simplify some code

includes/WebRequest.php
languages/Language.php
languages/LanguageConverter.php
languages/classes/LanguageIu.php
languages/classes/LanguageQqx.php
languages/classes/LanguageShi.php

index 84e7e78..2721a5b 100644 (file)
@@ -946,7 +946,7 @@ HTML;
 
        /**
         * Parse the Accept-Language header sent by the client into an array
-        * @return array( languageCode => q-value ) sorted by q-value in descending order
+        * @return array array( languageCode => q-value ) sorted by q-value in descending order
         * May contain the "language" '*', which applies to languages other than those explicitly listed.
         * This is aligned with rfc2616 section 14.4
         */
index 5e8ab1c..4c985d9 100644 (file)
@@ -239,7 +239,7 @@ class Language {
        /**
         * Includes language class files
         *
-        * @param $class Name of the language class
+        * @param $class string Name of the language class
         */
        public static function preloadLanguageClass( $class ) {
                global $IP;
@@ -1212,7 +1212,7 @@ class Language {
                }
 
                // Days passed in current month
-               $gDayNo += $gd;
+               $gDayNo += (int)$gd;
 
                $jDayNo = $gDayNo - 79;
 
@@ -1573,7 +1573,7 @@ class Language {
                $s = '';
                for ( $pow10 = 1000, $i = 3; $i >= 0; $pow10 /= 10, $i-- ) {
                        if ( $num >= $pow10 ) {
-                               $s .= $table[$i][floor( $num / $pow10 )];
+                               $s .= $table[$i][(int)floor( $num / $pow10 )];
                        }
                        $num = $num % $pow10;
                }
@@ -3097,10 +3097,10 @@ class Language {
         * truncateHtml() helper function
         * (a) push or pop $tag from $openTags as needed
         * (b) clear $tag value
-        * @param String &$tag Current HTML tag name we are looking at
-        * @param int $tagType (0-open tag, 1-close tag)
-        * @param char $lastCh Character before the '>' that ended this tag
-        * @param array &$openTags Open tag stack (not accounting for $tag)
+        * @param &$tag string Current HTML tag name we are looking at
+        * @param $tagType int (0-open tag, 1-close tag)
+        * @param $lastCh char|string Character before the '>' that ended this tag
+        * @param &$openTags array Open tag stack (not accounting for $tag)
         */
        private function truncate_endBracket( &$tag, $tagType, $lastCh, &$openTags ) {
                $tag = ltrim( $tag );
@@ -3762,7 +3762,7 @@ class Language {
                if ( $bps <= 0 ) {
                        return $this->formatNum( $bps ) . $units[0];
                }
-               $unitIndex = floor( log10( $bps ) / 3 );
+               $unitIndex = (int)floor( log10( $bps ) / 3 );
                $mantissa = $bps / pow( 1000, $unitIndex );
                if ( $mantissa < 10 ) {
                        $mantissa = round( $mantissa, 1 );
index 5cf714d..64cb4be 100644 (file)
@@ -117,7 +117,7 @@ class LanguageConverter {
         * in this case. Right now this is only used by zh.
         *
         * @param $variant String: the language code of the variant
-        * @return String: The code of the fallback language or the
+        * @return String|array: The code of the fallback language or the
         *                               main code if there is no fallback
         */
        public function getVariantFallbacks( $variant ) {
@@ -368,11 +368,11 @@ class LanguageConverter {
                        $sourceBlob .= substr( $text, $startPos, $elementPos - $startPos ) . "\000";
 
                        // Advance to the next position
-                       $startPos = $elementPos + strlen( $element );           
+                       $startPos = $elementPos + strlen( $element );
 
                        // Translate any alt or title attributes inside the matched element
-                       if ( $element !== '' && preg_match( '/^(<[^>\s]*)\s([^>]*)(.*)$/', $element, 
-                               $elementMatches ) ) 
+                       if ( $element !== '' && preg_match( '/^(<[^>\s]*)\s([^>]*)(.*)$/', $element,
+                               $elementMatches ) )
                        {
                                $attrs = Sanitizer::decodeTagAttributes( $elementMatches[2] );
                                $changed = false;
@@ -385,7 +385,7 @@ class LanguageConverter {
                                        if ( !strpos( $attr, '://' ) ) {
                                                $attr = $this->translate( $attr, $toVariant );
                                        }
-                                       
+
                                        // Remove HTML tags to avoid disrupting the layout
                                        $attr = preg_replace( '/<[^>]+>/', '', $attr );
                                        if ( $attr !== $attrs[$attrName] ) {
@@ -394,7 +394,7 @@ class LanguageConverter {
                                        }
                                }
                                if ( $changed ) {
-                                       $element = $elementMatches[1] . Html::expandAttributes( $attrs ) . 
+                                       $element = $elementMatches[1] . Html::expandAttributes( $attrs ) .
                                                $elementMatches[3];
                                }
                        }
index c6221de..72f6af1 100644 (file)
@@ -7,7 +7,7 @@
 * Conversion script between Latin and Syllabics for Inuktitut.
 * - Syllabics -> lowercase Latin
 * - lowercase/uppercase Latin -> Syllabics
-* 
+*
 *
 * Based on:
 *   - http://commons.wikimedia.org/wiki/Image:Inuktitut.png
@@ -21,6 +21,8 @@ require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
  *
  */
 class IuConverter extends LanguageConverter {
+
+       protected $mDoContentConvert;
        var $mToLatin = array(
                'ᐦ' => 'h',   'ᐃ' => 'i',    'ᐄ' => 'ii',    'ᐅ' => 'u',    'ᐆ' => 'uu',    'ᐊ' => 'a',    'ᐋ' => 'aa',
                'ᑉ' => 'p',   'ᐱ' => 'pi',   'ᐲ' => 'pii',   'ᐳ' => 'pu',   'ᐴ' => 'puu',   'ᐸ' => 'pa',   'ᐹ' => 'paa',
@@ -111,10 +113,7 @@ class IuConverter extends LanguageConverter {
         * @return string
         */
        function parserConvert( $text, &$parser ) {
-               if ( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() )
-                       $this->mDoContentConvert = false;
-               else
-                       $this->mDoContentConvert = true;
+               $this->mDoContentConvert = !( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() );
 
                return parent::parserConvert( $text, $parser );
        }
index 88d38f5..6798b24 100644 (file)
@@ -9,6 +9,10 @@
  * @ingroup Language
  */
 class LanguageQqx extends Language {
+       /**
+        * @param $key string
+        * @return string
+        */
        function getMessage( $key ) {
                return "($key)";
        }
index 6c7a5fe..7551b7f 100644 (file)
@@ -7,7 +7,7 @@
 * Conversion script between Latin and Tifinagh for Tachelhit.
 * - Tifinagh -> lowercase Latin
 * - lowercase/uppercase Latin -> Tifinagh
-* 
+*
 *
 * Based on:
 *   - http://en.wikipedia.org/wiki/Shilha_language
@@ -21,6 +21,9 @@ require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
  *
  */
 class ShiConverter extends LanguageConverter {
+
+       protected $mDoContentConvert;
+
        var $mToLatin = array(
                'ⴰ' => 'a', 'ⴱ' => 'b', 'ⴳ' => 'g', 'ⴷ' => 'd', 'ⴹ' => 'ḍ', 'ⴻ' => 'e',
                'ⴼ' => 'f', 'ⴽ' => 'k', 'ⵀ' => 'h', 'ⵃ' => 'ḥ', 'ⵄ' => 'ε', 'ⵅ' => 'x',
@@ -89,10 +92,7 @@ class ShiConverter extends LanguageConverter {
         * @return string
         */
        function parserConvert( $text, &$parser ) {
-               if ( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() )
-                       $this->mDoContentConvert = false;
-               else
-                       $this->mDoContentConvert = true;
+               $this->mDoContentConvert = !( is_object( $parser->getTitle() ) && $parser->getTitle()->isTalkPage() );
 
                return parent::parserConvert( $text, $parser );
        }