X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=languages%2FLanguage.php;h=a9bbc20c1d490b667bd6958e7cc349600906cd89;hb=3f16fda078025ccf2716f0a6bf10a650244c9d89;hp=6b6e88c075c3747cd2014f75a0633cc189414cb0;hpb=7d129953f6f576c8ee88d792a5905a252c43c62d;p=lhc%2Fweb%2Fwiklou.git diff --git a/languages/Language.php b/languages/Language.php index 6b6e88c075..a9bbc20c1d 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -2854,7 +2854,7 @@ class Language { } /** - * @return array + * @return string */ function fallback8bitEncoding() { return self::$dataCache->getItem( $this->mCode, 'fallback8bitEncoding' ); @@ -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 ) ); } /** @@ -4409,18 +4403,6 @@ class Language { return $this->mHtmlCode; } - /** - * @param string $code - * @deprecated since 1.32, use Language::factory to create a new object instead. - */ - public function setCode( $code ) { - wfDeprecated( __METHOD__, '1.32' ); - $this->mCode = $code; - // Ensure we don't leave incorrect cached data lying around - $this->mHtmlCode = null; - $this->mParentLanguage = false; - } - /** * Get the language code from a file name. Inverse of getFileName() * @param string $filename $prefix . $languageCode . $suffix