From: Fomafix Date: Thu, 22 Feb 2018 19:24:00 +0000 (+0100) Subject: Use PHP's implode() with the suggested order of arguments X-Git-Tag: 1.31.0-rc.0~536^2 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=d59af4c3414f26eee8e970b122081b9360365984;p=lhc%2Fweb%2Fwiklou.git Use PHP's implode() with the suggested order of arguments 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 --- diff --git a/includes/EditPage.php b/includes/EditPage.php index f9c7fb29e8..aae183ee7a 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -3702,7 +3702,7 @@ ERROR; $out->addHTML( $this->editFormTextAfterWarn ); $out->addHTML( "
\n" ); - $out->addHTML( implode( $this->getEditButtons( $tabindex ), "\n" ) . "\n" ); + $out->addHTML( implode( "\n", $this->getEditButtons( $tabindex ) ) . "\n" ); $cancel = $this->getCancelLink(); diff --git a/includes/api/ApiCSPReport.php b/includes/api/ApiCSPReport.php index 0df0ca97d1..af040d153a 100644 --- a/includes/api/ApiCSPReport.php +++ b/includes/api/ApiCSPReport.php @@ -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'; diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index 5a37701285..1a86648889 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -143,7 +143,7 @@ class ForeignAPIRepo extends FileRepo { } $data = $this->fetchImageQuery( [ - 'titles' => implode( $files, '|' ), + 'titles' => implode( '|', $files ), 'prop' => 'imageinfo' ] ); diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index c6a10aefbc..d408c7fffb 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -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 ''; } diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 0a38ad160a..f702bc0bcc 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -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', diff --git a/includes/tidy/Balancer.php b/includes/tidy/Balancer.php index fa89c1a5e1..c7d9a265aa 100644 --- a/includes/tidy/Balancer.php +++ b/includes/tidy/Balancer.php @@ -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 ' . diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 7e4bf7c043..c91fbb43ab 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -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. diff --git a/maintenance/language/languages.inc b/maintenance/language/languages.inc index ad80af5330..c8fb629e77 100644 --- a/maintenance/language/languages.inc +++ b/maintenance/language/languages.inc @@ -558,7 +558,7 @@ class Languages { } if ( isset( $messages[$key] ) ) { - $messages[$key] = implode( $messages[$key], ", " ); + $messages[$key] = implode( ", ", $messages[$key] ); } }