X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=languages%2FLanguage.php;h=52cb231561ecfc5fa51a5f1e687a49215e874c04;hb=5dfedaeaa42f13f115ae649ad5cfe319e6acc682;hp=71d350fd28d90dc675c36ef09658f9e1b3c6ef69;hpb=d54d5229858188824f52c06d5bd4ebf46d181341;p=lhc%2Fweb%2Fwiklou.git diff --git a/languages/Language.php b/languages/Language.php index 71d350fd28..52cb231561 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -3556,12 +3556,8 @@ class Language { * @return string */ private function truncateInternal( - $string, $length, $ellipsis, $adjustLength, $measureLength, $getSubstring + $string, $length, $ellipsis, $adjustLength, callable $measureLength, callable $getSubstring ) { - if ( !is_callable( $measureLength ) || !is_callable( $getSubstring ) ) { - throw new InvalidArgumentException( 'Invalid callback provided' ); - } - # Check if there is no need to truncate if ( $measureLength( $string ) <= abs( $length ) ) { return $string; // no need to truncate @@ -3701,6 +3697,7 @@ class Language { } } elseif ( $dispLen > $length && $dispLen > strlen( $ellipsis ) ) { # String in fact does need truncation, the truncation point was OK. + // @phan-suppress-next-line PhanTypeInvalidExpressionArrayDestructuring list( $ret, $openTags ) = $maybeState; // reload state $ret = $this->removeBadCharLast( $ret ); // multi-byte char fix $ret .= $ellipsis; // add ellipsis @@ -4023,15 +4020,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 ) ); } /** @@ -4857,6 +4851,8 @@ class Language { * @param array $query Optional URL query parameter string * @param bool $atend Optional param for specified if this is the last page * @return string + * @deprecated since 1.33, use SpecialPage::viewPrevNext() + * instead. */ public function viewPrevNext( Title $title, $offset, $limit, array $query = [], $atend = false