Merge "languages: Replace loop with array_pad()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 2 Apr 2019 01:34:43 +0000 (01:34 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 2 Apr 2019 01:34:43 +0000 (01:34 +0000)
1  2 
languages/Language.php

diff --combined languages/Language.php
@@@ -3515,8 -3515,8 +3515,8 @@@ class Language 
         * Truncate a string to a specified number of characters, appending an optional
         * string (e.g. for ellipsis).
         *
 -       * This provides multibyte version of truncate() method of this class, suitable for truncation
 -       * based on number of characters, instead of number of bytes.
 +       * This provides multibyte version of truncateForDatabase() method of this class,
 +       * suitable for truncation based on number of characters, instead of number of bytes.
         *
         * If $length is negative, the string will be truncated from the beginning.
         *
         * Checks that convertPlural was given an array and pads it to requested
         * amount of forms by copying the last one.
         *
-        * @param array $forms Array of forms given to convertPlural
+        * @param array $forms
         * @param int $count How many forms should there be at least
-        * @return array Padded array of forms or an exception if not an array
+        * @return array Padded array of forms
         */
        protected function preConvertPlural( /* Array */ $forms, $count ) {
-               while ( count( $forms ) < $count ) {
-                       $forms[] = $forms[count( $forms ) - 1];
-               }
-               return $forms;
+               return array_pad( $forms, $count, end( $forms ) );
        }
  
        /**