From 204126e7c7bd29fcd997459149d2dc4be4ef1434 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Fri, 1 Mar 2019 22:15:22 +0100 Subject: [PATCH] Simplify strings in PHP code Change-Id: I481810ade68b0c5a5be21d22e2a107646d5813e6 --- includes/Html.php | 4 ++-- includes/actions/RawAction.php | 2 +- includes/installer/Installer.php | 4 ++-- includes/parser/Parser.php | 2 +- includes/skins/Skin.php | 6 +++--- maintenance/mergeMessageFileList.php | 2 +- tests/phpunit/includes/jobqueue/JobTest.php | 2 +- .../includes/libs/rdbms/database/DatabaseSQLTest.php | 2 +- .../libs/stats/PrefixingStatsdDataFactoryProxyTest.php | 4 ++-- tests/phpunit/includes/linker/LinkRendererTest.php | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/includes/Html.php b/includes/Html.php index 1e597b6592..61785d5e72 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -213,7 +213,7 @@ class Html { // Silly XML. return substr( $start, 0, -1 ) . '/>'; } else { - return "$start$contents" . self::closeElement( $element ); + return $start . $contents . self::closeElement( $element ); } } @@ -973,7 +973,7 @@ class Html { if ( $isXHTML ) { // XHTML5 // XML MIME-typed markup should have an xml header. // However a DOCTYPE is not needed. - $ret .= "\n"; + $ret .= "\n"; // Add the standard xmlns $attribs['xmlns'] = 'http://www.w3.org/1999/xhtml'; diff --git a/includes/actions/RawAction.php b/includes/actions/RawAction.php index 73594bce3a..c8f1a8d2f0 100644 --- a/includes/actions/RawAction.php +++ b/includes/actions/RawAction.php @@ -116,7 +116,7 @@ class RawAction extends FormlessAction { $elevatedText = $elevated ? 'by elevated ' : ''; $log = LoggerFactory::getInstance( "security" ); $log->warning( - "Unsafe JS/CSS/Json $elevatedText" . "load - {user} loaded {title} with {ctype}", + "Unsafe JS/CSS/Json {$elevatedText}load - {user} loaded {title} with {ctype}", [ 'user' => $this->getUser()->getName(), 'title' => $title->getPrefixedDBKey(), diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 20661f240d..3ac152e9be 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -1184,8 +1184,8 @@ abstract class Installer { public function dirIsExecutable( $dir, $url ) { $scriptTypes = [ 'php' => [ - "]*?|\\s*?)(\/?" . ">)|<(!--)/i"; + $start = "/<($taglist)(\\s+[^>]*?|\\s*?)(\/?>)|<(!--)/i"; while ( $text != '' ) { $p = preg_split( $start, $text, 2, PREG_SPLIT_DELIM_CAPTURE ); diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 54dfff30bd..7ac2927666 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -530,14 +530,14 @@ abstract class Skin extends ContextSource { $colon = $this->msg( 'colon-separator' )->escaped(); if ( !empty( $allCats['normal'] ) ) { - $t = $embed . implode( "{$pop}{$embed}", $allCats['normal'] ) . $pop; + $t = $embed . implode( $pop . $embed, $allCats['normal'] ) . $pop; $msg = $this->msg( 'pagecategories' )->numParams( count( $allCats['normal'] ) )->escaped(); $linkPage = $this->msg( 'pagecategorieslink' )->inContentLanguage()->text(); $title = Title::newFromText( $linkPage ); $link = $title ? Linker::link( $title, $msg ) : $msg; $s .= ''; + $link . $colon . ''; } # Hidden categories @@ -552,7 +552,7 @@ abstract class Skin extends ContextSource { $s .= "
" . $this->msg( 'hidden-categories' )->numParams( count( $allCats['hidden'] ) )->escaped() . - $colon . '' . + $colon . '' . '
'; } diff --git a/maintenance/mergeMessageFileList.php b/maintenance/mergeMessageFileList.php index 51c41db325..6ae506fcf2 100644 --- a/maintenance/mergeMessageFileList.php +++ b/maintenance/mergeMessageFileList.php @@ -185,7 +185,7 @@ if ( $queue ) { fwrite( STDERR, "\n" ); $s = - "<" . "?php\n" . + "assertSame( 'Invalid atomic section ended (got ' . __METHOD__ . ' but expected ' . - __METHOD__ . 'X' . ').', + __METHOD__ . 'X).', $ex->getMessage() ); } diff --git a/tests/phpunit/includes/libs/stats/PrefixingStatsdDataFactoryProxyTest.php b/tests/phpunit/includes/libs/stats/PrefixingStatsdDataFactoryProxyTest.php index b55d8697db..46e23e36db 100644 --- a/tests/phpunit/includes/libs/stats/PrefixingStatsdDataFactoryProxyTest.php +++ b/tests/phpunit/includes/libs/stats/PrefixingStatsdDataFactoryProxyTest.php @@ -31,7 +31,7 @@ class PrefixingStatsdDataFactoryProxyTest extends PHPUnit\Framework\TestCase { ); $innerFactory->expects( $this->once() ) ->method( $method ) - ->with( 'testprefix.' . 'metricname' ); + ->with( 'testprefix.metricname' ); $proxy = new PrefixingStatsdDataFactoryProxy( $innerFactory, 'testprefix' ); // 1,2,3,4 simply makes sure we provide enough parameters, without caring what they are @@ -48,7 +48,7 @@ class PrefixingStatsdDataFactoryProxyTest extends PHPUnit\Framework\TestCase { ); $innerFactory->expects( $this->once() ) ->method( $method ) - ->with( 'testprefix.' . 'metricname' ); + ->with( 'testprefix.metricname' ); $proxy = new PrefixingStatsdDataFactoryProxy( $innerFactory, 'testprefix...' ); // 1,2,3,4 simply makes sure we provide enough parameters, without caring what they are diff --git a/tests/phpunit/includes/linker/LinkRendererTest.php b/tests/phpunit/includes/linker/LinkRendererTest.php index 9b1a3ddeb2..91ee276550 100644 --- a/tests/phpunit/includes/linker/LinkRendererTest.php +++ b/tests/phpunit/includes/linker/LinkRendererTest.php @@ -51,7 +51,7 @@ class LinkRendererTest extends MediaWikiLangTestCase { // Query added $this->assertEquals( - 'Foobar', + 'Foobar', $linkRenderer->makeKnownLink( $target, null, [], [ 'foo' => 'bar' ] ) ); -- 2.20.1