Use PHP's implode() with the suggested order of arguments
authorFomafix <fomafix@googlemail.com>
Thu, 22 Feb 2018 19:24:00 +0000 (20:24 +0100)
committerFomafix <fomafix@googlemail.com>
Thu, 22 Feb 2018 19:24:00 +0000 (20:24 +0100)
https://secure.php.net/manual/en/function.implode.php defines the order
of arguments as

 string implode ( string $glue , array $pieces )
 string implode ( array $pieces )

Note:
  implode() can, for historical reasons, accept its parameters in
  either order. For consistency with explode(), however, it may be less
  confusing to use the documented order of arguments.

Change-Id: I03bf5712204e283f52d3ede54af9b9ec117d4280

includes/EditPage.php
includes/api/ApiCSPReport.php
includes/filerepo/ForeignAPIRepo.php
includes/parser/CoreParserFunctions.php
includes/specials/SpecialEditWatchlist.php
includes/tidy/Balancer.php
maintenance/Maintenance.php
maintenance/language/languages.inc

index f9c7fb2..aae183e 100644 (file)
@@ -3702,7 +3702,7 @@ ERROR;
                $out->addHTML( $this->editFormTextAfterWarn );
 
                $out->addHTML( "<div class='editButtons'>\n" );
-               $out->addHTML( implode( $this->getEditButtons( $tabindex ), "\n" ) . "\n" );
+               $out->addHTML( implode( "\n", $this->getEditButtons( $tabindex ) ) . "\n" );
 
                $cancel = $this->getCancelLink();
 
index 0df0ca9..af040d1 100644 (file)
@@ -162,7 +162,7 @@ class ApiCSPReport extends ApiBase {
        private function generateLogLine( $flags, $report ) {
                $flagText = '';
                if ( $flags ) {
-                       $flagText = '[' . implode( $flags, ', ' ) . ']';
+                       $flagText = '[' . implode( ', ', $flags ) . ']';
                }
 
                $blockedFile = isset( $report['blocked-uri'] ) ? $report['blocked-uri'] : 'n/a';
index 5a37701..1a86648 100644 (file)
@@ -143,7 +143,7 @@ class ForeignAPIRepo extends FileRepo {
                }
 
                $data = $this->fetchImageQuery( [
-                       'titles' => implode( $files, '|' ),
+                       'titles' => implode( '|', $files ),
                        'prop' => 'imageinfo' ]
                );
 
index c6a10ae..d408c7f 100644 (file)
@@ -830,7 +830,7 @@ class CoreParserFunctions {
                        $restrictions = $titleObject->getRestrictions( strtolower( $type ) );
                        # Title::getRestrictions returns an array, its possible it may have
                        # multiple values in the future
-                       return implode( $restrictions, ',' );
+                       return implode( ',', $restrictions );
                }
                return '';
        }
@@ -1339,7 +1339,7 @@ class CoreParserFunctions {
                        foreach ( $sources[0] as $sourceTitle ) {
                                $names[] = $sourceTitle->getPrefixedText();
                        }
-                       return implode( $names, '|' );
+                       return implode( '|', $names );
                }
                return '';
        }
index 0a38ad1..f702bc0 100644 (file)
@@ -657,7 +657,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         * @return HTMLForm
         */
        protected function getRawForm() {
-               $titles = implode( $this->getWatchlist(), "\n" );
+               $titles = implode( "\n", $this->getWatchlist() );
                $fields = [
                        'Titles' => [
                                'type' => 'textarea',
index fa89c1a..c7d9a26 100644 (file)
@@ -1366,7 +1366,7 @@ class BalanceStack implements IteratorAggregate {
                foreach ( $this->elements as $elt ) {
                        array_push( $r, $elt->localName );
                }
-               return implode( $r, ' ' );
+               return implode( ' ', $r );
        }
 }
 
@@ -1904,7 +1904,7 @@ class Balancer {
                                }
                        );
                        if ( count( $bad ) > 0 ) {
-                               $badstr = implode( array_keys( $bad ), ',' );
+                               $badstr = implode( ',', array_keys( $bad ) );
                                throw new ParameterAssertionException(
                                        '$config',
                                        'Balance attempted with sanitization including ' .
index 7e4bf7c..c91fbb4 100644 (file)
@@ -1011,7 +1011,7 @@ abstract class Maintenance {
 
                // ... append parameters ...
                if ( $this->mParams ) {
-                       $output .= " [--" . implode( array_keys( $this->mParams ), "|--" ) . "]";
+                       $output .= " [--" . implode( "|--", array_keys( $this->mParams ) ) . "]";
                }
 
                // ... and append arguments.
index ad80af5..c8fb629 100644 (file)
@@ -558,7 +558,7 @@ class Languages {
                        }
 
                        if ( isset( $messages[$key] ) ) {
-                               $messages[$key] = implode( $messages[$key], ", " );
+                               $messages[$key] = implode( ", ", $messages[$key] );
                        }
                }