r104473 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104472‎ | r104473 | r104474 >
Date:19:30, 28 November 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
* (bug 32659) Code cleanup: normalize order of params to implode() in Language:: functions

Patch by Daniel Werner, https://bugzilla.wikimedia.org/attachment.cgi?id=9555&action=diff

For "historical reasons" implode() accepts parameters as ($list, $sep) as well as the usual ($sep, $list) but it's better to use the standard to be clear.
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/Language.php
@@ -2788,7 +2788,7 @@
27892789 * @param $l Array
27902790 * @return string
27912791 */
2792 - function listToText( $l ) {
 2792+ function listToText( array $l ) {
27932793 $s = '';
27942794 $m = count( $l ) - 1;
27952795 if ( $m == 1 ) {
@@ -2813,13 +2813,13 @@
28142814 * @param $list array of strings to put in a comma list
28152815 * @return string
28162816 */
2817 - function commaList( $list ) {
2818 - return implode(
2819 - $list,
 2817+ function commaList( array $list ) {
 2818+ return implode(
28202819 wfMsgExt(
28212820 'comma-separator',
28222821 array( 'parsemag', 'escapenoentities', 'language' => $this )
2823 - )
 2822+ ),
 2823+ $list
28242824 );
28252825 }
28262826
@@ -2829,13 +2829,13 @@
28302830 * @param $list array of strings to put in a semicolon list
28312831 * @return string
28322832 */
2833 - function semicolonList( $list ) {
2834 - return implode(
2835 - $list,
 2833+ function semicolonList( array $list ) {
 2834+ return implode(
28362835 wfMsgExt(
28372836 'semicolon-separator',
28382837 array( 'parsemag', 'escapenoentities', 'language' => $this )
2839 - )
 2838+ ),
 2839+ $list
28402840 );
28412841 }
28422842
@@ -2844,13 +2844,13 @@
28452845 * @param $list array of strings to put in a pipe list
28462846 * @return string
28472847 */
2848 - function pipeList( $list ) {
2849 - return implode(
2850 - $list,
 2848+ function pipeList( array $list ) {
 2849+ return implode(
28512850 wfMsgExt(
28522851 'pipe-separator',
28532852 array( 'escapenoentities', 'language' => $this )
2854 - )
 2853+ ),
 2854+ $list
28552855 );
28562856 }
28572857

Comments

#Comment by Nikerabbit (talk | contribs)   09:16, 30 November 2011

Those type annotations might catch some bugs later on.

Status & tagging log