Merge "Stop php strict error warnings from MemcachedClient::_flush_read_buffer()"
[lhc/web/wiklou.git] / maintenance / language / checkLanguage.inc
index f18afde..1860f4a 100644 (file)
@@ -41,9 +41,9 @@ class CheckLanguageCLI {
 
        /**
         * Constructor.
-        * @param $options Options for script.
+        * @param $options array Options for script.
         */
-       public function __construct( Array $options ) {
+       public function __construct( array $options ) {
                if ( isset( $options['help'] ) ) {
                        echo $this->help();
                        exit(1);
@@ -94,7 +94,7 @@ class CheckLanguageCLI {
 
        /**
         * Get the default checks.
-        * @return A list of the default checks.
+        * @return array A list of the default checks.
         */
        protected function defaultChecks() {
                return array(
@@ -107,7 +107,7 @@ class CheckLanguageCLI {
 
        /**
         * Get the checks which check other things than messages.
-        * @return A list of the non-message checks.
+        * @return array A list of the non-message checks.
         */
        protected function nonMessageChecks() {
                return array(
@@ -118,7 +118,7 @@ class CheckLanguageCLI {
 
        /**
         * Get the checks that can easily be treated by non-speakers of the language.
-        * @return A list of the easy checks.
+        * @return Array A list of the easy checks.
         */
        protected function easyChecks() {
                return array(
@@ -129,7 +129,7 @@ class CheckLanguageCLI {
 
        /**
         * Get all checks.
-        * @return An array of all check names mapped to their function names.
+        * @return array An array of all check names mapped to their function names.
         */
        protected function getChecks() {
                return array(
@@ -157,7 +157,7 @@ class CheckLanguageCLI {
 
        /**
         * Get total count for each check non-messages check.
-        * @return An array of all check names mapped to a two-element array:
+        * @return array An array of all check names mapped to a two-element array:
         * function name to get the total count and language code or null
         * for checked code.
         */
@@ -176,7 +176,7 @@ class CheckLanguageCLI {
 
        /**
         * Get all check descriptions.
-        * @return An array of all check names mapped to their descriptions.
+        * @return array An array of all check names mapped to their descriptions.
         */
        protected function getDescriptions() {
                return array(
@@ -204,7 +204,7 @@ class CheckLanguageCLI {
 
        /**
         * Get help.
-        * @return The help string.
+        * @return string The help string.
         */
        protected function help() {
                return <<<ENDS
@@ -222,17 +222,17 @@ Parameters:
        --links: Link the message values (default off).
        --prefix: prefix to add to links.
        --wikilang: For the links, what is the content language of the wiki to display the output in (default en).
-       --noexif: Don't check for EXIF messages (a bit hard and boring to translate), if you know
+       --noexif: Do not check for EXIF messages (a bit hard and boring to translate), if you know
                that they are currently not translated and want to focus on other problems (default off).
        --whitelist: Do only the following checks (form: code,code).
-       --blacklist: Don't do the following checks (form: code,code).
+       --blacklist: Do not do the following checks (form: code,code).
        --easy: Do only the easy checks, which can be treated by non-speakers of the language.
 
 Check codes (ideally, all of them should result 0; all the checks are executed by default (except language-specific check blacklists in checkLanguage.inc):
        * untranslated: Messages which are required to translate, but are not translated.
        * duplicate: Messages which translation equal to fallback
        * obsolete: Messages which are untranslatable or do not exist, but are translated.
-       * variables: Messages without variables which should be used, or with variables which shouldn't be used.
+       * variables: Messages without variables which should be used, or with variables which should not be used.
        * empty: Empty messages and messages that contain only -.
        * whitespace: Messages which have trailing whitespace.
        * xhtml: Messages which are not well-formed XHTML (checks only few common errors).
@@ -295,7 +295,7 @@ ENDS;
 
        /**
         * Get the check blacklist.
-        * @return The list of checks which should not be executed.
+        * @return array The list of checks which should not be executed.
         */
        protected function getCheckBlacklist() {
                global $checkBlacklist;
@@ -304,17 +304,18 @@ ENDS;
 
        /**
         * Check a language.
-        * @param $code The language code.
-        * @return The results.
+        * @param $code string The language code.
+        * @throws MWException
+        * @return array The results.
         */
        protected function checkLanguage( $code ) {
                # Syntax check only
+               $results = array();
                if ( $this->level === 0 ) {
                        $this->L->getMessages( $code );
-                       return;
+                       return $results;
                }
 
-               $results = array();
                $checkFunctions = $this->getChecks();
                $checkBlacklist = $this->getCheckBlacklist();
                foreach ( $this->checks as $check ) {
@@ -336,9 +337,9 @@ ENDS;
 
        /**
         * Format a message key.
-        * @param $key The message key.
-        * @param $code The language code.
-        * @return The formatted message key.
+        * @param $key string The message key.
+        * @param $code string The language code.
+        * @return string The formatted message key.
         */
        protected function formatKey( $key, $code ) {
                if ( $this->doLinks ) {
@@ -355,7 +356,6 @@ ENDS;
 
        /**
         * Output the checks results as plain text.
-        * @return The checks results as plain text.
         */
        protected function outputText() {
                foreach ( $this->results as $code => $results ) {
@@ -401,10 +401,8 @@ ENDS;
 
        /**
         * Output the checks results as wiki text.
-        * @return The checks results as wiki text.
         */
        function outputWiki() {
-               global $wgContLang;
                $detailText = '';
                $rows[] = '! Language !! Code !! Total !! ' . implode( ' !! ', array_diff( $this->checks, $this->nonMessageChecks() ) );
                foreach ( $this->results as $code => $results ) {
@@ -440,7 +438,7 @@ ENDS;
                                # Don't list languages without problems
                                continue;
                        }
-                       $language = $wgContLang->getLanguageName( $code );
+                       $language = Language::fetchLanguageName( $code );
                        $rows[] = "| $language || $code || $problems || " . implode( ' || ', $numbers );
                }
 
@@ -462,7 +460,7 @@ EOL;
 
        /**
         * Check if there are any results for the checks, in any language.
-        * @return True if there are any results, false if not.
+        * @return bool True if there are any results, false if not.
         */
        protected function isEmpty() {
                foreach( $this->results as $results ) {
@@ -484,10 +482,10 @@ class CheckExtensionsCLI extends CheckLanguageCLI {
 
        /**
         * Constructor.
-        * @param $options Options for script.
-        * @param $extension The extension name (or names).
+        * @param $options array Options for script.
+        * @param $extension string The extension name (or names).
         */
-       public function __construct( Array $options, $extension ) {
+       public function __construct( array $options, $extension ) {
                if ( isset( $options['help'] ) ) {
                        echo $this->help();
                        exit(1);
@@ -569,7 +567,7 @@ class CheckExtensionsCLI extends CheckLanguageCLI {
 
        /**
         * Get the default checks.
-        * @return A list of the default checks.
+        * @return array A list of the default checks.
         */
        protected function defaultChecks() {
                return array(
@@ -580,7 +578,7 @@ class CheckExtensionsCLI extends CheckLanguageCLI {
 
        /**
         * Get the checks which check other things than messages.
-        * @return A list of the non-message checks.
+        * @return array A list of the non-message checks.
         */
        protected function nonMessageChecks() {
                return array();
@@ -588,7 +586,7 @@ class CheckExtensionsCLI extends CheckLanguageCLI {
 
        /**
         * Get the checks that can easily be treated by non-speakers of the language.
-        * @return A list of the easy checks.
+        * @return arrayA list of the easy checks.
         */
        protected function easyChecks() {
                return array(
@@ -598,7 +596,7 @@ class CheckExtensionsCLI extends CheckLanguageCLI {
 
        /**
         * Get help.
-        * @return The help string.
+        * @return string The help string.
         */
        protected function help() {
                return <<<ENDS
@@ -643,7 +641,8 @@ ENDS;
 
        /**
         * Check a language and show the results.
-        * @param $code The language code.
+        * @param $code string The language code.
+        * @throws MWException
         */
        protected function checkLanguage( $code ) {
                foreach( $this->extensions as $extension ) {