languages: Replace loop with array_pad()
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Wed, 27 Mar 2019 10:36:51 +0000 (11:36 +0100)
committerThiemo Kreuz (WMDE) <thiemo.kreuz@wikimedia.de>
Thu, 28 Mar 2019 13:52:48 +0000 (13:52 +0000)
Change-Id: Ia5159b44653f033d3db79094e46a0d94e1b1d01e

languages/Language.php

index 9eea7ab..a52ad9a 100644 (file)
@@ -4023,15 +4023,12 @@ class Language {
         * 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 ) );
        }
 
        /**