Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/121340

Change subject: LanguageFallbackChain type hint and inline documentation cleanup
......................................................................

LanguageFallbackChain type hint and inline documentation cleanup

Change-Id: I03bc6151d8ca4f3de17f30410cb2e4a187b45af5
---
M lib/includes/LanguageFallbackChain.php
M lib/includes/LanguageFallbackChainFactory.php
M lib/tests/phpunit/LanguageFallbackChainFactoryTest.php
M lib/tests/phpunit/LanguageFallbackChainTest.php
4 files changed, 20 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/40/121340/1

diff --git a/lib/includes/LanguageFallbackChain.php 
b/lib/includes/LanguageFallbackChain.php
index 92502d5..179091b 100644
--- a/lib/includes/LanguageFallbackChain.php
+++ b/lib/includes/LanguageFallbackChain.php
@@ -2,7 +2,7 @@
 
 namespace Wikibase;
 
-use \Language;
+use Language;
 
 /**
  * FIXME: this class is not a language fallback chain. It takes and uses a 
fallback chain.
@@ -17,7 +17,7 @@
        /**
         * @var LanguageWithConversion[]
         */
-       private $chain = array();
+       private $chain;
 
        /**
         * @param LanguageWithConversion[] $chain
@@ -46,7 +46,7 @@
         *      'source' => language code of the language where the value is 
translated from
         * ), or null when no "acceptable" data can be found.
         */
-       public function extractPreferredValue( $data ) {
+       public function extractPreferredValue( array $data ) {
 
                foreach ( $this->chain as $languageWithConversion ) {
                        $fetchCode = 
$languageWithConversion->getFetchLanguageCode();
@@ -75,7 +75,7 @@
         *      'source' => language code of the language where the value is 
translated from
         * ), or null when no data with a valid language code can be found.
         */
-       public function extractPreferredValueOrAny( $data ) {
+       public function extractPreferredValueOrAny( array $data ) {
                $preferred = $this->extractPreferredValue( $data );
 
                if ( $preferred ) {
@@ -94,4 +94,5 @@
 
                return null;
        }
+
 }
diff --git a/lib/includes/LanguageFallbackChainFactory.php 
b/lib/includes/LanguageFallbackChainFactory.php
index fdc7b43..390b923 100644
--- a/lib/includes/LanguageFallbackChainFactory.php
+++ b/lib/includes/LanguageFallbackChainFactory.php
@@ -39,12 +39,12 @@
        const FALLBACK_OTHERS = 4;
 
        /**
-        * @var array
+        * @var array[]
         */
        public $languageCache;
 
        /**
-        * @var array
+        * @var array[]
         */
        public $userLanguageCache;
 
@@ -54,10 +54,8 @@
        public $anonymousPageViewCached;
 
        /**
-        * Constructor.
-        *
-        * @param $anonymousPageViewCached bool
-        *          Whether full page outputs are cached for anons, so some 
fine-grained fallbacks shouldn't be used for them.
+        * @param bool $anonymousPageViewCached Whether full page outputs are 
cached for anons, so some
+        * fine-grained fallbacks shouldn't be used for them.
         */
        public function __construct( $anonymousPageViewCached = false ) {
                $this->anonymousPageViewCached = $anonymousPageViewCached;
@@ -67,7 +65,7 @@
         * Get the fallback chain based a single language, and specified 
fallback level.
         *
         * @param Language $language
-        * @param mixed $mode bitfield of self::FALLBACK_*
+        * @param int $mode Bitfield of self::FALLBACK_*
         *
         * @return LanguageFallbackChain
         */
@@ -89,7 +87,7 @@
         * Get the fallback chain based a single language code, and specified 
fallback level.
         *
         * @param string $languageCode
-        * @param mixed $mode bitfield of self::FALLBACK_*
+        * @param int $mode Bitfield of self::FALLBACK_*
         *
         * @return LanguageFallbackChain
         */
@@ -113,7 +111,7 @@
         * Build fallback chain array for a given language or validated 
language code.
         *
         * @param $language Language object or language code as string
-        * @param $mode bitfield of self::FALLBACK_*
+        * @param int $mode Bitfield of self::FALLBACK_*
         * @param LanguageFallbackChain[] $chain for recursive calls
         * @param array $fetched for recursive calls
         *
@@ -136,6 +134,7 @@
                }
 
                if ( $mode & self::FALLBACK_VARIANTS ) {
+                       /** @var Language $parentLanguage */
                        $pieces = explode( '-', $languageCode );
                        if ( !in_array( $pieces[0], 
LanguageConverter::$languagesWithVariants ) ) {
                                $parentLanguage = null;
diff --git a/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php 
b/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php
index 949dc00..b1b9ab3 100644
--- a/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php
+++ b/lib/tests/phpunit/LanguageFallbackChainFactoryTest.php
@@ -18,7 +18,11 @@
  */
 class LanguageFallbackChainFactoryTest extends \MediaWikiTestCase {
 
-       private function assertChainEquals( $expectedItems, $chain ) {
+       /**
+        * @param array $expectedItems
+        * @param \Wikibase\LanguageWithConversion[] $chain
+        */
+       private function assertChainEquals( array $expectedItems, array $chain 
) {
                $this->assertEquals( count( $expectedItems ), count( $chain ) );
 
                foreach ( $expectedItems as $i => $expected ) {
@@ -376,4 +380,5 @@
                        ),
                );
        }
+
 }
diff --git a/lib/tests/phpunit/LanguageFallbackChainTest.php 
b/lib/tests/phpunit/LanguageFallbackChainTest.php
index 2bf1bb7..83cecc9 100644
--- a/lib/tests/phpunit/LanguageFallbackChainTest.php
+++ b/lib/tests/phpunit/LanguageFallbackChainTest.php
@@ -163,4 +163,5 @@
                        array( 'ar', 
LanguageFallbackChainFactory::FALLBACK_SELF, array(), null ),
                );
        }
+
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/121340
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I03bc6151d8ca4f3de17f30410cb2e4a187b45af5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to