Simplify SpecialVersion:listToText()
authorReedy <reedy@wikimedia.org>
Thu, 17 Apr 2014 19:00:35 +0000 (20:00 +0100)
committerReedy <reedy@wikimedia.org>
Thu, 17 Apr 2014 19:01:43 +0000 (20:01 +0100)
Don't special case $list only having one item

Unindent else block

Bug: 64069
Change-Id: I171a64147fe00f00ac0523ccf58fea11e800e2fd

includes/specials/SpecialVersion.php

index 9ad95ec..dee44cd 100644 (file)
@@ -961,21 +961,15 @@ class SpecialVersion extends SpecialPage {
         * @return string
         */
        function listToText( $list, $sort = true ) {
-               $cnt = count( $list );
-
-               if ( $cnt == 1 ) {
-                       // Enforce always returning a string
-                       return (string)self::arrayToString( $list[0] );
-               } elseif ( $cnt == 0 ) {
+               if ( !count( $list ) ) {
                        return '';
-               } else {
-                       if ( $sort ) {
-                               sort( $list );
-                       }
-
-                       return $this->getLanguage()
-                               ->listToText( array_map( array( __CLASS__, 'arrayToString' ), $list ) );
                }
+               if ( $sort ) {
+                       sort( $list );
+               }
+
+               return $this->getLanguage()
+                       ->listToText( array_map( array( __CLASS__, 'arrayToString' ), $list ) );
        }
 
        /**