Merge "Simplify private listToText() implementation"

This commit is contained in:
jenkins-bot 2019-10-25 08:32:49 +00:00 committed by Gerrit Code Review
commit f62736c58c

View file

@ -1099,16 +1099,15 @@ class Cite {
* @return string
*/
private function listToText( array $arr ) {
$cnt = count( $arr );
if ( $cnt === 1 ) {
// Enforce always returning a string
return (string)$arr[0];
$lastElement = array_pop( $arr );
if ( $arr === [] ) {
return (string)$lastElement;
}
$sep = wfMessage( 'cite_references_link_many_sep' )->inContentLanguage()->plain();
$and = wfMessage( 'cite_references_link_many_and' )->inContentLanguage()->plain();
$t = array_slice( $arr, 0, $cnt - 1 );
return implode( $sep, $t ) . $and . $arr[$cnt - 1];
return implode( $sep, $arr ) . $and . $lastElement;
}
/**